コード例 #1
0
ファイル: WXTextTest.java プロジェクト: Rowandjj/weex
  @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());
  }
コード例 #2
0
ファイル: WXImageTest.java プロジェクト: Rowandjj/weex
  @Before
  public void setUp() throws Exception {

    mInstance = WXSDKInstanceTest.createInstance();
    mDomObject = PowerMockito.mock(WXDomObject.class);
    PowerMockito.when(mDomObject.clone()).thenReturn(mDomObject);
    mWXDiv = PowerMockito.mock(WXDiv.class);
    mWXImage = new WXImage(mInstance, mDomObject, mWXDiv, true);
  }