use of com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip in project android_packages_apps_Settings by omnirom.
the class RestrictAppDetectorTest method testDetect_typeNewHasUninstalledAnomaly_removeIt.
@Test
public void testDetect_typeNewHasUninstalledAnomaly_removeIt() {
mAppInfoList.add(new AppInfo.Builder().setPackageName(UNINSTALLED_PACKAGE_NAME).build());
doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(), eq(AnomalyDatabaseHelper.State.NEW));
final RestrictAppTip restrictAppTip = (RestrictAppTip) mRestrictAppDetector.detect();
assertThat(restrictAppTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
assertThat(restrictAppTip.getRestrictAppList()).containsExactly(mAppInfo);
}
use of com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryTipDialogFragmentTest method testOnCreateDialog_restrictSixAppsTip_fireRestrictSixAppsDialog.
@Test
public void testOnCreateDialog_restrictSixAppsTip_fireRestrictSixAppsDialog() {
Robolectric.getForegroundThreadScheduler().pause();
final List<AppInfo> appInfos = new ArrayList<>();
for (int i = 0; i < 6; i++) {
appInfos.add(mAppInfo);
}
final RestrictAppTip restrictSixAppsTip = new RestrictAppTip(BatteryTip.StateType.NEW, appInfos);
mDialogFragment = BatteryTipDialogFragment.newInstance(restrictSixAppsTip, METRICS_KEY);
FragmentController.setupFragment(mDialogFragment, FragmentActivity.class, 0, /* containerViewId */
null);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
final AlertDialog dialog = ShadowAlertDialogCompat.getLatestAlertDialog();
ShadowAlertDialogCompat shadowDialog = ShadowAlertDialogCompat.shadowOf(dialog);
assertThat(shadowDialog.getTitle()).isEqualTo("Restrict 6 apps?");
assertThat(shadowDialog.getMessage()).isEqualTo("To save battery, stop these apps from using battery in the background. " + "Restricted apps may not work properly and notifications may be" + " delayed.\n\nApps:\napp, app, app, app, app, and app.");
}
use of com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictAppDetectorTest method testDetect_typeNewHasRestrictedAnomaly_removeIt.
@Test
public void testDetect_typeNewHasRestrictedAnomaly_removeIt() throws PackageManager.NameNotFoundException {
mAppInfoList.add(new AppInfo.Builder().setUid(RESTRICTED_UID).setPackageName(RESTRICTED_PACKAGE_NAME).build());
doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(), eq(AnomalyDatabaseHelper.State.NEW));
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(eq(RESTRICTED_PACKAGE_NAME), anyInt());
final RestrictAppTip restrictAppTip = (RestrictAppTip) mRestrictAppDetector.detect();
assertThat(restrictAppTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
assertThat(restrictAppTip.getRestrictAppList()).containsExactly(mAppInfo);
}
use of com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictAppDetectorTest method testDetect_typeHandledHasUnRestrictedAnomaly_removeIt.
@Test
public void testDetect_typeHandledHasUnRestrictedAnomaly_removeIt() throws PackageManager.NameNotFoundException {
mAppInfoList.clear();
mAppInfoList.add(new AppInfo.Builder().setUid(UNRESTRICTED_UID).setPackageName(UNRESTRICTED_PACKAGE_NAME).build());
doReturn(new ArrayList<>()).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(), eq(AnomalyDatabaseHelper.State.NEW));
doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(), eq(AnomalyDatabaseHelper.State.AUTO_HANDLED));
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(eq(UNRESTRICTED_PACKAGE_NAME), anyInt());
final RestrictAppTip restrictAppTip = (RestrictAppTip) mRestrictAppDetector.detect();
assertThat(restrictAppTip.getState()).isEqualTo(BatteryTip.StateType.INVISIBLE);
}
use of com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictAppDetectorTest method testDetect_typeNewHasUninstalledAnomaly_removeIt.
@Test
public void testDetect_typeNewHasUninstalledAnomaly_removeIt() {
mAppInfoList.add(new AppInfo.Builder().setPackageName(UNINSTALLED_PACKAGE_NAME).build());
doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(), eq(AnomalyDatabaseHelper.State.NEW));
final RestrictAppTip restrictAppTip = (RestrictAppTip) mRestrictAppDetector.detect();
assertThat(restrictAppTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
assertThat(restrictAppTip.getRestrictAppList()).containsExactly(mAppInfo);
}
Aggregations