本文整理汇总了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());
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例9: idleMainLooper
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
public static void idleMainLooper(long interval) {
ShadowLooper.idleMainLooper(interval);
}
示例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.");
}