Merge "Port battery usage bug fixing cls from master to tm-qpr-dev" into tm-qpr-dev

This commit is contained in:
TreeHugger Robot
2022-08-24 05:04:05 +00:00
committed by Android (Google) Code Review
18 changed files with 186 additions and 62 deletions

View File

@@ -630,6 +630,18 @@ public final class BatteryChartPreferenceControllerTest {
.isFalse();
}
@Test
public void getTotalHours_getExpectedResult() {
Map<Long, Map<String, BatteryHistEntry>> batteryHistoryMap = createBatteryHistoryMap(60);
BatteryLevelData batteryLevelData = DataProcessor.getBatteryLevelData(mContext, null,
batteryHistoryMap, null);
final int totalHour = BatteryChartPreferenceController.getTotalHours(batteryLevelData);
// Only calculate the even hours.
assertThat(totalHour).isEqualTo(58);
}
private static Long generateTimestamp(int index) {
// "2021-04-23 07:00:00 UTC" + index hours
return 1619247600000L + index * DateUtils.HOUR_IN_MILLIS;

View File

@@ -307,7 +307,7 @@ public class BatteryEntryTest {
R.drawable.ic_settings_aod);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_BLUETOOTH,
R.string.power_bluetooth,
com.android.internal.R.drawable.ic_settings_bluetooth);
R.drawable.ic_settings_bluetooth);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_CAMERA,
R.string.power_camera,
R.drawable.ic_settings_camera);
@@ -325,7 +325,7 @@ public class BatteryEntryTest {
R.drawable.ic_settings_display);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_WIFI,
R.string.power_wifi,
R.drawable.ic_settings_wireless);
R.drawable.ic_settings_wireless_no_theme);
assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_IDLE,
R.string.power_idle,
R.drawable.ic_settings_phone_idle);