Support incompatible charger state in the battery main page

https://screenshot.googleplex.com/PrSzAtMAhsyqbsR

Bug: 271775549
Test: make test RunSettingsRoboTests
Change-Id: I0bb912eaab9c8837eaa3a9b998b3ebb5a8e6f99f
This commit is contained in:
ykhung
2023-05-03 18:03:59 +08:00
parent 6a2f6960ab
commit c234196bc1
5 changed files with 58 additions and 22 deletions

View File

@@ -36,6 +36,7 @@ import androidx.preference.Preference;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.BatteryTestUtils;
import org.junit.Before;
import org.junit.Ignore;
@@ -136,7 +137,7 @@ public class TopLevelBatteryPreferenceControllerTest {
@Test
public void getDashboardLabel_incompatibleCharger_returnsCorrectLabel() {
setupIncompatibleEvent();
BatteryTestUtils.setupIncompatibleEvent(mUsbPort, mUsbManager, mUsbPortStatus);
mController.mPreference = new Preference(mContext);
BatteryInfo info = new BatteryInfo();
@@ -150,14 +151,4 @@ public class TopLevelBatteryPreferenceControllerTest {
assertThat(mController.getSummary())
.isEqualTo(mContext.getString(R.string.battery_missing_message));
}
private void setupIncompatibleEvent() {
final List<UsbPort> usbPorts = new ArrayList<>();
usbPorts.add(mUsbPort);
when(mUsbManager.getPorts()).thenReturn(usbPorts);
when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
when(mUsbPort.supportsComplianceWarnings()).thenReturn(true);
when(mUsbPortStatus.isConnected()).thenReturn(true);
when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
}
}