Fix legacy failed unit test for BatteryInfoLoader
fix the legacy failed test since the scale is different, setting the testing value in ms scale (getBatteryTimeRemainingMs()), but getting the data in us scale (info.remainingTimeUs) Bug: 188244142 Test: make SettingsRoboTests Change-Id: Ib389976985eb3741cc96e0ee4a3a000c7f690b37
This commit is contained in:
@@ -73,6 +73,11 @@ public class BatteryDiffEntry {
|
|||||||
mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
|
mBackgroundUsageTimeInMs = backgroundUsageTimeInMs;
|
||||||
mBatteryHistEntry = batteryHistEntry;
|
mBatteryHistEntry = batteryHistEntry;
|
||||||
mUserManager = context.getSystemService(UserManager.class);
|
mUserManager = context.getSystemService(UserManager.class);
|
||||||
|
if (foregroundUsageTimeInMs == 0
|
||||||
|
&& backgroundUsageTimeInMs == 0
|
||||||
|
&& consumePower != 0) {
|
||||||
|
Log.w(TAG, "abnornal BatteryDiffEntry:\n" + this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the total consumed power in a specific time slot. */
|
/** Sets the total consumed power in a specific time slot. */
|
||||||
|
@@ -230,7 +230,7 @@ public final class ConvertUtils {
|
|||||||
if (selectedBatteryEntry == null) {
|
if (selectedBatteryEntry == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Force refine the cumulative value since it may introduce deviation
|
// Forces refine the cumulative value since it may introduce deviation
|
||||||
// error since we will apply the interpolation arithmetic.
|
// error since we will apply the interpolation arithmetic.
|
||||||
final float totalUsageTimeInMs =
|
final float totalUsageTimeInMs =
|
||||||
foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
foregroundUsageTimeInMs + backgroundUsageTimeInMs;
|
||||||
|
@@ -78,6 +78,6 @@ public class BatteryInfoLoaderTest {
|
|||||||
BatteryInfo info = loader.loadInBackground();
|
BatteryInfo info = loader.loadInBackground();
|
||||||
|
|
||||||
assertThat(info.remainingLabel).isNotNull();
|
assertThat(info.remainingLabel).isNotNull();
|
||||||
assertThat(info.remainingTimeUs).isEqualTo(TEST_TIME_REMAINING);
|
assertThat(info.remainingTimeUs).isEqualTo(TEST_TIME_REMAINING * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user