Example #1
0
 @Test
 public void clickItemContainingText_shouldPerformItemClickOnList() throws Exception {
   ShadowListView shadowListView = prepareListWithThreeItems();
   listView.setOnItemClickListener(
       new AdapterView.OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           transcript.add("clicked on item " + position);
         }
       });
   shadowListView.clickFirstItemContainingText("Item 1");
   transcript.assertEventsSoFar("clicked on item 1");
 }
Example #2
0
 @Test(expected = IllegalArgumentException.class)
 public void clickItemContainingText_shouldThrowExceptionIfNotFound() throws Exception {
   ShadowListView shadowListView = prepareListWithThreeItems();
   shadowListView.clickFirstItemContainingText("Non-existant item");
 }
Example #3
0
 @Test
 public void findItemContainingText_shouldReturnNullIfNotFound() throws Exception {
   ShadowListView shadowListView = prepareListWithThreeItems();
   assertThat(shadowListView.findItemContainingText("Non-existant item"), nullValue());
 }
Example #4
0
 @Test
 public void findItemContainingText_shouldFindChildByString() throws Exception {
   ShadowListView shadowListView = prepareListWithThreeItems();
   View item1 = shadowListView.findItemContainingText("Item 1");
   assertThat(item1, sameInstance(listView.getChildAt(1)));
 }