use of com.taobao.weex.dom.WXDomObject in project weex-example by KalicyZhou.
the class WXDivTest method testAddChild.
@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);
TestDomObject.setRef(testDom, "2");
WXText child1 = new WXText(instance, testDom, mWXDiv);
child1.initView();
mWXDiv.addChild(child1, 0);
assertEquals(1, mWXDiv.childCount());
WXDomObject testDom2 = Mockito.spy(new WXDomObject());
Mockito.when(testDom2.getPadding()).thenReturn(new Spacing());
Mockito.when(testDom2.clone()).thenReturn(testDom2);
TestDomObject.setRef(testDom2, "3");
child2 = new WXText(instance, testDom2, mWXDiv);
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);
TestDomObject.setRef(testDom3, "4");
WXText child3 = new WXText(instance, testDom3, mWXDiv);
child3.initView();
mWXDiv.addChild(child3, 1);
assertEquals(3, mWXDiv.childCount());
assertEquals(child3, mWXDiv.getChild(1));
}
Aggregations