GesturesSettingPreferenceController to Toggle

Convert GesturesSettingPreferenceController to
TogglePreferenceController,
All of its children need follow the change,
add setter and robotest for them:
AssistGestureSettingsPreferenceController
DoubleTapPowerPreferenceController
DoubleTapScreenPreferenceController
DoubleTwistPreferenceController
PickupGesturePreferenceController
SwipeToNotificationPreferenceController

Change-Id: I792b2d370eea828bf345fb2b1cc3eac260eb66f4
Fixes: 74913806
Fixes: 67998110
Fixes: 67998098
Fixes: 67998048
Fixes: 67998069
Fixes: 67997452
Test: make RunSettingsRoboTests
This commit is contained in:
HJ ChangLiao
2018-04-02 17:06:55 +08:00
parent 9914ef7635
commit 22f53c0274
40 changed files with 320 additions and 429 deletions

View File

@@ -56,8 +56,8 @@ public class DoubleTapScreenPreferenceControllerTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new DoubleTapScreenPreferenceController(
mContext, null, mAmbientDisplayConfiguration, 0, KEY_DOUBLE_TAP_SCREEN);
mController = new DoubleTapScreenPreferenceController(mContext, KEY_DOUBLE_TAP_SCREEN);
mController.setConfig(mAmbientDisplayConfiguration);
}
@Test
@@ -75,26 +75,26 @@ public class DoubleTapScreenPreferenceControllerTest {
}
@Test
public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
public void testIsChecked_configIsSet_shouldReturnTrue() {
// Set the setting to be enabled.
when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(true);
assertThat(mController.isSwitchPrefEnabled()).isTrue();
assertThat(mController.isChecked()).isTrue();
}
@Test
public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
public void testIsChecked_configIsNotSet_shouldReturnFalse() {
when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
assertThat(mController.isSwitchPrefEnabled()).isFalse();
assertThat(mController.isChecked()).isFalse();
}
@Test
public void testPreferenceController_ProperResultPayloadType() {
final Context context = RuntimeEnvironment.application;
DoubleTapScreenPreferenceController controller =
new DoubleTapScreenPreferenceController(context, null /* lifecycle */,
mAmbientDisplayConfiguration, 0 /* userid */, KEY_DOUBLE_TAP_SCREEN);
new DoubleTapScreenPreferenceController(context, KEY_DOUBLE_TAP_SCREEN);
controller.setConfig(mAmbientDisplayConfiguration);
ResultPayload payload = controller.getResultPayload();
assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
}