Fix bugs in auto restriction.

1. Dismiss this tip once user clicks it and goes to detail page.
2. In auto restriction, since apps are automatically restricted,
we need to remove apps in list that unrestricted by user.
3. Refactor the code to remove the unnecessary parameter(i.e.
SettingsActivity)

Bug: 78187414
Test: RunSettingsRoboTests
Change-Id: I1c950f7c55df35795641c2ea8579ce9e011dba28
This commit is contained in:
Lei Yu
2018-04-17 17:41:07 -07:00
parent 1257466d0b
commit 252d4e1fc0
14 changed files with 234 additions and 51 deletions

View File

@@ -55,7 +55,7 @@ public class RestrictAppTest {
}
@Test
public void testBatterySettings_hasOneAnomaly_showAnomaly() throws
public void batterySettings_hasOneAnomaly_showAnomaly() throws
PackageManager.NameNotFoundException {
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
PACKAGE_SETTINGS, 1,
@@ -67,7 +67,7 @@ public class RestrictAppTest {
}
@Test
public void testBatterySettings_hasTwoAnomalies_showAnomalies() throws
public void batterySettings_hasTwoAnomalies_showAnomalies() throws
PackageManager.NameNotFoundException {
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
PACKAGE_SETTINGS, 1,
@@ -80,4 +80,19 @@ public class RestrictAppTest {
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
onView(withText("Restrict 2 apps")).check(matches(isDisplayed()));
}
@Test
public void batterySettings_hasAutoHandledAnomalies_showAutoHandled() throws
PackageManager.NameNotFoundException {
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
PACKAGE_SETTINGS, 1,
AnomalyDatabaseHelper.State.AUTO_HANDLED, System.currentTimeMillis());
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SYSTEM_UI, 0),
PACKAGE_SYSTEM_UI, 1,
AnomalyDatabaseHelper.State.AUTO_HANDLED, System.currentTimeMillis());
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
onView(withText("2 apps recently restricted")).check(matches(isDisplayed()));
}
}