Пример #1
0
 @Test
 public void testSetPadding() {
   testCreateView();
   mWXText.setPadding(mDomObject.getPadding(), mDomObject.getBorder());
   assertEquals(0, mWXText.getHostView().getPaddingLeft());
   assertEquals(0, mWXText.getHostView().getPaddingTop());
   assertEquals(0, mWXText.getHostView().getPaddingRight());
   assertEquals(0, mWXText.getHostView().getPaddingBottom());
 }
Пример #2
0
  @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);
    mParentDomObj.ref = "_root";

    mDomObject = Mockito.spy(new WXTextDomObject());
    mDomObject.ref = "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, false);
    mParent.createView(null, -1);
    mWXText = new WXText(instance, mDomObject, mParent, false);
    mWXText.bindHolder(new SimpleComponentHolder(WXText.class));
    assertNotNull(instance.getContext());
  }