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


Java ShadowLooper.runUiThreadTasksIncludingDelayedTasks方法代码示例

本文整理汇总了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);
}
 
开发者ID:artem-zinnatullin,项目名称:RxUi,代码行数:24,代码来源:RxUiTest.java

示例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);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:22,代码来源:BaseListActivityTest.java

示例3: waitForIdleSync

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Override
public void waitForIdleSync() {
  ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
}
 
开发者ID:maskarade,项目名称:Robolectric-Instrumentation,代码行数:5,代码来源:InstrumentationRegistry.java

示例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 );
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:12,代码来源:WXDomStatementTest.java

示例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 );
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:13,代码来源:WXDomStatementTest.java

示例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();
}
 
开发者ID:pine,项目名称:RxBindroid,代码行数:12,代码来源:AppObservableTest.java

示例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();
}
 
开发者ID:pine,项目名称:RxBindroid,代码行数:12,代码来源:AppObservableTest.java

示例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();
}
 
开发者ID:pine,项目名称:RxBindroid,代码行数:12,代码来源:AppObservableTest.java

示例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;
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:29,代码来源:PhoneActivityTest.java

示例10: runOnMainSync

import org.robolectric.shadows.ShadowLooper; //导入方法依赖的package包/类
@Override
public void runOnMainSync(@NonNull Runnable task) {
    new Handler(Looper.getMainLooper()).post(task);
    ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
}
 
开发者ID:maskarade,项目名称:Robolectric-Instrumentation,代码行数:6,代码来源:InstrumentationRegistry.java

示例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"));

    }
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:50,代码来源:CbtTest.java

示例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());
    }
}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:27,代码来源:PhotometerTest.java

示例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());
    }
}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:32,代码来源:MainTest.java

示例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());
    }
}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:28,代码来源:StripsTest.java

示例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());
    }
}
 
开发者ID:akvo,项目名称:akvo-caddisfly,代码行数:28,代码来源:SensorsTest.java


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