use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class TestTomorrowWeatherViewModel 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).getTomorrowWeather(1.0, 1.0);
}
use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class UnitTestTodayWeatherPresenter method denieingPermissionsShouldNotTriggerReloadOfWeatherData.
@Test
public void denieingPermissionsShouldNotTriggerReloadOfWeatherData() {
when(locationProvider.lastLocation()).thenReturn(createLocation(1.0, 1.0));
when(pm.isPermissionGranted(PERM_COARSE_LOCATION)).thenReturn(false);
when(pm.isPermissionGranted(PERM_FINE_LOCATION)).thenReturn(false);
vm.onViewAttached();
PermissionResult result = new PermissionResult(TodayWeatherViewModel.REQUEST_CODE_PERM_ACCESS_FINE_LOCATION, new String[] { PERM_COARSE_LOCATION }, new int[] { PackageManager.PERMISSION_DENIED });
permissionSubject.onNext(result);
verifyZeroInteractions(weatherService);
}
use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class UnitTestTodayWeatherPresenter method grantingPermissionsShouldTriggerReloadOfWeatherData.
@Test
public void grantingPermissionsShouldTriggerReloadOfWeatherData() {
when(locationProvider.lastLocation()).thenReturn(createLocation(1.0, 1.0));
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);
when(pm.isPermissionGranted(PERM_FINE_LOCATION)).thenReturn(true);
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);
}
use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class TestTomorrowWeatherViewModel method denieingPermissionsShouldNotTriggerReloadOfWeatherData.
@Test
public void denieingPermissionsShouldNotTriggerReloadOfWeatherData() {
when(pm.isPermissionGranted(PERM_COARSE_LOCATION)).thenReturn(false);
when(pm.isPermissionGranted(PERM_FINE_LOCATION)).thenReturn(false);
vm.onViewAttached();
PermissionResult result = new PermissionResult(TodayWeatherViewModel.REQUEST_CODE_PERM_ACCESS_FINE_LOCATION, new String[] { PERM_COARSE_LOCATION }, new int[] { PackageManager.PERMISSION_DENIED });
permissionSubject.onNext(result);
verifyZeroInteractions(weatherService);
}
use of dagger.extension.example.service.PermissionResult in project dagger-test-example by aschattney.
the class TestTodayWeatherViewModel method denieingPermissionsShouldNotTriggerReloadOfWeatherData.
@Test
public void denieingPermissionsShouldNotTriggerReloadOfWeatherData() {
when(pm.isPermissionGranted(PERM_COARSE_LOCATION)).thenReturn(false);
when(pm.isPermissionGranted(PERM_FINE_LOCATION)).thenReturn(false);
vm.onViewAttached();
PermissionResult result = new PermissionResult(TodayWeatherViewModel.REQUEST_CODE_PERM_ACCESS_FINE_LOCATION, new String[] { PERM_COARSE_LOCATION }, new int[] { PackageManager.PERMISSION_DENIED });
permissionSubject.onNext(result);
verifyZeroInteractions(weatherService);
}
Aggregations