Move allowed list definition in the battery usage to feature provider

Bug: 199367609
Test: make SettingsRoboTests
Change-Id: I321426e6ff1b9586ee493792f1d39aed35ecc34d
Signed-off-by: ykhung <ykhung@google.com>
This commit is contained in:
ykhung
2021-09-09 17:25:08 +08:00
parent 88cd5025e1
commit b62cdecc67
7 changed files with 26 additions and 14 deletions

View File

@@ -67,11 +67,13 @@ public class BatteryAppListPreferenceControllerTest {
private Context mContext;
private PowerGaugePreference mPreference;
private BatteryAppListPreferenceController mPreferenceController;
private FakeFeatureFactory mFeatureFactory;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mFeatureFactory = FakeFeatureFactory.setupForTest();
mContext = spy(RuntimeEnvironment.application);
final Resources resources = spy(mContext.getResources());
when(mContext.getResources()).thenReturn(resources);
@@ -79,9 +81,8 @@ public class BatteryAppListPreferenceControllerTest {
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});
when(resources.getTextArray(R.array.allowlist_hide_summary_in_battery_usage))
when(mFeatureFactory.powerUsageFeatureProvider.getHideApplicationSummary(mContext))
.thenReturn(new String[] {"com.android.googlequicksearchbox"});
FakeFeatureFactory.setupForTest();
mPreference = new PowerGaugePreference(mContext);

View File

@@ -103,7 +103,8 @@ public final class BatteryChartPreferenceControllerTest {
resources.getConfiguration().setLocales(new LocaleList(new Locale("en_US")));
doReturn(resources).when(mContext).getResources();
doReturn(new String[] {"com.android.googlequicksearchbox"})
.when(resources).getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
.when(mFeatureFactory.powerUsageFeatureProvider)
.getHideApplicationSummary(mContext);
mBatteryChartPreferenceController = createController();
mBatteryChartPreferenceController.mPrefContext = mContext;
mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;