Skip to content

Commit

Permalink
Unit test: Broadcast intent CONVERSATION_CLEAR.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenega committed Oct 13, 2014
1 parent b4d3619 commit f9b8f66
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/src/org/yaaic/test/receiver/ConversationReceiverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ConversationReceiverTest extends AndroidTestCase implements Convers
private boolean onConversationMessageCalled;
private boolean onNewConversationCalled;
private boolean onRemoveConversationCalled;
private boolean onClearConversationCalled;

private ConversationReceiver receiver;
private String testTarget = "#unittest";
Expand All @@ -47,6 +48,7 @@ public void setUp()
onConversationMessageCalled = false;
onNewConversationCalled = false;
onRemoveConversationCalled = false;
onClearConversationCalled = false;

receiver = new ConversationReceiver(serverId, this);
}
Expand All @@ -59,6 +61,7 @@ public void testMessageBroadcast()
assertTrue(onConversationMessageCalled);
assertFalse(onNewConversationCalled);
assertFalse(onRemoveConversationCalled);
assertFalse(onClearConversationCalled);
}

public void testNewBroadcast()
Expand All @@ -69,6 +72,7 @@ public void testNewBroadcast()
assertFalse(onConversationMessageCalled);
assertTrue(onNewConversationCalled);
assertFalse(onRemoveConversationCalled);
assertFalse(onClearConversationCalled);
}

public void testRemoveBroadcast()
Expand All @@ -79,6 +83,18 @@ public void testRemoveBroadcast()
assertFalse(onConversationMessageCalled);
assertFalse(onNewConversationCalled);
assertTrue(onRemoveConversationCalled);
assertFalse(onClearConversationCalled);
}

public void testClearBroadcast()
{
Intent intent = Broadcast.createConversationIntent(Broadcast.CONVERSATION_CLEAR, serverId, testTarget);
receiver.onReceive(getContext(), intent);

assertFalse(onConversationMessageCalled);
assertFalse(onNewConversationCalled);
assertFalse(onRemoveConversationCalled);
assertTrue(onClearConversationCalled);
}

@Override
Expand Down Expand Up @@ -110,4 +126,12 @@ public void onTopicChanged(String topic)
{
// XXX: Implement me!
}

@Override
public void onClearConversation(String target)
{
assertEquals(testTarget, target);

onClearConversationCalled = true;
}
}

0 comments on commit f9b8f66

Please sign in to comment.