WXText extends WXComponent { @Override public WXTextView getView() { return (WXTextView) super.getView(); } WXText(WXSDKInstance instance, WXDomObject node,
                WXVContainer parent, String instanceId, boolean lazy); @Override WXTextView getView(); @Override void updateExtra(Object extra); @Override View detachViewAndClearPreInfo(); @WXComponentProp(name = WXDomPropConstant.WX_TEXTALIGN) void setTextAlign(String textAlign); @WXComponentProp(name = WXDomPropConstant.WX_LINES) void setLines(int lines); @WXComponentProp(name = WXDomPropConstant.WX_TEXT_OVERFLOW) void setTextOverFlow(String textOverFlow); static final int sDEFAULT_SIZE; }
@Test public void testSetPadding(){ testCreateView(); mWXText.setPadding(mDomObject.getPadding(), mDomObject.getBorder()); assertEquals(0, mWXText.getView().getPaddingLeft()); assertEquals(0, mWXText.getView().getPaddingTop()); assertEquals(0, mWXText.getView().getPaddingRight()); assertEquals(0, mWXText.getView().getPaddingBottom()); }
@Test public void testBind(){ testCreateView(); mWXText.bind(null); assertNotNull(mWXText.getView().getLayoutParams()); assertEquals(100, mWXText.getView().getLayoutParams().height); assertEquals(100, mWXText.getView().getLayoutParams().width); assertEquals(0, mWXText.getView().getPaddingLeft()); assertEquals(0, mWXText.getView().getPaddingTop()); assertEquals(0, mWXText.getView().getPaddingRight()); assertEquals(0, mWXText.getView().getPaddingBottom()); }
@Test public void testAddEvent(){ testBind(); mWXText.addEvent(WXEventType.CLICK); assertTrue(mWXText.getView().isEnabled()); mWXText.getView().performClick(); }
@Test public void testUpdateProperties(){ testBind(); Map<String, Object> prop = new HashMap<>(); prop.put(WXDomPropConstant.WX_ATTR_DISABLED, "false"); prop.put(WXDomPropConstant.WX_OPACITY, 0.8f); mWXText.updateProperties(prop); assertTrue(mWXText.getView().isEnabled()); assertTrue(mWXText.getView().getAlpha()>=0.799 && mWXText.getView().getAlpha()<=0.811); prop.put(WXDomPropConstant.WX_ATTR_DISABLED, "true"); mWXText.updateProperties(prop); assertFalse(mWXText.getView().isEnabled()); }
@Test public void testCreateView(){ mWXText.createView(mParent, -1); assertNotNull(mWXText.getView()); }
@Test public void testSetLayout(){ testCreateView(); mWXText.setLayout(mDomObject); assertNotNull(mWXText.getView().getLayoutParams()); assertEquals(100, mWXText.getView().getLayoutParams().height); assertEquals(100, mWXText.getView().getLayoutParams().width); }