WXDiv extends WXVContainer { @Override protected void initView() { if(mContext!=null) { mHost = new WXFrameLayout(mContext); } } WXDiv(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override WXFrameLayout getView();  }
@Test public void testAddChild(){ WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); WXDomObject testDom = Mockito.mock(WXDomObject.class); Mockito.when(testDom.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom.clone()).thenReturn(testDom); testDom.ref = "2"; WXText child1 = new WXText(instance, testDom, mWXDiv, false); child1.initView(); mWXDiv.addChild(child1, 0); assertEquals(1, mWXDiv.childCount()); WXDomObject testDom2 = Mockito.mock(WXDomObject.class); Mockito.when(testDom2.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom2.clone()).thenReturn(testDom2); testDom2.ref = "3"; child2 = new WXText(instance, testDom2, mWXDiv, false); child2.initView(); mWXDiv.addChild(child2, -1); assertEquals(2, mWXDiv.childCount()); assertEquals(child2, mWXDiv.getChild(1)); WXDomObject testDom3 = Mockito.mock(WXDomObject.class); Mockito.when(testDom3.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom3.clone()).thenReturn(testDom3); testDom3.ref = "4"; WXText child3 = new WXText(instance, testDom3, mWXDiv, false); child3.initView(); mWXDiv.addChild(child3, 1); assertEquals(3, mWXDiv.childCount()); assertEquals(child3, mWXDiv.getChild(1)); }