コード例 #1
0
  /** Given the history is empty, when I remove tags, then nothing happens. */
  @Test
  public void testRemoveTagsFromEmptyHistory() {
    tagHistory = new TagHistoryView(context);
    tagHistory.getAdapter().registerAdapterDataObserver(observer);

    for (int i = 0; i < 3; i++) {
      tagHistory.pop();
    }

    assertEquals("No tags are removed from an empty history", 0, observer.itemRemovedCount);
  }
コード例 #2
0
  /**
   * When I add several tags to the history, then I am notified for each one and the history has the
   * correct views.
   */
  @Test
  public void testAddTags() {
    tagHistory = new TagHistoryView(context);
    tagHistory.getAdapter().registerAdapterDataObserver(observer);

    for (int i = 0; i < 5; i++) {
      Tag tag = new Tag(String.valueOf(i), String.valueOf(i * 2));
      tagHistory.push(tag);
    }

    assertEquals("The correct number of tags are inserted", 5, observer.itemInsertedCount);
    assertEquals(
        "The history has the correct number of tags", 5, tagHistory.getAdapter().getItemCount());
  }
コード例 #3
0
 @After
 public void unregisterObservers() {
   if (tagHistory != null && observer != null) {
     tagHistory.getAdapter().unregisterAdapterDataObserver(observer);
   }
 }