Merge "Update the flow of charging optimization strings." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
a71f46ecc6
@@ -286,8 +286,9 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
batteryInfo.pluggedStatus = BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(eq(mContext),
|
||||
any(BatteryInfo.class))).thenReturn(label);
|
||||
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(
|
||||
eq(mContext), any(BatteryInfo.class)))
|
||||
.thenReturn(label);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
|
||||
@@ -326,14 +327,64 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBatteryStatus_chargingOptimizationMode_remainingLabel() {
|
||||
var batteryInfo =
|
||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||
/* remainingLabel= */ "Expected remaining label",
|
||||
/* statusLabel= */ "Fast Charging",
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.remainingLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(true);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBatteryStatus_chargingOptimizationModeNoRemainingLabel_statusLabel() {
|
||||
var batteryInfo =
|
||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||
/* remainingLabel= */ null,
|
||||
/* statusLabel= */ "Fast Charging",
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.statusLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(true);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBatteryStatus_notChargingOptimizationMode_statusWithRemainingLabel() {
|
||||
var batteryInfo =
|
||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||
/* remainingLabel= */ "Full by 1:30 PM",
|
||||
/* statusLabel= */ "Fast Charging",
|
||||
/* isFastCharging= */ true,
|
||||
/* isChargingStringV2= */ true);
|
||||
var expectedChargingString = batteryInfo.statusLabel + " • " + batteryInfo.remainingLabel;
|
||||
when(mFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(false);
|
||||
|
||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||
}
|
||||
|
||||
private BatteryInfo arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||
String remainingLabel,
|
||||
String statusLabel,
|
||||
boolean isFastCharging,
|
||||
boolean isChargingStringV2) {
|
||||
SystemProperties.set(
|
||||
BatteryUtils.PROPERTY_CHARGING_STRING_V2_KEY,
|
||||
String.valueOf(isChargingStringV2));
|
||||
BatteryUtils.PROPERTY_CHARGING_STRING_V2_KEY, String.valueOf(isChargingStringV2));
|
||||
mBatteryInfo.isBatteryDefender = false;
|
||||
mBatteryInfo.remainingLabel = remainingLabel;
|
||||
mBatteryInfo.statusLabel = statusLabel;
|
||||
@@ -389,8 +440,11 @@ public class BatteryHeaderPreferenceControllerTest {
|
||||
|
||||
mController.updateHeaderPreference(mBatteryInfo);
|
||||
|
||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(mContext.getString(
|
||||
com.android.settingslib.R.string.battery_info_status_charging_on_hold));
|
||||
verify(mBatteryUsageProgressBarPref)
|
||||
.setBottomSummary(
|
||||
mContext.getString(
|
||||
com.android.settingslib.R.string
|
||||
.battery_info_status_charging_on_hold));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -724,15 +724,15 @@ public class BatteryInfoTest {
|
||||
Intent batteryIntent =
|
||||
createIntentForGetBatteryInfoTest(
|
||||
ChargingType.WIRED, ChargingSpeed.REGULAR, /* batteryLevel= */ 65);
|
||||
var expectedRemainingLabel = "Done charging by";
|
||||
var expectedRemainingLabel = "Expected remaining label";
|
||||
var expectedChargeLabel = "65% - " + expectedRemainingLabel;
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.isChargingOptimizationMode(mContext))
|
||||
.thenReturn(true);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationRemainingLabel(
|
||||
eq(mContext), anyLong(), anyLong()))
|
||||
eq(mContext), anyInt(), anyInt(), anyLong(), anyLong()))
|
||||
.thenReturn(expectedRemainingLabel);
|
||||
when(mFeatureFactory.batterySettingsFeatureProvider.getChargingOptimizationChargeLabel(
|
||||
eq(mContext), anyString(), anyLong(), anyLong()))
|
||||
eq(mContext), anyInt(), anyString(), anyLong(), anyLong()))
|
||||
.thenReturn(expectedChargeLabel);
|
||||
var expectedStatusLabel = "Charging";
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.BatteryManager;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
@@ -87,12 +88,15 @@ public class BatterySettingsFeatureProviderImplTest {
|
||||
|
||||
@Test
|
||||
public void getChargingOptimizationRemainingLabel_default_returnNull() {
|
||||
assertThat(mImpl.getChargingOptimizationRemainingLabel(mContext, 1000L, 1000L)).isNull();
|
||||
assertThat(
|
||||
mImpl.getChargingOptimizationRemainingLabel(
|
||||
mContext, 75, BatteryManager.BATTERY_PLUGGED_AC, 1000L, 1000L))
|
||||
.isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChargingOptimizationChargeLabel_default_returnNull() {
|
||||
assertThat(mImpl.getChargingOptimizationChargeLabel(mContext, "70%", 1000L, 1000L))
|
||||
assertThat(mImpl.getChargingOptimizationChargeLabel(mContext, 70, "70%", 1000L, 1000L))
|
||||
.isNull();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user