Disable the optimization mode preference if the app is not settable
https://screenshot.googleplex.com/BbQyEv6YCjPVwUF (allowlist) https://screenshot.googleplex.com/3hTb8TQwGMQqcwS https://screenshot.googleplex.com/6hdTAT2yNFucD9N (system app) https://screenshot.googleplex.com/77T5JyAD5nZJpDT (normal app) Fix: 281566984 Test: make test RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge.* Change-Id: If7aa4b61bc806daa570187da24b7f454cd069dec
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package com.android.settings.fuelgauge;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -53,7 +52,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_isValidPackage_prefEnabled() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(false);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -62,7 +61,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_invalidPackage_prefDisabled() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(false);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(true);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -71,7 +70,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_isSystemOrDefaultAppAndUnrestrictedStates_prefChecked() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(false);
|
||||
when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(
|
||||
BatteryOptimizeUtils.MODE_UNRESTRICTED);
|
||||
@@ -83,7 +82,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_isSystemOrDefaultApp_prefUnchecked() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(false);
|
||||
when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
@@ -94,7 +93,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_isUnrestrictedStates_prefChecked() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(false);
|
||||
when(mockBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn(
|
||||
BatteryOptimizeUtils.MODE_UNRESTRICTED);
|
||||
|
||||
@@ -105,7 +104,7 @@ public class UnrestrictedPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUpdateState_prefUnchecked() {
|
||||
when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true);
|
||||
when(mockBatteryOptimizeUtils.isDisabledForOptimizeModeOnly()).thenReturn(false);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user