Search in sources :

Example 1 with Spacing

use of com.taobao.weex.dom.flex.Spacing in project weex-example by KalicyZhou.

the class WXTextTest method setUp.

@Before
public void setUp() throws Exception {
    WXEnvironment.sApplication = RuntimeEnvironment.application;
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
    mParentDomObj = Mockito.spy(new WXDomObject());
    Mockito.when(mParentDomObj.getPadding()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.getBorder()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.clone()).thenReturn(mParentDomObj);
    TestDomObject.setRef(mParentDomObj, WXDomObject.ROOT);
    mDomObject = Mockito.spy(new WXTextDomObject());
    TestDomObject.setRef(mDomObject, "1");
    mDomObject.addEvent(Constants.Event.CLICK);
    Mockito.when(mDomObject.clone()).thenReturn(mDomObject);
    Mockito.when(mDomObject.getPadding()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getBorder()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getMargin()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getLayoutWidth()).thenReturn(100f);
    Mockito.when(mDomObject.getLayoutHeight()).thenReturn(100f);
    mParent = new WXDiv(instance, mParentDomObj, null);
    mParent.createView();
    mWXText = new WXText(instance, mDomObject, mParent);
    mWXText.bindHolder(new SimpleComponentHolder(WXText.class));
    assertNotNull(instance.getContext());
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) WXDomObject(com.taobao.weex.dom.WXDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) SimpleComponentHolder(com.taobao.weex.ui.SimpleComponentHolder) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Example 2 with Spacing

use of com.taobao.weex.dom.flex.Spacing in project weex-example by KalicyZhou.

the class WXDivTest 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");
    mWXDiv = new WXDiv(instance, divDom, null);
    mWXDiv.initView();
}
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 3 with Spacing

use of com.taobao.weex.dom.flex.Spacing in project incubator-weex by apache.

the class UpdateStyleAction method executeRender.

@Override
public void executeRender(RenderActionContext context) {
    WXComponent component = context.getComponent(mRef);
    if (component == null) {
        return;
    }
    component.updateProperties(mData);
    if (mData.containsKey(Constants.Name.PADDING) || mData.containsKey(Constants.Name.PADDING_TOP) || mData.containsKey(Constants.Name.PADDING_LEFT) || mData.containsKey(Constants.Name.PADDING_RIGHT) || mData.containsKey(Constants.Name.PADDING_BOTTOM) || mData.containsKey(Constants.Name.BORDER_WIDTH)) {
        Spacing padding = mPadding;
        Spacing border = mBorder;
        component.setPadding(padding, border);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) Spacing(com.taobao.weex.dom.flex.Spacing)

Example 4 with Spacing

use of com.taobao.weex.dom.flex.Spacing in project incubator-weex by apache.

the class WXTextTest method setUp.

@Before
public void setUp() throws Exception {
    WXEnvironment.sApplication = RuntimeEnvironment.application;
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);
    Mockito.when(instance.getFlatUIContext()).thenReturn(new FlatGUIContext());
    mParentDomObj = Mockito.spy(new WXDomObject());
    Mockito.when(mParentDomObj.getPadding()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.getBorder()).thenReturn(new Spacing());
    Mockito.when(mParentDomObj.clone()).thenReturn(mParentDomObj);
    TestDomObject.setRef(mParentDomObj, WXDomObject.ROOT);
    mDomObject = Mockito.spy(new WXTextDomObject());
    TestDomObject.setRef(mDomObject, "1");
    mDomObject.addEvent(Constants.Event.CLICK);
    Mockito.when(mDomObject.clone()).thenReturn(mDomObject);
    Mockito.when(mDomObject.getPadding()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getBorder()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getMargin()).thenReturn(new Spacing());
    Mockito.when(mDomObject.getLayoutWidth()).thenReturn(100f);
    Mockito.when(mDomObject.getLayoutHeight()).thenReturn(100f);
    mParent = new WXDiv(instance, mParentDomObj, null);
    mParent.createView();
    mWXText = new WXText(instance, mDomObject, mParent);
    mWXText.bindHolder(new SimpleComponentHolder(WXText.class));
    assertNotNull(instance.getContext());
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) FlatGUIContext(com.taobao.weex.ui.flat.FlatGUIContext) WXDomObject(com.taobao.weex.dom.WXDomObject) WXTextDomObject(com.taobao.weex.dom.WXTextDomObject) SimpleComponentHolder(com.taobao.weex.ui.SimpleComponentHolder) Spacing(com.taobao.weex.dom.flex.Spacing) Before(org.junit.Before)

Example 5 with Spacing

use of com.taobao.weex.dom.flex.Spacing in project incubator-weex by apache.

the class WXMask method get.

private int get(int type, ImmutableDomObject domObject) {
    try {
        Spacing margin = domObject.getMargin();
        WXStyle style = domObject.getStyles();
        switch(type) {
            case LEFT:
                return add(style.getLeft(), margin.get(Spacing.LEFT));
            case RIGHT:
                return add(style.getRight(), margin.get(Spacing.RIGHT));
            case TOP:
                return add(style.getTop(), margin.get(Spacing.TOP));
            case BOTTOM:
                return add(style.getBottom(), margin.get(Spacing.BOTTOM));
        }
    } catch (Throwable t) {
    // ignore
    }
    return 0;
}
Also used : WXStyle(com.taobao.weex.dom.WXStyle) Spacing(com.taobao.weex.dom.flex.Spacing)

Aggregations

Spacing (com.taobao.weex.dom.flex.Spacing)15 WXSDKInstance (com.taobao.weex.WXSDKInstance)7 WXDomObject (com.taobao.weex.dom.WXDomObject)7 Before (org.junit.Before)5 WXEvent (com.taobao.weex.dom.WXEvent)3 FlatGUIContext (com.taobao.weex.ui.flat.FlatGUIContext)3 ViewGroup (android.view.ViewGroup)2 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)2 WXTextDomObject (com.taobao.weex.dom.WXTextDomObject)2 SimpleComponentHolder (com.taobao.weex.ui.SimpleComponentHolder)2 Test (org.junit.Test)2 Point (android.graphics.Point)1 WXStyle (com.taobao.weex.dom.WXStyle)1 WXComponent (com.taobao.weex.ui.component.WXComponent)1