WXText extends WXComponent { @Override public WXTextView getView() { return (WXTextView) super.getView(); } WXText(WXSDKInstance instance, WXDomObject node,
                WXVContainer parent, boolean lazy); @Override WXTextView getView(); @Override void updateExtra(Object extra); static final int sDEFAULT_SIZE; }
@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); }
@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.applyLayoutAndEvent(mWXText); mWXText.bindData(mWXText); 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()); }