Use enhanced estimate battery info when available
This CL updates the battery page to get the updated strings and other relevant battery info from directly from SettingsLib by providing it an overrided drain time instead of manually changing the value in the returned info. This will provide the added benefit of using the new strings when appropriate that tell the user that the estimate provided is based on their usage. Test: robotests Bug: 38399659 Change-Id: I0db572c2ea78910756314b6bf066d37e9f90a15c
This commit is contained in:
@@ -489,41 +489,6 @@ public class PowerUsageSummaryTest {
|
||||
assertThat(mFragment.mAnomalySparseArray.get(UID_2)).containsExactly(anomaly3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUseEnhancedEstimateIfAvailable() {
|
||||
// mock out the provider
|
||||
final long time = 60 * 1000 * 1000;
|
||||
PowerUsageFeatureProvider provider = mFeatureFactory.getPowerUsageFeatureProvider(mContext);
|
||||
when(provider.isEnhancedBatteryPredictionEnabled(any())).thenReturn(true);
|
||||
mFragment.mPowerFeatureProvider = provider;
|
||||
mFragment.mEnhancedEstimate = time;
|
||||
|
||||
mFragment.useEnhancedEstimateIfAvailable(mRealContext, mBatteryInfo);
|
||||
|
||||
// The string that gets returned always has weird whitespacing to make it fit
|
||||
// so we're just going to check that it contains the correct value we care about.
|
||||
assertThat(mBatteryInfo.remainingTimeUs).isEqualTo(time);
|
||||
assertThat(mBatteryInfo.remainingLabel).contains("About 17 hrs");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUseEnhancedEstimateIfAvailable_noOpsOnDisabled() {
|
||||
// mock out the provider
|
||||
final long time = 60 * 1000 * 1000;
|
||||
PowerUsageFeatureProvider provider = mFeatureFactory.getPowerUsageFeatureProvider(mContext);
|
||||
when(provider.isEnhancedBatteryPredictionEnabled(any())).thenReturn(false);
|
||||
mFragment.mPowerFeatureProvider = provider;
|
||||
mFragment.mEnhancedEstimate = time;
|
||||
mBatteryInfo.remainingTimeUs = TIME_SINCE_LAST_FULL_CHARGE_US;
|
||||
mBatteryInfo.remainingLabel = TIME_LEFT;
|
||||
|
||||
mFragment.useEnhancedEstimateIfAvailable(mRealContext, mBatteryInfo);
|
||||
|
||||
// check to make sure the values did not change
|
||||
assertThat(mBatteryInfo.remainingTimeUs).isEqualTo(TIME_SINCE_LAST_FULL_CHARGE_US);
|
||||
assertThat(mBatteryInfo.remainingLabel).contains(TIME_LEFT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatteryPredictionLoaderCallbacks_DoesNotCrashOnNull() {
|
||||
// Sanity test to check for crash
|
||||
|
||||
Reference in New Issue
Block a user