Merge "Call detect anomaly in period job only when there is new battery usage data." into udc-qpr-dev

This commit is contained in:
Treehugger Robot
2023-09-20 11:01:27 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 17 deletions

View File

@@ -53,7 +53,6 @@ public class LowBatteryDetectorTest {
mPolicy = spy(new BatteryTipPolicy(RuntimeEnvironment.application));
mContext = RuntimeEnvironment.application;
ReflectionHelpers.setField(mPolicy, "lowBatteryEnabled", true);
ReflectionHelpers.setField(mPolicy, "lowBatteryHour", 3);
mBatteryInfo.discharging = true;
mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo,
@@ -78,13 +77,9 @@ public class LowBatteryDetectorTest {
@Test
public void testDetect_lowBattery_tipNew() {
mBatteryInfo.batteryLevel = 3;
mBatteryInfo.batteryLevel = 20;
mBatteryInfo.remainingTimeUs = TimeUnit.DAYS.toMillis(1);
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.NEW);
mBatteryInfo.batteryLevel = 50;
mBatteryInfo.remainingTimeUs = TimeUnit.MINUTES.toMillis(1);
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.NEW);
}
@Test
@@ -104,9 +99,9 @@ public class LowBatteryDetectorTest {
}
@Test
public void testDetect_timeEstimationZero_tipInvisible() {
public void testDetect_lowTimeEstimation_tipInvisible() {
mBatteryInfo.batteryLevel = 50;
mBatteryInfo.remainingTimeUs = 0;
mBatteryInfo.remainingTimeUs = TimeUnit.MINUTES.toMillis(1);
assertThat(mLowBatteryDetector.detect().isVisible()).isFalse();
}