Java Code Examples for android.support.test.espresso.idling.CountingIdlingResource

The following are top voted examples for showing how to use android.support.test.espresso.idling.CountingIdlingResource. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Clases-2017c1   File: SelectPictureActivityTest.java   View source code 6 votes vote down vote up
@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);
}
 
Example 2
Project: lacomida   File: AbstractEspressoTestCase.java   View source code 5 votes vote down vote up
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();
	}));
}
 
Example 3
Project: RxJavaEspressoSample   File: ActivityCountingIdlingResourceTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 4
Project: RxJavaEspressoSample   File: ActivityCountingIdlingResourceTest.java   View source code 5 votes vote down vote up
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
    RxJavaPlugins.setScheduleHandler(oldAction -> () -> {
        try {
            countingIdlingResource.increment();
            oldAction.run();
        } finally {
            countingIdlingResource.decrement();
        }
    });
}
 
Example 5
Project: RxJavaEspressoSample   File: ActivityCountingIdlingResourceTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 6
Project: RxJavaEspressoSample   File: ActivityCountingIdlingResourceTest.java   View source code 5 votes vote down vote up
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) {
    RxJavaHooks.setOnScheduleAction(oldAction -> () -> {
        try {
            countingIdlingResource.increment();
            oldAction.call();
        } finally {
            countingIdlingResource.decrement();
        }
    });
}
 
Example 7
Project: RxEspresso   File: RxEspresso.java   View source code 5 votes vote down vote up
private RxEspresso() {

        boolean debug = false;
        if (LOG_LEVEL == LogLevel.DEBUG) {
            debug = true;
        }
        countingIdlingResource = new CountingIdlingResource(TAG, debug);
        Espresso.registerIdlingResources(countingIdlingResource);
    }
 
Example 8
Project: android-mobile-engage-sdk   File: MobileEngageIdlingResource.java   View source code 4 votes vote down vote up
public MobileEngageIdlingResource(String resourceName) {
    this.delegateIdlingResource = new CountingIdlingResource(resourceName, true);
}
 
Example 9
Project: rx-twitter-stream-android   File: StreamActivityTest.java   View source code 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    presenterIdlingResource = new CountingIdlingResource("FooServerCalls");
    Espresso.registerIdlingResources(presenterIdlingResource);
}