Java Code Examples for android.support.test.espresso.IdlingRegistry

The following are top voted examples for showing how to use android.support.test.espresso.IdlingRegistry. 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: espresso-samples   File: MainActivityTest.java   View source code 6 votes vote down vote up
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);
}
 
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: meat-grinder   File: MainActivityTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 4
Project: cat-is-a-dog   File: AuthTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    Intents.init();

    mIdlingResource = mActivityRule.getActivity().getIdlingResource();
    IdlingRegistry.getInstance().register(mIdlingResource);
}
 
Example 5
Project: cat-is-a-dog   File: AuthTest.java   View source code 5 votes vote down vote up
@After
public void tearDown() {
    Intents.release();

    if (mIdlingResource != null) {
        IdlingRegistry.getInstance().unregister(mIdlingResource);
    }
}
 
Example 6
Project: espresso-samples   File: MainActivityTest.java   View source code 5 votes vote down vote up
@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);
}
 
Example 7
Project: GitHub   File: AddEditTaskScreenTest.java   View source code 4 votes vote down vote up
/**
 * 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());
}
 
Example 8
Project: GitHub   File: TasksScreenTest.java   View source code 4 votes vote down vote up
/**
 * 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());
}
 
Example 9
Project: InstantAppStarter   File: IdlingResources.java   View source code 4 votes vote down vote up
public static void registerOkHttp(OkHttpClient client) {
    IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create("okhttp", client));
}
 
Example 10
Project: FireBaseTest   File: HomeScreenTest.java   View source code 4 votes vote down vote up
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
 
Example 11
Project: FireBaseTest   File: HomeScreenTest.java   View source code 4 votes vote down vote up
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
 
Example 12
Project: FireBaseTest   File: ContentScreenTest.java   View source code 4 votes vote down vote up
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
 
Example 13
Project: FireBaseTest   File: ContentScreenTest.java   View source code 4 votes vote down vote up
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
 
Example 14
Project: FireBaseTest   File: SignInScreenTest.java   View source code 4 votes vote down vote up
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
 
Example 15
Project: FireBaseTest   File: SignInScreenTest.java   View source code 4 votes vote down vote up
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
 
Example 16
Project: firefox-tv   File: PageVisitTest.java   View source code 4 votes vote down vote up
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 17
Project: firefox-tv   File: PageVisitTest.java   View source code 4 votes vote down vote up
@After
public void tearDown() throws Exception {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);

    mActivityTestRule.getActivity().finishAndRemoveTask();
}
 
Example 18
Project: firefox-tv   File: ScreenshotTest.java   View source code 4 votes vote down vote up
@Before
public void setUpIdlingResources() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 19
Project: firefox-tv   File: ScreenshotTest.java   View source code 4 votes vote down vote up
@After
public void tearDownIdlingResources() {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
 
Example 20
Project: firefox-tv   File: ToggleBlockTest.java   View source code 4 votes vote down vote up
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 21
Project: firefox-tv   File: ToggleBlockTest.java   View source code 4 votes vote down vote up
@After
public void tearDown() throws Exception {
    mActivityTestRule.getActivity().finishAndRemoveTask();

    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
 
Example 22
Project: focus-android   File: ScreenshotTest.java   View source code 4 votes vote down vote up
@Before
public void setUpIdlingResources() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 23
Project: focus-android   File: ScreenshotTest.java   View source code 4 votes vote down vote up
@After
public void tearDownIdlingResources() {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
 
Example 24
Project: focus-android   File: PageVisitTest.java   View source code 4 votes vote down vote up
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 25
Project: focus-android   File: PageVisitTest.java   View source code 4 votes vote down vote up
@After
public void tearDown() throws Exception {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);

    mActivityTestRule.getActivity().finishAndRemoveTask();
}
 
Example 26
Project: focus-android   File: ToggleBlockTest.java   View source code 4 votes vote down vote up
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
 
Example 27
Project: focus-android   File: ToggleBlockTest.java   View source code 4 votes vote down vote up
@After
public void tearDown() throws Exception {
    mActivityTestRule.getActivity().finishAndRemoveTask();

    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
 
Example 28
Project: delern   File: FirebaseOperationInProgressRule.java   View source code 4 votes vote down vote up
/**
 * Enable IdlingResource for the current test case (useful when defaultEnabled = false).
 */
public void enableForCurrentTestCase() {
    IdlingRegistry.getInstance().register(mFirebaseOperationIdlingResource);
}
 
Example 29
Project: delern   File: FirebaseOperationInProgressRule.java   View source code 4 votes vote down vote up
@Override
protected void after() {
    IdlingRegistry.getInstance().unregister(mFirebaseOperationIdlingResource);
    // TODO(dotdoom): move this to a more appropriate place
    CrashlyticsTestExtension.sendReportsNow();
}
 
Example 30
Project: espresso-samples   File: IdlingResources.java   View source code 4 votes vote down vote up
public static void registerOkHttp(OkHttpClient client) {
  IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create(
      "okhttp", client));
}
 
Example 31
Project: GitHub   File: AddEditTaskScreenTest.java   View source code 2 votes vote down vote up
/**
 * 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());
}
 
Example 32
Project: GitHub   File: TasksScreenTest.java   View source code 2 votes vote down vote up
/**
 * 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());
}