Merge "Fix inconsistent connected without charging state in the Settings" into udc-qpr-dev

This commit is contained in:
YK Hung
2023-07-28 05:53:16 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ import android.content.Intent;
import android.hardware.usb.UsbManager;
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
import android.os.BatteryManager;
import androidx.preference.Preference;
import androidx.test.core.app.ApplicationProvider;
@@ -145,6 +146,17 @@ public class TopLevelBatteryPreferenceControllerTest {
.isEqualTo(mContext.getString(R.string.battery_info_status_not_charging));
}
@Test
public void getDashboardLabel_notChargingState_returnsCorrectLabel() {
mController.mPreference = new Preference(mContext);
BatteryInfo info = new BatteryInfo();
info.batteryStatus = BatteryManager.BATTERY_STATUS_NOT_CHARGING;
info.statusLabel = "expected returned label";
assertThat(mController.getDashboardLabel(mContext, info, true))
.isEqualTo(info.statusLabel);
}
@Test
public void getSummary_batteryNotPresent_shouldShowWarningMessage() {
mController.mIsBatteryPresent = false;