@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); }
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(); })); }
@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); }
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) { RxJavaPlugins.setScheduleHandler(oldAction -> () -> { try { countingIdlingResource.increment(); oldAction.run(); } finally { countingIdlingResource.decrement(); } }); }
@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); }
private void decorateScheduledActionWithIdlingResource(CountingIdlingResource countingIdlingResource) { RxJavaHooks.setOnScheduleAction(oldAction -> () -> { try { countingIdlingResource.increment(); oldAction.call(); } finally { countingIdlingResource.decrement(); } }); }
private RxEspresso() { boolean debug = false; if (LOG_LEVEL == LogLevel.DEBUG) { debug = true; } countingIdlingResource = new CountingIdlingResource(TAG, debug); Espresso.registerIdlingResources(countingIdlingResource); }
public MobileEngageIdlingResource(String resourceName) { this.delegateIdlingResource = new CountingIdlingResource(resourceName, true); }
@Before public void setUp() throws Exception { presenterIdlingResource = new CountingIdlingResource("FooServerCalls"); Espresso.registerIdlingResources(presenterIdlingResource); }