Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 018548b3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refine update process for restrict tip." into pi-dev

parents 871d93a5 551a1a01
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class RestrictAppTip extends BatteryTip {
        } else {
            mState = tip.getState();
            mShowDialog = tip.shouldShowDialog();
            mRestrictAppList = ((RestrictAppTip) tip).mRestrictAppList;
        }
    }

+13 −4
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public class RestrictAppTipTest {
    private RestrictAppTip mHandledBatteryTip;
    private RestrictAppTip mInvisibleBatteryTip;
    private List<AppInfo> mUsageAppList;
    private AppInfo mAppInfo;
    @Mock
    private ApplicationInfo mApplicationInfo;
    @Mock
@@ -77,15 +78,16 @@ public class RestrictAppTipTest {
                PackageManager.MATCH_DISABLED_COMPONENTS | PackageManager.MATCH_ANY_USER);
        doReturn(DISPLAY_NAME).when(mApplicationInfo).loadLabel(mPackageManager);

        mUsageAppList = new ArrayList<>();
        mUsageAppList.add(new AppInfo.Builder()
        mAppInfo = new AppInfo.Builder()
                .setPackageName(PACKAGE_NAME)
                .addAnomalyType(ANOMALY_WAKEUP)
                .addAnomalyType(ANOMALY_WAKELOCK)
                .build());
                .build();
        mUsageAppList = new ArrayList<>();
        mUsageAppList.add(mAppInfo);
        mNewBatteryTip = new RestrictAppTip(BatteryTip.StateType.NEW, mUsageAppList);
        mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
        mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, mUsageAppList);
        mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, new ArrayList<>());
    }

    @Test
@@ -164,6 +166,13 @@ public class RestrictAppTipTest {
        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
    public void toString_containsAppData() {
        assertThat(mNewBatteryTip.toString()).isEqualTo(