Send fake data if there is no battey consumption entry list

Sends fake data into SettingsIntelligence if there is no data in the
battery consumption list, otherwise we don't have battery level data to
draw into the chart graph. We should draw the battery levels if it is
full-charged without any BatteryEntry data.

Bug: 184807417
Test: make SettingsRoboTests
Test: make SettingsGoogleRoboTests
Change-Id: I759e769256f4aa0ec152afff5c265ee3d04c03da
This commit is contained in:
ykhung
2021-04-11 11:03:35 +08:00
parent c024ec7cc9
commit bdaee1431f
3 changed files with 63 additions and 25 deletions

View File

@@ -111,6 +111,29 @@ public final class ConvertUtilsTest {
.isEqualTo(BatteryManager.BATTERY_HEALTH_COLD);
}
@Test
public void testConvert_nullBatteryEntry_returnsExpectedContentValues() {
final ContentValues values =
ConvertUtils.convert(
/*entry=*/ null,
/*batteryUsageStats=*/ null,
/*batteryLevel=*/ 12,
/*batteryStatus=*/ BatteryManager.BATTERY_STATUS_FULL,
/*batteryHealth=*/ BatteryManager.BATTERY_HEALTH_COLD,
/*timestamp=*/ 10001L);
assertThat(values.getAsLong("timestamp")).isEqualTo(10001L);
assertThat(values.getAsString("zoneId"))
.isEqualTo(TimeZone.getDefault().getID());
assertThat(values.getAsInteger("batteryLevel")).isEqualTo(12);
assertThat(values.getAsInteger("batteryStatus"))
.isEqualTo(BatteryManager.BATTERY_STATUS_FULL);
assertThat(values.getAsInteger("batteryHealth"))
.isEqualTo(BatteryManager.BATTERY_HEALTH_COLD);
assertThat(values.getAsString("packageName"))
.isEqualTo(ConvertUtils.FAKE_PACKAGE_NAME);
}
@Test
public void testGetDrainType_returnsExpetcedResult() {
final int expectedType = 3;