private static void waitFor(long waitingTime, boolean success) { // Start onView(withId(R.id.toggle_button)) .check(matches(withText(R.string.start))) .perform(click()); // Make sure Espresso does not time out IdlingPolicies.setMasterPolicyTimeout(waitingTime * 2, TimeUnit.MILLISECONDS); IdlingPolicies.setIdlingResourceTimeout(waitingTime * 2, TimeUnit.MILLISECONDS); // Now we wait IdlingResource idlingResource = new ElapsedTimeIdlingResource(waitingTime); IdlingRegistry.getInstance().register(idlingResource); // Stop and verify onView(withId(R.id.toggle_button)) .check(matches(withText(R.string.stop))) .perform(click()); onView(withId(R.id.result)) .check(matches(withText(success ? R.string.success: R.string.failure))); // Clean up IdlingRegistry.getInstance().unregister(idlingResource); }
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(); })); }
@Test public void testFabButtonAndList() { IdlingResource ir = new RecyclerViewScrollingIdlingResource((RecyclerView) activity.findViewById(R.id.list)); IdlingRegistry.getInstance().register(ir); Matcher listMatcher = withId(R.id.list); onView(listMatcher).perform(smoothScrollTo(12)); onView(withId(R.id.fab)).perform(click()); onView(listMatcher).perform(smoothScrollTo(0)); onView(withId(R.id.fab)).perform(click()); IdlingRegistry.getInstance().unregister(ir); }
@Before public void setUp() throws Exception { Intents.init(); mIdlingResource = mActivityRule.getActivity().getIdlingResource(); IdlingRegistry.getInstance().register(mIdlingResource); }
@After public void tearDown() { Intents.release(); if (mIdlingResource != null) { IdlingRegistry.getInstance().unregister(mIdlingResource); } }
@Test public void name() { IdlingResource idlingResource = OkHttp3IdlingResource.create( "okhttp", OkHttpProvider.getOkHttpInstance()); IdlingRegistry.getInstance().register(idlingResource); onView(withId(R.id.name)) .check(matches(withText("Chiu-Ki Chan"))); IdlingRegistry.getInstance().unregister(idlingResource); }
/** * Unregister your Idling Resource so it can be garbage collected and does not leak any memory. */ @After public void unregisterIdlingResource() { IdlingRegistry.getInstance().unregister( mAddTaskIntentsTestRule.getActivity().getCountingIdlingResource()); }
/** * Unregister your Idling Resource so it can be garbage collected and does not leak any memory. */ @After public void tearDown() throws Exception { IdlingRegistry.getInstance().unregister( mTasksActivityTestRule.getActivity().getCountingIdlingResource()); }
public static void registerOkHttp(OkHttpClient client) { IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create("okhttp", client)); }
@Before public void registerIdlingResource() { IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource()); }
@After public void unregisterIdlingResource() { IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource()); }
@Before public void setUp() { loadingIdlingResource = new SessionLoadedIdlingResource(); IdlingRegistry.getInstance().register(loadingIdlingResource); }
@After public void tearDown() throws Exception { IdlingRegistry.getInstance().unregister(loadingIdlingResource); mActivityTestRule.getActivity().finishAndRemoveTask(); }
@Before public void setUpIdlingResources() { loadingIdlingResource = new SessionLoadedIdlingResource(); IdlingRegistry.getInstance().register(loadingIdlingResource); }
@After public void tearDownIdlingResources() { IdlingRegistry.getInstance().unregister(loadingIdlingResource); }
@After public void tearDown() throws Exception { mActivityTestRule.getActivity().finishAndRemoveTask(); IdlingRegistry.getInstance().unregister(loadingIdlingResource); }
/** * Enable IdlingResource for the current test case (useful when defaultEnabled = false). */ public void enableForCurrentTestCase() { IdlingRegistry.getInstance().register(mFirebaseOperationIdlingResource); }
@Override protected void after() { IdlingRegistry.getInstance().unregister(mFirebaseOperationIdlingResource); // TODO(dotdoom): move this to a more appropriate place CrashlyticsTestExtension.sendReportsNow(); }
public static void registerOkHttp(OkHttpClient client) { IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create( "okhttp", client)); }
/** * Prepare your test fixture for this test. In this case we register an IdlingResources with * Espresso. IdlingResource resource is a great way to tell Espresso when your app is in an * idle state. This helps Espresso to synchronize your test actions, which makes tests significantly * more reliable. */ @Before public void registerIdlingResource() { IdlingRegistry.getInstance().register( mAddTaskIntentsTestRule.getActivity().getCountingIdlingResource()); }
/** * Prepare your test fixture for this test. In this case we register an IdlingResources with * Espresso. IdlingResource resource is a great way to tell Espresso when your app is in an * idle state. This helps Espresso to synchronize your test actions, which makes tests significantly * more reliable. */ @Before public void setUp() throws Exception { IdlingRegistry.getInstance().register( mTasksActivityTestRule.getActivity().getCountingIdlingResource()); }