Merge "Add power consumption footer in screen timeout page." into main

This commit is contained in:
Treehugger Robot
2023-11-24 09:59:58 +00:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 1 deletions

View File

@@ -92,6 +92,9 @@ public class ScreenTimeoutSettingsTest {
@Mock
FooterPreference mDisableOptionsPreference;
@Mock
FooterPreference mPowerConsumptionPreference;
@Mock
private PackageManager mPackageManager;
@@ -182,11 +185,28 @@ public class ScreenTimeoutSettingsTest {
public void updateCandidates_enforcedAdmin_showDisabledByAdminPreference() {
mSettings.mAdmin = new RestrictedLockUtils.EnforcedAdmin();
mSettings.mDisableOptionsPreference = mDisableOptionsPreference;
mSettings.mPowerConsumptionPreference = mPowerConsumptionPreference;
doNothing().when(mSettings).setupDisabledFooterPreference();
doNothing().when(mSettings).setupPowerConsumptionFooterPreference();
mSettings.updateCandidates();
verify(mPreferenceScreen, atLeast(1)).addPreference(mDisableOptionsPreference);
verify(mPreferenceScreen, never()).addPreference(mPowerConsumptionPreference);
}
@Test
public void updateCandidates_withoutAdmin_showPowerConsumptionPreference() {
mSettings.mAdmin = null;
mSettings.mDisableOptionsPreference = mDisableOptionsPreference;
mSettings.mPowerConsumptionPreference = mPowerConsumptionPreference;
doNothing().when(mSettings).setupDisabledFooterPreference();
doNothing().when(mSettings).setupPowerConsumptionFooterPreference();
mSettings.updateCandidates();
verify(mPreferenceScreen, never()).addPreference(mDisableOptionsPreference);
verify(mPreferenceScreen, atLeast(1)).addPreference(mPowerConsumptionPreference);
}
@Test