Java 类android.support.test.espresso.idling.CountingIdlingResource 实例源码

项目:Clases-2017c1    文件:SelectPictureActivityTest.java   
@Before
public void setUp() throws Exception {
    instrumentation = InstrumentationRegistry.getInstrumentation();
    activity = activityTestRule.launchActivity(new Intent());
    countingResource = new CountingIdlingResource("MyRequest");
    UrlRequest.setFactory(new UrlRequest.RequestFactory() {
        @NonNull
        @Override
        public UrlRequest makeRequest(URL url, UrlRequest.Listener listener) {
            return new UrlRequest(url, listener) {
                @Override
                public void run() {
                    countingResource.increment();
                    super.run();
                    countingResource.decrement();
                }
            };
        }
    });
    Espresso.registerIdlingResources(countingResource);
}
项目:lacomida    文件:AbstractEspressoTestCase.java   
private static void setupRxScheduler() {
    CountingIdlingResource idlingResource = new CountingIdlingResource("rxJava");
    IdlingRegistry.getInstance().register(idlingResource);

    RxJavaTestScheduler.init(s -> Schedulers.from(runnable -> {
        idlingResource.increment();
        new Thread(() -> {
            runnable.run();
            idlingResource.decrement();
        }).start();
    }));
}
项目:RxJavaEspressoSample    文件:ActivityCountingIdlingResourceTest.java   
@Before
public void setUp() throws Exception {
    // for using UiDevice.wait()
    setUpUiAutomator();

    // RxJava Synchronization in Espresso
    rxIdlingResource = new CountingIdlingResource("RxJava2", /* debug */ true);
    decorateScheduledActionWithIdlingResource(rxIdlingResource);
    Espresso.registerIdlingResources(rxIdlingResource);

    // launch Activity Under Test
    activityTestRule.launchActivity(null);
}
项目:RxJavaEspressoSample    文件:ActivityCountingIdlingResourceTest.java   
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
    RxJavaPlugins.setScheduleHandler(oldAction -> () -> {
        try {
            countingIdlingResource.increment();
            oldAction.run();
        } finally {
            countingIdlingResource.decrement();
        }
    });
}
项目:RxJavaEspressoSample    文件:ActivityCountingIdlingResourceTest.java   
@Before
public void setUp() throws Exception {
    // for using UiDevice.wait()
    setUpUiAutomator();

    // RxJava Synchronization in Espresso
    rxIdlingResource = new CountingIdlingResource("RxJava1", /* debug */ true);
    decorateScheduledActionWithIdlingResource(rxIdlingResource);
    Espresso.registerIdlingResources(rxIdlingResource);

    // launch Activity Under Test
    activityTestRule.launchActivity(null);
}
项目:RxJavaEspressoSample    文件:ActivityCountingIdlingResourceTest.java   
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
    RxJavaHooks.setOnScheduleAction(oldAction -> () -> {
        try {
            countingIdlingResource.increment();
            oldAction.call();
        } finally {
            countingIdlingResource.decrement();
        }
    });
}
项目:RxEspresso    文件:RxEspresso.java   
private RxEspresso() {

        boolean debug = false;
        if (LOG_LEVEL == LogLevel.DEBUG) {
            debug = true;
        }
        countingIdlingResource = new CountingIdlingResource(TAG, debug);
        Espresso.registerIdlingResources(countingIdlingResource);
    }
项目:android-mobile-engage-sdk    文件:MobileEngageIdlingResource.java   
public MobileEngageIdlingResource(String resourceName) {
    this.delegateIdlingResource = new CountingIdlingResource(resourceName, true);
}
项目:rx-twitter-stream-android    文件:StreamActivityTest.java   
@Before
public void setUp() throws Exception {
    presenterIdlingResource = new CountingIdlingResource("FooServerCalls");
    Espresso.registerIdlingResources(presenterIdlingResource);
}