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());
}
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();
}
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);
}
}
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());
}
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;
}
Aggregations