use of com.getcapacitor.PermissionState in project capacitor-radar by radarlabs.
the class PermissionsTest method data.
@Parameters(name = "{index}: " + "gpsLocationPermission? {0}. " + "wifiLocationPermission? {1}. " + "backgroundLocationPermission? {2}")
public static Iterable<Object[]> data() {
PermissionState[] states = PermissionState.values();
Object[][] data = new Object[states.length * states.length * states.length][3];
int i = 0;
for (PermissionState gpsLocationPermission : states) {
for (PermissionState wifiLocationPermission : states) {
for (PermissionState backgroundLocationPermission : states) {
data[i] = new Object[] { gpsLocationPermission, wifiLocationPermission, backgroundLocationPermission };
i++;
}
}
}
return Arrays.asList(data);
}
use of com.getcapacitor.PermissionState in project capacitor-radar by radarlabs.
the class PermissionsTest method testGetLocationPermissionsStatus.
@Test
public void testGetLocationPermissionsStatus() {
PluginCall pluginCall = mock(PluginCall.class);
Map<String, PermissionState> states = new HashMap<>();
states.put(Manifest.permission.ACCESS_FINE_LOCATION, mGpsLocationPermission);
states.put(Manifest.permission.ACCESS_COARSE_LOCATION, mWifiLocationPermission);
states.put(Manifest.permission.ACCESS_BACKGROUND_LOCATION, mBackgroundLocationPermission);
when(mBridge.getPermissionStates(eq(mPlugin))).thenReturn(states);
mPlugin.getLocationPermissionsStatus(pluginCall);
String expectedStatus;
if (isGranted(mGpsLocationPermission) || isGranted(mWifiLocationPermission)) {
if (isGranted(mBackgroundLocationPermission)) {
expectedStatus = "GRANTED_BACKGROUND";
} else {
expectedStatus = "GRANTED_FOREGROUND";
}
} else if (isDenied(mGpsLocationPermission) || isDenied(mWifiLocationPermission)) {
expectedStatus = "DENIED";
} else {
expectedStatus = "NOT_DETERMINED";
}
ArgumentCaptor<JSObject> captor = ArgumentCaptor.forClass(JSObject.class);
verify(pluginCall).resolve(captor.capture());
JSObject json = captor.getValue();
assertNotNull(json);
String actualStatus = json.getString("status");
assertEquals(expectedStatus, actualStatus);
}
Aggregations