Add isSliceable API to BasePrefController
Only support explicitly approved Settings Slices, dictated by controllers which return true for the new method isSliceable. Updating the supported settings to a whitelist means that the method to return all available slices must be updated, and checking slicability when we index slices. Test: robotests Bug: 79779103 Change-Id: Ib2b9690cdd0036b5cc4a1cb846c52bce7c824ab9
This commit is contained in:
@@ -104,7 +104,7 @@ public class AutoRotatePreferenceControllerTest {
|
||||
@Test
|
||||
public void testGetAvailabilityStatus() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
|
||||
.CONDITIONALLY_UNAVAILABLE);
|
||||
.UNSUPPORTED_ON_DEVICE);
|
||||
|
||||
enableAutoRotationPreference();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class AutoRotatePreferenceControllerTest {
|
||||
disableAutoRotationPreference();
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
|
||||
.CONDITIONALLY_UNAVAILABLE);
|
||||
.UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,6 +144,20 @@ public class AutoRotatePreferenceControllerTest {
|
||||
assertThat(RotationPolicy.isRotationLocked(mContext)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
final AutoRotatePreferenceController controller =
|
||||
new AutoRotatePreferenceController(mContext, "auto_rotate");
|
||||
assertThat(controller.isSliceable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableIncorrectKey_returnsFalse() {
|
||||
final AutoRotatePreferenceController controller =
|
||||
new AutoRotatePreferenceController(mContext, "bad_key");
|
||||
assertThat(controller.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
private void enableAutoRotationPreference() {
|
||||
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
|
||||
when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
|
||||
|
Reference in New Issue
Block a user