Code example for ViewGroup

Methods: getChildAtgetChildCountremoveView

0
        assertThat(child1.getLayoutParams()).isInstanceOf(ViewGroup.LayoutParams.class);
    } 
 
    @Test 
    public void removeView_removesView() throws Exception { 
        assertThat(root.getChildCount()).isEqualTo(3);
        root.removeView(child1);
        assertThat(root.getChildCount()).isEqualTo(2);
        assertThat(root.getChildAt(0)).isSameAs(child2);
        assertThat(root.getChildAt(1)).isSameAs((View) child3);
        assertThat(child1.getParent()).isNull();
    } 
 
    @Test 
    public void removeView_resetsParentOnlyIfViewIsInViewGroup() throws Exception { 
        assertThat(root.getChildCount()).isEqualTo(3);
        assertNotSame(child3a.getParent(), root);
        root.removeView(child3a);
        assertThat(root.getChildCount()).isEqualTo(3);
        assertThat(child3a.getParent()).isSameAs((ViewParent) child3);
    }