Merge "Suppress battery saver suggestion notification" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
62ec08f7bd
@@ -8,6 +8,7 @@ import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.provider.Settings.Secure;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -59,9 +60,36 @@ public class BatterySaverScheduleRadioButtonsControllerTest {
|
||||
@Test
|
||||
public void setDefaultKey_any_defaultsToNoScheduleIfWarningNotSeen() {
|
||||
Secure.putString(
|
||||
mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, "null");
|
||||
mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, "null");
|
||||
mController.setDefaultKey(BatterySaverScheduleRadioButtonsController.KEY_ROUTINE);
|
||||
assertThat(mController.getDefaultKey())
|
||||
.isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setDefaultKey_percentage_shouldSuppressNotification() {
|
||||
Secure.putInt(
|
||||
mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1);
|
||||
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);
|
||||
|
||||
final int result = Settings.Secure.getInt(mResolver,
|
||||
Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0);
|
||||
assertThat(result).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setDefaultKey_routine_shouldSuppressNotification() {
|
||||
Secure.putInt(
|
||||
mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 1);
|
||||
Settings.Global.putInt(mResolver, Global.AUTOMATIC_POWER_SAVE_MODE,
|
||||
PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
|
||||
mController.setDefaultKey(BatterySaverScheduleRadioButtonsController.KEY_ROUTINE);
|
||||
|
||||
final int result = Settings.Secure.getInt(mResolver,
|
||||
Secure.SUPPRESS_AUTO_BATTERY_SAVER_SUGGESTION, 0);
|
||||
assertThat(result).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user