Java 类android.support.test.espresso.IdlingRegistry 实例源码

项目:espresso-samples    文件:MainActivityTest.java   
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);
}
项目: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();
    }));
}
项目:meat-grinder    文件:MainActivityTest.java   
@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);
}
项目:cat-is-a-dog    文件:AuthTest.java   
@Before
public void setUp() throws Exception {
    Intents.init();

    mIdlingResource = mActivityRule.getActivity().getIdlingResource();
    IdlingRegistry.getInstance().register(mIdlingResource);
}
项目:cat-is-a-dog    文件:AuthTest.java   
@After
public void tearDown() {
    Intents.release();

    if (mIdlingResource != null) {
        IdlingRegistry.getInstance().unregister(mIdlingResource);
    }
}
项目:espresso-samples    文件:MainActivityTest.java   
@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);
}
项目:GitHub    文件:AddEditTaskScreenTest.java   
/**
 * 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());
}
项目:GitHub    文件:TasksScreenTest.java   
/**
 * 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());
}
项目:InstantAppStarter    文件:IdlingResources.java   
public static void registerOkHttp(OkHttpClient client) {
    IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create("okhttp", client));
}
项目:FireBaseTest    文件:HomeScreenTest.java   
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
项目:FireBaseTest    文件:HomeScreenTest.java   
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
项目:FireBaseTest    文件:ContentScreenTest.java   
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
项目:FireBaseTest    文件:ContentScreenTest.java   
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
项目:FireBaseTest    文件:SignInScreenTest.java   
@Before
public void registerIdlingResource() {
    IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource());
}
项目:FireBaseTest    文件:SignInScreenTest.java   
@After
public void unregisterIdlingResource() {
    IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource());
}
项目:firefox-tv    文件:PageVisitTest.java   
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:firefox-tv    文件:PageVisitTest.java   
@After
public void tearDown() throws Exception {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);

    mActivityTestRule.getActivity().finishAndRemoveTask();
}
项目:firefox-tv    文件:ScreenshotTest.java   
@Before
public void setUpIdlingResources() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:firefox-tv    文件:ScreenshotTest.java   
@After
public void tearDownIdlingResources() {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
项目:firefox-tv    文件:ToggleBlockTest.java   
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:firefox-tv    文件:ToggleBlockTest.java   
@After
public void tearDown() throws Exception {
    mActivityTestRule.getActivity().finishAndRemoveTask();

    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
项目:focus-android    文件:ScreenshotTest.java   
@Before
public void setUpIdlingResources() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:focus-android    文件:ScreenshotTest.java   
@After
public void tearDownIdlingResources() {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
项目:focus-android    文件:PageVisitTest.java   
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:focus-android    文件:PageVisitTest.java   
@After
public void tearDown() throws Exception {
    IdlingRegistry.getInstance().unregister(loadingIdlingResource);

    mActivityTestRule.getActivity().finishAndRemoveTask();
}
项目:focus-android    文件:ToggleBlockTest.java   
@Before
public void setUp() {
    loadingIdlingResource = new SessionLoadedIdlingResource();
    IdlingRegistry.getInstance().register(loadingIdlingResource);
}
项目:focus-android    文件:ToggleBlockTest.java   
@After
public void tearDown() throws Exception {
    mActivityTestRule.getActivity().finishAndRemoveTask();

    IdlingRegistry.getInstance().unregister(loadingIdlingResource);
}
项目:delern    文件:FirebaseOperationInProgressRule.java   
/**
 * Enable IdlingResource for the current test case (useful when defaultEnabled = false).
 */
public void enableForCurrentTestCase() {
    IdlingRegistry.getInstance().register(mFirebaseOperationIdlingResource);
}
项目:delern    文件:FirebaseOperationInProgressRule.java   
@Override
protected void after() {
    IdlingRegistry.getInstance().unregister(mFirebaseOperationIdlingResource);
    // TODO(dotdoom): move this to a more appropriate place
    CrashlyticsTestExtension.sendReportsNow();
}
项目:espresso-samples    文件:IdlingResources.java   
public static void registerOkHttp(OkHttpClient client) {
  IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create(
      "okhttp", client));
}
项目:GitHub    文件:AddEditTaskScreenTest.java   
/**
 * 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());
}
项目:GitHub    文件:TasksScreenTest.java   
/**
 * 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());
}