Camera lift preference now saves correctly

Bug: 37751057
Test: manual + make RunSettingsRoboTests

Fixed issue where camera lift preference was saving the opposite value
of what it was supposed to. Added test to cover saving of value on
preference change.

Change-Id: I2d2c454eb478afb7f73519f9f05c9a9a1933938b
This commit is contained in:
Daniel Sheng
2017-05-04 15:14:39 -07:00
parent 5c5830f865
commit 7b9e3fdd08
2 changed files with 23 additions and 1 deletions

View File

@@ -100,4 +100,26 @@ public class CameraLiftTriggerPreferenceControllerTest {
assertThat(mController.isSwitchPrefEnabled()).isTrue();
}
@Test
public void testEnablePreference_shouldSetSetting() {
final Context context = RuntimeEnvironment.application;
mController = new CameraLiftTriggerPreferenceController(context, null,
KEY_CAMERA_LIFT_TRIGGER);
mController.onPreferenceChange(null, true);
assertThat(Settings.Secure.getInt(context.getContentResolver(),
CAMERA_LIFT_TRIGGER_ENABLED, 0)).isEqualTo(1);
}
@Test
public void testDisablePreference_shouldClearSetting() {
final Context context = RuntimeEnvironment.application;
mController = new CameraLiftTriggerPreferenceController(context, null,
KEY_CAMERA_LIFT_TRIGGER);
mController.onPreferenceChange(null, false);
assertThat(Settings.Secure.getInt(context.getContentResolver(),
CAMERA_LIFT_TRIGGER_ENABLED, 1)).isEqualTo(0);
}
}