use of android.support.test.espresso.IdlingResource in project cw-omnibus by commonsguy.
the class OkHttpTests method moreReliableAsyncTest.
@Test
public void moreReliableAsyncTest() {
IdlingResource idleWild = OkHttp3IdlingResource.create("okhttp3", main.getActivity().getOkHttpClient());
Espresso.registerIdlingResources(idleWild);
try {
onView(withId(android.R.id.list)).check(new AdapterCountAssertion(100));
} finally {
Espresso.unregisterIdlingResources(idleWild);
}
}
use of android.support.test.espresso.IdlingResource in project Rosie by Karumi.
the class InjectedInstrumentationTest method tearDown.
@After
public void tearDown() throws Exception {
List<IdlingResource> idlingResources = getIdlingResources();
for (IdlingResource resource : idlingResources) {
unregisterIdlingResources(resource);
}
MainApplication application = getApplication();
application.resetFakeGraph();
}
use of android.support.test.espresso.IdlingResource in project iosched by google.
the class MyScheduleActivityTest method newDataObtained_DataUpdated.
@Test
public void newDataObtained_DataUpdated() {
IdlingResource idlingResource = null;
try {
// Given initial data displayed
showDay(2);
onView(withText(MyScheduleMockItems.SESSION_TITLE_BEFORE)).check(matches(isDisplayed()));
onView(withText(MyScheduleMockItems.SESSION_TITLE_2)).check(doesNotExist());
showDay(1);
onView(withText(MyScheduleMockItems.SESSION_TITLE_AFTER)).check(matches(isDisplayed()));
onView(withText(MyScheduleMockItems.SESSION_TITLE_1)).check(doesNotExist());
// When new data is available
mStubMyScheduleModel.setMockScheduleDataDay1(MyScheduleMockItems.getItemsForAttendee(1, false, MyScheduleMockItems.SESSION_TITLE_1));
mStubMyScheduleModel.setMockScheduleDataDay2(MyScheduleMockItems.getItemsForAttendee(2, false, MyScheduleMockItems.SESSION_TITLE_2));
mStubMyScheduleModel.fireContentObserver();
// Wait for the ThrottleContentObserver to process the event
idlingResource = new ThrottleContentObserverIdlingResource(InstrumentationRegistry.getTargetContext());
Espresso.registerIdlingResources(idlingResource);
// Then the new data is shown
onView(withText(MyScheduleMockItems.SESSION_TITLE_1)).check(matches(isDisplayed()));
onView(withText(MyScheduleMockItems.SESSION_TITLE_AFTER)).check(doesNotExist());
showDay(2);
onView(withText(MyScheduleMockItems.SESSION_TITLE_2)).check(matches(isDisplayed()));
onView(withText(MyScheduleMockItems.SESSION_TITLE_BEFORE)).check(doesNotExist());
} finally {
if (idlingResource != null) {
Espresso.unregisterIdlingResources(idlingResource);
}
}
}
use of android.support.test.espresso.IdlingResource in project dev-summit-architecture-demo by yigit.
the class FeedActivityTest method registerIdlingResource.
@Before
public void registerIdlingResource() {
mIdlingResource = new IdlingResource() {
ResourceCallback mResourceCallback;
@Override
public String getName() {
return "RecyclerView";
}
@Override
public boolean isIdleNow() {
boolean idle = !mCreatedActivity || !getActivity().mBinding.list.hasPendingAdapterUpdates();
if (idle && mResourceCallback != null) {
mResourceCallback.onTransitionToIdle();
}
return idle;
}
@Override
public void registerIdleTransitionCallback(ResourceCallback callback) {
mResourceCallback = callback;
}
};
Espresso.registerIdlingResources(mIdlingResource);
}
Aggregations