Search in sources :

Example 1 with NavigationController

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()));
    }
}
Also used : NavigationController(dagger.extension.example.service.NavigationController) HttpException(retrofit2.HttpException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

NavigationController (dagger.extension.example.service.NavigationController)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 HttpException (retrofit2.HttpException)1