use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class HighUsageDetectorTest method testDetect_containsHighUsageApp_tipVisibleAndSorted.
@Test
public void testDetect_containsHighUsageApp_tipVisibleAndSorted() {
doReturn(true).when(mDataParser).isDeviceHeavilyUsed();
final HighUsageTip highUsageTip = (HighUsageTip) mHighUsageDetector.detect();
assertThat(highUsageTip.isVisible()).isTrue();
// Contain two appInfo and large one comes first
final List<AppInfo> appInfos = highUsageTip.getHighUsageAppList();
assertThat(appInfos).containsExactly(mLowAppInfo, mHighAppInfo);
assertThat(appInfos.get(0)).isEqualTo(mHighAppInfo);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HighUsageTipTest method testParcelable.
@Test
public void testParcelable() {
Parcel parcel = Parcel.obtain();
mBatteryTip.writeToParcel(parcel, mBatteryTip.describeContents());
parcel.setDataPosition(0);
final HighUsageTip parcelTip = new HighUsageTip(parcel);
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used more than usual");
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
assertThat(parcelTip.getLastFullChargeTimeMs()).isEqualTo(LAST_FULL_CHARGE_TIME);
assertThat(parcelTip.mHighUsageAppList).isNotNull();
assertThat(parcelTip.mHighUsageAppList.size()).isEqualTo(1);
final AppInfo app = parcelTip.mHighUsageAppList.get(0);
assertThat(app.packageName).isEqualTo(PACKAGE_NAME);
assertThat(app.screenOnTimeMs).isEqualTo(SCREEN_TIME);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictedAppDetailsTest method startRestrictedAppDetails_startWithCorrectData.
@Test
public void startRestrictedAppDetails_startWithCorrectData() {
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
doAnswer(invocation -> {
// Get the intent in which it has the app info bundle
mIntent = captor.getValue();
return true;
}).when(mContext).startActivity(captor.capture());
RestrictedAppDetails.startRestrictedAppDetails(mFragment, mRestrictedAppDetails.mAppInfos);
final Bundle bundle = mIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
// Verify the bundle has the correct info
final List<AppInfo> appInfos = bundle.getParcelableArrayList(RestrictedAppDetails.EXTRA_APP_INFO_LIST);
assertThat(appInfos).containsExactly(mAppInfo);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryDatabaseManagerTest method updateAnomalies_updateSuccessfully.
@Test
public void updateAnomalies_updateSuccessfully() {
mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_NEW, AnomalyDatabaseHelper.State.NEW, NOW);
mBatteryDatabaseManager.insertAnomaly(UID_OLD, PACKAGE_NAME_OLD, TYPE_OLD, AnomalyDatabaseHelper.State.NEW, NOW);
final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_OLD).build();
final List<AppInfo> updateAppInfos = new ArrayList<>();
updateAppInfos.add(appInfo);
// Change state of PACKAGE_NAME_OLD to handled
mBatteryDatabaseManager.updateAnomalies(updateAppInfos, AnomalyDatabaseHelper.State.HANDLED);
// The state of PACKAGE_NAME_NEW is still new
List<AppInfo> newAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE, AnomalyDatabaseHelper.State.NEW);
assertThat(newAppInfos).containsExactly(mNewAppInfo);
// The state of PACKAGE_NAME_OLD is changed to handled
List<AppInfo> handledAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE, AnomalyDatabaseHelper.State.HANDLED);
assertThat(handledAppInfos).containsExactly(mOldAppInfo);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UnrestrictAppActionTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final AppInfo appInfo = new AppInfo.Builder().setUid(UID_1).setPackageName(PACKAGE_NAME_1).build();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mUnrestrictAppAction = new UnrestrictAppAction(RuntimeEnvironment.application, new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo));
mUnrestrictAppAction.mBatteryUtils = mBatteryUtils;
}
Aggregations