use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class TestTodayWeatherViewModel method grantingPermissionsShouldTriggerReloadOfWeatherDataIfGpsIsEnabled.
@Test
public void grantingPermissionsShouldTriggerReloadOfWeatherDataIfGpsIsEnabled() {
final Location location = mockLocation(mock(Location.class), 1.0, 1.0);
when(locationService.lastLocation()).thenReturn(location);
when(pm.isPermissionGranted(PERM_COARSE_LOCATION)).thenReturn(false);
when(pm.isPermissionGranted(PERM_FINE_LOCATION)).thenReturn(false);
vm.onViewAttached();
when(pm.isPermissionGranted(PERM_COARSE_LOCATION)).thenReturn(true);
permissionSubject.onNext(new PermissionResult(TodayWeatherViewModel.REQUEST_CODE_PERM_ACCESS_FINE_LOCATION, new String[] { PERM_FINE_LOCATION }, new int[] { PackageManager.PERMISSION_GRANTED }));
verifyZeroInteractions(weatherService);
permissionSubject.onNext(new PermissionResult(TodayWeatherViewModel.REQUEST_CODE_PERM_ACCESS_COARSE_LOCATION, new String[] { PERM_COARSE_LOCATION }, new int[] { PackageManager.PERMISSION_GRANTED }));
verify(weatherService).getCurrentWeather(1.0, 1.0);
}
Aggregations