Code example for ViewGroup

Methods: addViewremoveAllViews, findViewWithTag

0
        assertThat(root.getChildAt(2)).isSameAs(child2);
    } 
 
    @Test 
    public void shouldFindViewWithTag() { 
        root.removeAllViews();
        child1.setTag("tag1");
        child2.setTag("tag2");
        child3.setTag("tag3");
        root.addView(child1);
        root.addView(child2);
        root.addView(child3, 1);
        assertThat(root.findViewWithTag("tag1")).isSameAs(child1);
        assertThat(root.findViewWithTag("tag2")).isSameAs((View) child2);
        assertThat((ViewGroup) root.findViewWithTag("tag3")).isSameAs(child3);
    } 
 
    @Test 
    public void shouldNotFindViewWithTagReturnNull() { 
        root.removeAllViews();
        child1.setTag("tag1");