use of dagger.extension.example.service.NavigationController in project dagger-test-example by aschattney.
the class SimpleEspressoTest method viewIsClearedWhenARequestFailed.
@Test
public void viewIsClearedWhenARequestFailed() {
NavigationController controller = mock(NavigationController.class);
app().mainActivitySubcomponent().withNavigationController(() -> controller);
doNothing().when(controller).showErrorIfNotAlreadyShowing(anyString(), anyString());
final String message = "some exception message";
when(weatherApi.getCurrentWeather(FAKE_LONGITUDE, FAKE_LATITUDE)).thenReturn(Observable.error(new HttpException(Response.error(500, ResponseBody.create(MediaType.parse("text/plain"), message)))));
when(weatherApi.getTomorrowWeather(FAKE_LONGITUDE, FAKE_LATITUDE)).thenReturn(Observable.empty());
rule.launchActivity(null);
this.allowPermissionsIfNeeded();
onView(withIndex(withId(R.id.imageView), 0)).check(matches(hasNoDrawable()));
final int[] ids = new int[] { R.id.cityTextView, R.id.temperatureTextView, R.id.humidityTextView, R.id.descriptionTextView };
for (int id : ids) {
onView(withIndex(withId(id), 0)).check(matches(emptyText()));
}
}
Aggregations