Refine update process for restrict tip.
When restrict tip update, we should also update app list unless it goes from NEW to INVISIBLE. After that it won't show "0 apps been restricted". Change-Id: Iedf4288fcddfe632a9ba8c16afdfb5bc044bce2e Fix: 79890132 Test: RunSettingsRoboTests
This commit is contained in:
@@ -103,6 +103,7 @@ public class RestrictAppTip extends BatteryTip {
|
|||||||
} else {
|
} else {
|
||||||
mState = tip.getState();
|
mState = tip.getState();
|
||||||
mShowDialog = tip.shouldShowDialog();
|
mShowDialog = tip.shouldShowDialog();
|
||||||
|
mRestrictAppList = ((RestrictAppTip) tip).mRestrictAppList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@ public class RestrictAppTipTest {
|
|||||||
private RestrictAppTip mHandledBatteryTip;
|
private RestrictAppTip mHandledBatteryTip;
|
||||||
private RestrictAppTip mInvisibleBatteryTip;
|
private RestrictAppTip mInvisibleBatteryTip;
|
||||||
private List<AppInfo> mUsageAppList;
|
private List<AppInfo> mUsageAppList;
|
||||||
|
private AppInfo mAppInfo;
|
||||||
@Mock
|
@Mock
|
||||||
private ApplicationInfo mApplicationInfo;
|
private ApplicationInfo mApplicationInfo;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -77,15 +78,16 @@ public class RestrictAppTipTest {
|
|||||||
PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_ANY_USER);
|
PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_ANY_USER);
|
||||||
doReturn(DISPLAY_NAME).when(mApplicationInfo).loadLabel(mPackageManager);
|
doReturn(DISPLAY_NAME).when(mApplicationInfo).loadLabel(mPackageManager);
|
||||||
|
|
||||||
mUsageAppList = new ArrayList<>();
|
mAppInfo = new AppInfo.Builder()
|
||||||
mUsageAppList.add(new AppInfo.Builder()
|
|
||||||
.setPackageName(PACKAGE_NAME)
|
.setPackageName(PACKAGE_NAME)
|
||||||
.addAnomalyType(ANOMALY_WAKEUP)
|
.addAnomalyType(ANOMALY_WAKEUP)
|
||||||
.addAnomalyType(ANOMALY_WAKELOCK)
|
.addAnomalyType(ANOMALY_WAKELOCK)
|
||||||
.build());
|
.build();
|
||||||
|
mUsageAppList = new ArrayList<>();
|
||||||
|
mUsageAppList.add(mAppInfo);
|
||||||
mNewBatteryTip = new RestrictAppTip(BatteryTip.StateType.NEW, mUsageAppList);
|
mNewBatteryTip = new RestrictAppTip(BatteryTip.StateType.NEW, mUsageAppList);
|
||||||
mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
|
mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
|
||||||
mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, mUsageAppList);
|
mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -164,6 +166,13 @@ public class RestrictAppTipTest {
|
|||||||
assertThat(mHandledBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
assertThat(mHandledBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void update_newHandledAnomalyComes_containHandledAnomaly() {
|
||||||
|
mInvisibleBatteryTip.updateState(mHandledBatteryTip);
|
||||||
|
assertThat(mInvisibleBatteryTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
|
||||||
|
assertThat(mInvisibleBatteryTip.getRestrictAppList()).containsExactly(mAppInfo);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toString_containsAppData() {
|
public void toString_containsAppData() {
|
||||||
assertThat(mNewBatteryTip.toString()).isEqualTo(
|
assertThat(mNewBatteryTip.toString()).isEqualTo(
|
||||||
|
Reference in New Issue
Block a user