use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class StatementTest method setUp.
@Before
public void setUp() throws Exception {
WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
WXDomObject divDom = new WXDomObject();
WXDomObject spy = Mockito.spy(divDom);
Mockito.when(spy.getPadding()).thenReturn(new Spacing());
Mockito.when(spy.getEvents()).thenReturn(new WXEvent());
Mockito.when(spy.clone()).thenReturn(divDom);
TestDomObject.setRef(divDom, "1");
}
use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class WXSDKInstanceTest method setupRoot.
public static void setupRoot(WXSDKInstance instance) {
WXDomObject domObject = new WXDomObject();
WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null);
WXComponent root = WXDivTest.create(comp);
comp.addChild(root);
comp.createView();
instance.onCreateFinish();
ShadowLooper.idleMainLooper();
}
use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class WXTransitionTest method testFrom.
@Test
public void testFrom() {
WXViewUtils.setScreenWidth(750);
WXDomObject domObject = new WXDomObject();
domObject.setViewPortWidth(750);
JSONObject map = JSON.parseObject("{\n" + " \"style\": {\n" + " \"width\": 600, \n" + " \"marginLeft\": 75, \n" + " \"marginTop\": 35, \n" + " \"marginBottom\": 35, \n" + " \"flexDirection\": \"column\", \n" + " \"justifyContent\": \"center\", \n" + " \"borderWidth\": 2, \n" + " \"borderStyle\": \"solid\", \n" + " \"borderColor\": \"rgb(0,180,255)\", \n" + " \"backgroundColor\": \"rgba(0,180,255,0.2)\", \n" + " \"transitionProperty\": \"height\", \n" + " \"transitionDuration\": 300, \n" + " \"transitionDelay\": 50, \n" + " \"transitionTimingFunction\": \"ease-in-out\"\n" + " }\n" + "}");
domObject.parseFromJson(map);
Assert.assertNotNull("transition success", domObject.getTransition());
WXTransition transition = domObject.getTransition();
Map<String, Object> updates = new HashMap();
updates.put("height", "1000");
Assert.assertTrue(transition.hasTransitionProperty(updates));
transition.startTransition(updates);
}
use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class WXDivTest method testAddChild.
@Test
public void testAddChild() {
WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
Mockito.when(instance.getFlatUIContext()).thenReturn(new FlatGUIContext());
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));
}
use of com.taobao.weex.dom.WXDomObject in project incubator-weex by apache.
the class WXDivTest method setUp.
@Before
public void setUp() throws Exception {
WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
Mockito.when(instance.getFlatUIContext()).thenReturn(new FlatGUIContext());
WXDomObject divDom = new WXDomObject();
WXDomObject spy = Mockito.spy(divDom);
Mockito.when(spy.getPadding()).thenReturn(new Spacing());
Mockito.when(spy.getEvents()).thenReturn(new WXEvent());
Mockito.when(spy.clone()).thenReturn(divDom);
TestDomObject.setRef(divDom, "1");
mWXDiv = new WXDiv(instance, divDom, null);
mWXDiv.initView();
}
Aggregations