use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by omnirom.
the class PowerUsageSummaryTest method testFindBatterySipperByType_findTypeScreen.
@Test
public void testFindBatterySipperByType_findTypeScreen() {
BatterySipper sipper = mFragment.findBatterySipperByType(mUsageList, BatterySipper.DrainType.SCREEN);
assertThat(sipper).isSameAs(mScreenBatterySipper);
}
use of com.android.internal.os.BatterySipper in project android_packages_apps_Settings by omnirom.
the class BatteryUtilsTest method createTestSmearBatterySipper.
private BatterySipper createTestSmearBatterySipper(long topTime, double totalPowerMah, int uidCode, boolean isUidNull) {
final BatterySipper sipper = mock(BatterySipper.class);
sipper.drainType = BatterySipper.DrainType.APP;
sipper.totalPowerMah = totalPowerMah;
doReturn(uidCode).when(sipper).getUid();
if (!isUidNull) {
final BatteryStats.Uid uid = mock(BatteryStats.Uid.class, RETURNS_DEEP_STUBS);
doReturn(topTime).when(mBatteryUtils).getProcessTimeMs(eq(BatteryUtils.StatusType.SCREEN_USAGE), eq(uid), anyInt());
doReturn(uidCode).when(uid).getUid();
sipper.uidObj = uid;
}
return sipper;
}
use of com.android.internal.os.BatterySipper in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryUtilsTest method createTestSmearBatterySipper.
private BatterySipper createTestSmearBatterySipper(long topTime, double totalPowerMah, int uidCode, boolean isUidNull) {
final BatterySipper sipper = mock(BatterySipper.class);
sipper.drainType = BatterySipper.DrainType.APP;
sipper.totalPowerMah = totalPowerMah;
doReturn(uidCode).when(sipper).getUid();
if (!isUidNull) {
final BatteryStats.Uid uid = mock(BatteryStats.Uid.class, RETURNS_DEEP_STUBS);
doReturn(topTime).when(mBatteryUtils).getProcessTimeMs(eq(BatteryUtils.StatusType.SCREEN_USAGE), eq(uid), anyInt());
doReturn(uidCode).when(uid).getUid();
sipper.uidObj = uid;
}
return sipper;
}
use of com.android.internal.os.BatterySipper in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryUtilsTest method testFindBatterySipperByType_findTypeScreen.
@Test
public void testFindBatterySipperByType_findTypeScreen() {
BatterySipper sipper = mBatteryUtils.findBatterySipperByType(mUsageList, BatterySipper.DrainType.SCREEN);
assertThat(sipper).isSameAs(mScreenBatterySipper);
}
use of com.android.internal.os.BatterySipper in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryUtilsTest method testSmearScreenBatterySipper.
@Test
public void testSmearScreenBatterySipper() {
final BatterySipper sipperNull = createTestSmearBatterySipper(TIME_FOREGROUND_ZERO, BATTERY_APP_USAGE, 0, /* uid */
true);
final BatterySipper sipperBg = createTestSmearBatterySipper(TIME_FOREGROUND_ZERO, BATTERY_APP_USAGE, 1, /* uid */
false);
final BatterySipper sipperFg = createTestSmearBatterySipper(TIME_FOREGROUND, BATTERY_APP_USAGE, 2, /* uid */
false);
final BatterySipper sipperFg2 = createTestSmearBatterySipper(TIME_FOREGROUND, BATTERY_APP_USAGE, 3, /* uid */
false);
final List<BatterySipper> sippers = new ArrayList<>();
sippers.add(sipperNull);
sippers.add(sipperBg);
sippers.add(sipperFg);
sippers.add(sipperFg2);
mBatteryUtils.smearScreenBatterySipper(sippers, mScreenBatterySipper);
assertThat(sipperNull.totalPowerMah).isWithin(PRECISION).of(BATTERY_APP_USAGE);
assertThat(sipperBg.totalPowerMah).isWithin(PRECISION).of(BATTERY_APP_USAGE);
assertThat(sipperFg.totalPowerMah).isWithin(PRECISION).of(BATTERY_APP_USAGE + BATTERY_SCREEN_USAGE / 2);
assertThat(sipperFg2.totalPowerMah).isWithin(PRECISION).of(BATTERY_APP_USAGE + BATTERY_SCREEN_USAGE / 2);
}
Aggregations