Search in sources :

Example 31 with WXDomObject

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");
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) WXEvent(com.taobao.weex.dom.WXEvent) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Example 32 with WXDomObject

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();
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXDomObject(com.taobao.weex.dom.WXDomObject) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 33 with WXDomObject

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);
}
Also used : WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) HashMap(java.util.HashMap) WXDomObject(com.taobao.weex.dom.WXDomObject) JSONObject(com.alibaba.fastjson.JSONObject) Test(org.junit.Test)

Example 34 with WXDomObject

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));
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) FlatGUIContext(com.taobao.weex.ui.flat.FlatGUIContext) WXDomObject(com.taobao.weex.dom.WXDomObject) Spacing(com.taobao.weex.dom.flex.Spacing) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest)

Example 35 with WXDomObject

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();
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) FlatGUIContext(com.taobao.weex.ui.flat.FlatGUIContext) WXDomObject(com.taobao.weex.dom.WXDomObject) WXEvent(com.taobao.weex.dom.WXEvent) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Aggregations

WXDomObject (com.taobao.weex.dom.WXDomObject)42 WXSDKInstance (com.taobao.weex.WXSDKInstance)15 WXComponent (com.taobao.weex.ui.component.WXComponent)10 JSONObject (com.alibaba.fastjson.JSONObject)8 WXVContainer (com.taobao.weex.ui.component.WXVContainer)8 Spacing (com.taobao.weex.dom.flex.Spacing)7 WXEvent (com.taobao.weex.dom.WXEvent)6 WXTextDomObject (com.taobao.weex.dom.WXTextDomObject)6 Test (org.junit.Test)6 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)5 Before (org.junit.Before)5 ArrayMap (android.support.v4.util.ArrayMap)4 WXAttr (com.taobao.weex.dom.WXAttr)4 WXDiv (com.taobao.weex.ui.component.WXDiv)4 WXCell (com.taobao.weex.ui.component.list.WXCell)4 HashMap (java.util.HashMap)4 WXStyle (com.taobao.weex.dom.WXStyle)3 FlatGUIContext (com.taobao.weex.ui.flat.FlatGUIContext)3 Map (java.util.Map)3 SpannableString (android.text.SpannableString)2