Code example for ViewGroup

Methods: addViewgetChildAtremoveAllViews

0
        assertThat(child2.getParent()).isNull();
    } 
 
    @Test 
    public void testAddViewAt() throws Exception { 
        root.removeAllViews();
        root.addView(child1);
        root.addView(child2);
        root.addView(child3, 1);
        assertThat(root.getChildAt(0)).isSameAs(child1);
        assertThat(root.getChildAt(1)).isSameAs((View) child3);
        assertThat(root.getChildAt(2)).isSameAs(child2);
    } 
 
    @Test 
    public void shouldFindViewWithTag() { 
        root.removeAllViews();
        child1.setTag("tag1");
        child2.setTag("tag2");
        child3.setTag("tag3");
        root.addView(child1);