本文整理汇总了Java中org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks方法的典型用法代码示例。如果您正苦于以下问题:Java ShadowLooper.runUiThreadTasksIncludingDelayedTasks方法的具体用法?Java ShadowLooper.runUiThreadTasksIncludingDelayedTasks怎么用?Java ShadowLooper.runUiThreadTasksIncludingDelayedTasks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robolectric.shadows.ShadowLooper
的用法示例。
在下文中一共展示了ShadowLooper.runUiThreadTasksIncludingDelayedTasks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uiShouldPreventCallsToActionIfUnsubscribedBeforeExecution
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void uiShouldPreventCallsToActionIfUnsubscribedBeforeExecution() throws Exception {
// WHEN have UI action
Consumer<String> uiAction = mock(Consumer.class);
// AND produce binder func
Function<Observable<String>, Disposable> binderFunc = RxUi.ui(uiAction);
// AND pause Main Thread
ShadowLooper.pauseMainLooper();
// AND bind Observable via binder func
Disposable disposable = binderFunc.apply(Observable.just("a", "b", "c"));
// AND dispose Disposable
disposable.dispose();
// AND resume Main Thread
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
// THEN no calls to uiAction are expected
verifyZeroInteractions(uiAction);
}
示例2: testLastUpdated
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void testLastUpdated() {
String expected = activity.getString(R.string.last_updated,
DateUtils.getRelativeTimeSpanString(System.currentTimeMillis(),
System.currentTimeMillis(),
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_ABBREV_ALL));
activity.onRefreshed();
assertThat(activity.getSupportActionBar()).hasSubtitle(expected);
activity.getSupportActionBar().setSubtitle(null);
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
assertThat(activity.getSupportActionBar()).hasSubtitle(expected);
activity.getSupportActionBar().setSubtitle(null);
controller.pause().resume();
assertThat(activity.getSupportActionBar()).hasSubtitle(expected);
Bundle savedState = new Bundle();
activity.onSaveInstanceState(savedState);
controller = Robolectric.buildActivity(TestListActivity.class);
activity = controller.create(savedState).postCreate(null).start().resume().visible().get();
assertThat(activity.getSupportActionBar()).hasSubtitle(expected);
}
示例3: waitForIdleSync
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Override
public void waitForIdleSync() {
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
}
示例4: setUp
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
ShadowLooper looper = WXBridgeManagerTest.getLooper();
looper.idle();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
instance = WXSDKInstanceTest.createInstance();
rednerManager = new WXRenderManager();
rednerManager.registerInstance(instance);//
stmt = new WXDomStatement(instance.getInstanceId(),rednerManager );
}
示例5: setUp
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build());
ShadowLooper looper = WXBridgeManagerTest.getLooper();
looper.idle();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
instance = WXSDKInstanceTest.createInstance();
rednerManager = new WXRenderManager();
rednerManager.registerInstance(instance);//
WXSDKManagerTest.setRenderManager(rednerManager);
stmt = new DOMActionContextImpl(instance.getInstanceId(),rednerManager );
}
示例6: bindFragmentToSourceFromDifferentThread
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void bindFragmentToSourceFromDifferentThread() throws InterruptedException {
CountDownLatch done = new CountDownLatch(1);
AppObservable.bindFragment(fragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver<String>(observer));
done.await();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
verify(observer).onNext(TestUtil.STRING_EXPECTATION);
verify(observer).onCompleted();
}
示例7: bindSupportFragmentToSourceFromDifferentThread
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void bindSupportFragmentToSourceFromDifferentThread() throws InterruptedException {
CountDownLatch done = new CountDownLatch(1);
AppObservable.bindSupportFragment(supportFragment, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver<String>(observer));
done.await();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
verify(observer).onNext(TestUtil.STRING_EXPECTATION);
verify(observer).onCompleted();
}
示例8: bindActivityToSourceFromDifferentThread
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void bindActivityToSourceFromDifferentThread() throws InterruptedException {
CountDownLatch done = new CountDownLatch(1);
AppObservable.bindActivity(activity, TestUtil.atBackgroundThread(done)).subscribe(new TestObserver<String>(observer));
done.await();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
verify(observer).onNext(TestUtil.STRING_EXPECTATION);
verify(observer).onCompleted();
}
示例9: testSendConfirmationCode
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
private PhoneAuthProvider.OnVerificationStateChangedCallbacks testSendConfirmationCode() {
mActivity.verifyPhoneNumber(PHONE, false);
verify(AuthHelperShadow.getPhoneAuthProvider()).verifyPhoneNumber(
eq(PHONE),
eq(AUTO_RETRIEVAL_TIMEOUT_MILLIS),
eq(TimeUnit.MILLISECONDS),
eq(mActivity),
callbacksArgumentCaptor.capture(),
(PhoneAuthProvider.ForceResendingToken) isNull());
PhoneAuthProvider.OnVerificationStateChangedCallbacks onVerificationStateChangedCallbacks
= callbacksArgumentCaptor.getValue();
onVerificationStateChangedCallbacks.onCodeSent(verificationId, forceResendingToken);
//Force postDelayed runnables to completed on looper
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
SubmitConfirmationCodeFragment fragment = (SubmitConfirmationCodeFragment) mActivity
.getSupportFragmentManager().findFragmentByTag(SubmitConfirmationCodeFragment.TAG);
assertNotNull(fragment);
SpacedEditText mConfirmationCodeEditText = mActivity
.findViewById(R.id.confirmation_code);
assertTrue(mConfirmationCodeEditText.isFocused());
return onVerificationStateChangedCallbacks;
}
示例10: runOnMainSync
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Override
public void runOnMainSync(@NonNull Runnable task) {
new Handler(Looper.getMainLooper()).post(task);
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
}
示例11: clickingNext
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void clickingNext() {
String[] permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
TestConfigRepository testConfigRepository = new TestConfigRepository();
TestInfo testInfo = testConfigRepository.getTestInfo(Constants.CBT_ID);
Intent intent = new Intent();
Bundle data = new Bundle();
data.putParcelable(ConstantKey.TEST_INFO, testInfo);
intent.putExtras(data);
ActivityController controller = Robolectric.buildActivity(TestActivity.class, intent).create().start();
Activity activity = (Activity) controller.get();
Button button = activity.findViewById(R.id.button_prepare);
button.performClick();
Intent nextIntent = shadowOf(activity).getNextStartedActivity();
assertNull(nextIntent);
// assertThat(ShadowToast.getTextOfLatestToast(), equalTo(null));
ShadowApplication application = shadowOf(activity.getApplication());
application.grantPermissions(permissions);
controller.resume();
button.performClick();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
Intent nextIntent2 = shadowOf(activity).getNextStartedActivity();
if (nextIntent2.getComponent() != null) {
assertEquals(CbtActivity.class.getCanonicalName(),
nextIntent2.getComponent().getClassName());
}
// CountDownLatch latch = new CountDownLatch(1);
// try {
// latch.await(1, TimeUnit.SECONDS);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// assertThat(ShadowToast.getTextOfLatestToast(), equalTo("Take a photo of the compartment bag"));
}
示例12: clickTest
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void clickTest() {
Intent intent = new Intent();
intent.putExtra(ConstantKey.TYPE, TestType.BLUETOOTH);
ActivityController controller = Robolectric.buildActivity(TestListActivity.class, intent).create();
controller.start().visible();
Activity activity = (Activity) controller.get();
RecyclerView recyclerView = activity.findViewById(R.id.list_types);
assertSame(51, recyclerView.getAdapter().getItemCount());
recyclerView.getChildAt(1).performClick();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
Intent nextIntent = shadowOf(activity).getNextStartedActivity();
if (nextIntent != null && nextIntent.getComponent() != null) {
assertEquals(TestActivity.class.getCanonicalName(),
nextIntent.getComponent().getClassName());
}
}
示例13: clickingCalibrate
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void clickingCalibrate() throws Exception {
String[] permissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
ActivityController controller = Robolectric.buildActivity(MainActivity.class).create().start();
Activity activity = (Activity) controller.get();
Button button = activity.findViewById(R.id.buttonCalibrate);
button.performClick();
Intent nextIntent = shadowOf(activity).getNextStartedActivity();
assertNull(nextIntent);
ShadowApplication application = shadowOf(activity.getApplication());
application.grantPermissions(permissions);
controller.resume();
button.performClick();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
button.performClick();
Intent intent = shadowOf(activity).getNextStartedActivity();
if (intent.getComponent() != null) {
assertEquals(TestListActivity.class.getCanonicalName(),
intent.getComponent().getClassName());
}
}
示例14: clickTest
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void clickTest() {
Intent intent = new Intent();
intent.putExtra(ConstantKey.TYPE, TestType.STRIP_TEST);
ActivityController controller = Robolectric.buildActivity(TestListActivity.class, intent).create();
controller.start().visible();
Activity activity = (Activity) controller.get();
RecyclerView recyclerView = activity.findViewById(R.id.list_types);
assertSame(20, recyclerView.getChildCount());
recyclerView.getChildAt(1).performClick();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
Intent nextIntent = shadowOf(activity).getNextStartedActivity();
if (nextIntent.getComponent() != null) {
assertEquals(TestActivity.class.getCanonicalName(),
nextIntent.getComponent().getClassName());
}
}
示例15: clickSensorItem
import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Test
public void clickSensorItem() {
Intent intent = new Intent();
intent.putExtra(ConstantKey.TYPE, TestType.SENSOR);
ActivityController controller = Robolectric.buildActivity(TestListActivity.class, intent).create();
controller.start().visible();
Activity activity = (Activity) controller.get();
RecyclerView recyclerView = activity.findViewById(R.id.list_types);
recyclerView.getChildAt(1).performClick();
ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
Intent nextIntent1 = shadowOf(activity).getNextStartedActivity();
assertNotNull(nextIntent1);
if (nextIntent1.getComponent() != null) {
assertEquals(TestActivity.class.getCanonicalName(),
nextIntent1.getComponent().getClassName());
}
}