当前位置: 首页>>代码示例>>Java>>正文


Java ShadowLooper.idleMainLooper方法代码示例

本文整理汇总了Java中org.robolectric.shadows.ShadowLooper.idleMainLooper方法的典型用法代码示例。如果您正苦于以下问题:Java ShadowLooper.idleMainLooper方法的具体用法?Java ShadowLooper.idleMainLooper怎么用?Java ShadowLooper.idleMainLooper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.shadows.ShadowLooper的用法示例。


在下文中一共展示了ShadowLooper.idleMainLooper方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: currentActivity

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void currentActivity() throws Exception {
    /* now select an activity */
    DiaryActivity someAct = new DiaryActivity(1, "Test", Color.BLACK);

    ActivityHelper.helper.insertActivity(someAct);
    assertNotNull(someAct);

    ActivityHelper.helper.setCurrentActivity(someAct);
    assertEquals(ActivityHelper.helper.getCurrentActivity(), someAct);

    MainActivity activity = Robolectric.setupActivity(MainActivity.class);

    View card = activity.findViewById(R.id.card);
    TextView nameView = (TextView) card.findViewById(R.id.activity_name);
    assertNotNull("Current activity Text available", nameView);

    assertEquals(nameView.getText(), "Test");

    FloatingActionButton fabNoteEdit = (FloatingActionButton) activity.findViewById(R.id.fab_edit_note);
    FloatingActionButton fabAttachPicture = (FloatingActionButton) activity.findViewById(R.id.fab_attach_picture);

    assertNotNull("we have two FABs", fabNoteEdit);
    assertNotNull("we have two FABs", fabAttachPicture);

    fabNoteEdit.performClick();

    DialogFragment dialogFragment = (DialogFragment) activity.getSupportFragmentManager()
            .findFragmentByTag("NoteEditDialogFragment");
    assertNotNull(dialogFragment);

    ShadowLooper.idleMainLooper(100, TimeUnit.MILLISECONDS);
    assertNull(ShadowToast.getTextOfLatestToast());

    fabAttachPicture.performClick();

    ShadowLooper.idleMainLooper(100, TimeUnit.MILLISECONDS);
    assertNull(ShadowToast.getTextOfLatestToast());
}
 
开发者ID:ramack,项目名称:ActivityDiary,代码行数:40,代码来源:MainActivityTest.java

示例2: setupRoot

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
public static void setupRoot(WXSDKInstance instance){
  WXDomObject domObject = new WXDomObject();
  WXDomObject.prepareGod(domObject);
  WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null);

  WXComponent root = WXDivTest.create(comp);
  comp.addChild(root);
  comp.createView(null, -1);

  instance.onViewCreated(comp);
  ShadowLooper.idleMainLooper();
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:13,代码来源:WXSDKInstanceTest.java

示例3: setupRoot

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
public static void setupRoot(WXSDKInstance instance){

    WXDomObject domObject = new WXDomObject();
    WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null);

    WXComponent root = WXDivTest.create(comp);
    comp.addChild(root);
    comp.createView();

    instance.onCreateFinish();
    ShadowLooper.idleMainLooper();
  }
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:13,代码来源:WXSDKInstanceTest.java

示例4: setUp

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Before
public void setUp() {
    mNumCallsToOnUiChangedAndIsNowStable = 0;
    mNumRunnableExecutions = 0;
    mActionProcessor = new ActionProcessor(this);
    ShadowLooper.idleMainLooper(LONG_ENOUGH_TIME_MILLIS);
}
 
开发者ID:google,项目名称:talkback,代码行数:8,代码来源:ActionProcessorTest.java

示例5: testActionAfterUIChange_notProcessedAfterShortDelay

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void testActionAfterUIChange_notProcessedAfterShortDelay() {
    mActionProcessor.onPossibleChangeToUi();
    mActionProcessor.process(runnable);
    ShadowLooper.idleMainLooper(TOO_SOON_TIME_MILLIS);
    assertEquals(0, mNumRunnableExecutions);
    assertEquals(0, mNumCallsToOnUiChangedAndIsNowStable);

}
 
开发者ID:google,项目名称:talkback,代码行数:10,代码来源:ActionProcessorTest.java

示例6: testActionAfterUIChange_processedAfterDelay

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void testActionAfterUIChange_processedAfterDelay() {
    mActionProcessor.onPossibleChangeToUi();
    mActionProcessor.process(runnable);
    ShadowLooper.idleMainLooper(LONG_ENOUGH_TIME_MILLIS);
    assertEquals(1, mNumRunnableExecutions);
    assertEquals(1, mNumCallsToOnUiChangedAndIsNowStable);
}
 
开发者ID:google,项目名称:talkback,代码行数:9,代码来源:ActionProcessorTest.java

示例7: testActionAfterUIChange_processedAfterShortThenLongDelay

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void testActionAfterUIChange_processedAfterShortThenLongDelay() {
    mActionProcessor.onPossibleChangeToUi();
    mActionProcessor.process(runnable);
    ShadowLooper.idleMainLooper(TOO_SOON_TIME_MILLIS);
    ShadowLooper.idleMainLooper(LONG_ENOUGH_TIME_MILLIS - TOO_SOON_TIME_MILLIS);
    assertEquals(1, mNumRunnableExecutions);
    assertEquals(1, mNumCallsToOnUiChangedAndIsNowStable);
}
 
开发者ID:google,项目名称:talkback,代码行数:10,代码来源:ActionProcessorTest.java

示例8: idleMainLooper

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
private static void idleMainLooper(long amount, TimeUnit unit) {
    // TODO delete this when https://github.com/robolectric/robolectric/pull/2592 is released.
    ShadowLooper.idleMainLooper(unit.toMillis(amount));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:HandlerSchedulerTest.java

示例9: idleMainLooper

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
public static void idleMainLooper(long interval) {
  ShadowLooper.idleMainLooper(interval);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java

示例10: currentNullActivity

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void currentNullActivity() throws Exception {
    /* show absense of #60 */
    MainActivity activity = Robolectric.setupActivity(MainActivity.class);

    View card = activity.findViewById(R.id.card);
    assertNotNull("Current activity card available", card);

    TextView nameView = (TextView) card.findViewById(R.id.activity_name);
    assertNotNull("Current activity Text available", nameView);

    /* initial creation shall not have any activity selected */
    assertEquals(nameView.getText(), "<No Activity>");

    assertNull(ActivityHelper.helper.getCurrentActivity());

    FloatingActionButton fabNoteEdit = (FloatingActionButton) activity.findViewById(R.id.fab_edit_note);
    FloatingActionButton fabAttachPicture = (FloatingActionButton) activity.findViewById(R.id.fab_attach_picture);

    assertNotNull("we have two FABs", fabNoteEdit);
    assertNotNull("we have two FABs", fabAttachPicture);

    fabNoteEdit.performClick();

    ShadowLooper.idleMainLooper(100, TimeUnit.MILLISECONDS);
    assertEquals(ShadowToast.getTextOfLatestToast().toString(), "To perform this action it is necessary to select an activity first.");

    fabAttachPicture.performClick();

    ShadowLooper.idleMainLooper(100, TimeUnit.MILLISECONDS);
    assertEquals(ShadowToast.getTextOfLatestToast().toString(), "To perform this action it is necessary to select an activity first.");

}
 
开发者ID:ramack,项目名称:ActivityDiary,代码行数:34,代码来源:MainActivityTest.java


注:本文中的org.robolectric.shadows.ShadowLooper.idleMainLooper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。