Refactor battery saver schedule method
- Move schedule method and definition into BatterySaverUtils and reuse them from utils Bug: 260302999 Test: make SettingsRoboTests Change-Id: I402c57629d1a6f3317f0a7c14529508ce81f999c
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.settings.fuelgauge.batterysaver;
|
||||
|
||||
import static com.android.settingslib.fuelgauge.BatterySaverUtils.KEY_PERCENTAGE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
@@ -47,33 +49,6 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
|
||||
mResolver = mContext.getContentResolver();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_routine_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_automatic_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDefaultKey_none_returnsCorrectValue() {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void setDefaultKey_percentage_shouldSuppressNotification() {
|
||||
Secure.putInt(
|
||||
@@ -81,7 +56,7 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
|
||||
Settings.Global.putInt(mResolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
|
||||
mController.setDefaultKey(BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE);
|
||||
mController.setDefaultKey(KEY_PERCENTAGE);
|
||||
|
||||
final int result = Settings.Secure.getInt(mResolver,
|
||||
Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0);
|
||||
|
Reference in New Issue
Block a user