Add a flag for controlling location indicator settings.

Bug: 177334097
Test: Manual && make RunSettingsRoboTests ROBOTEST_FILTER=LocationIndicatorsPreferenceControllerTest
Change-Id: I33821ab8328fd18b796a78813b7354a928832792
This commit is contained in:
Wei Wang
2021-01-12 10:30:25 -08:00
parent bd56b6ba62
commit a6daf85a32
3 changed files with 35 additions and 0 deletions

View File

@@ -75,6 +75,10 @@ public class LocationIndicatorsPreferenceControllerTest {
*/
@Test
public void getAvailabilityStatus_locationSupported_shouldReturnAVAILABLE() {
// Enable the settings flags.
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
Utils.PROPERTY_LOCATION_INDICATOR_SETTINGS_ENABLED, Boolean.toString(true),
true);
when(mPackageManager.hasSystemFeature(eq(PackageManager.FEATURE_LOCATION))).thenReturn(
true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
@@ -86,11 +90,31 @@ public class LocationIndicatorsPreferenceControllerTest {
*/
@Test
public void getAvailabilityStatus_locationNotSupported_shouldReturnUNSUPPORTED() {
// Enable the settings flags.
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
Utils.PROPERTY_LOCATION_INDICATOR_SETTINGS_ENABLED, Boolean.toString(true),
true);
when(mPackageManager.hasSystemFeature(eq(PackageManager.FEATURE_LOCATION))).thenReturn(
false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
/**
* Verify the location indicator settings are not visible when location indicator settings
* are disabled on the device.
*/
@Test
public void getAvailabilityStatus_flagDisabled_shouldReturnUNSUPPORTED() {
// Disable the settings flags.
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_PRIVACY,
Utils.PROPERTY_LOCATION_INDICATOR_SETTINGS_ENABLED, Boolean.toString(false),
false);
when(mPackageManager.hasSystemFeature(eq(PackageManager.FEATURE_LOCATION))).thenReturn(
true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
/**
* Verify the location indicator preference is checked when the feature is enabled.
*/