Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d0a7f14 authored by Zhenwei Chen's avatar Zhenwei Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix batteryInfo unit test"

parents 4131877e 54615b3b
Loading
Loading
Loading
Loading
+3 −6
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ public class BatteryInfoTest {
    private static final String STATUS_CHARGING_TIME = "50% - 0 min left until full";
    private static final String STATUS_CHARGING_TIME = "50% - 0 min left until full";
    private static final String STATUS_NOT_CHARGING = "Not charging";
    private static final String STATUS_NOT_CHARGING = "Not charging";
    private static final String STATUS_CHARGING_FUTURE_BYPASS = "50% - Charging to 12%";
    private static final String STATUS_CHARGING_FUTURE_BYPASS = "50% - Charging to 12%";
    private static final String STATUS_CHARGING_PAUSED = "50% - Charging paused";
    private static final long REMAINING_TIME_NULL = -1;
    private static final long REMAINING_TIME_NULL = -1;
    private static final long REMAINING_TIME = 2;
    private static final long REMAINING_TIME = 2;
    // Strings are defined in frameworks/base/packages/SettingsLib/res/values/strings.xml
    // Strings are defined in frameworks/base/packages/SettingsLib/res/values/strings.xml
@@ -256,8 +257,6 @@ public class BatteryInfoTest {


    @Test
    @Test
    public void testGetBatteryInfo_chargingWithOverheated_updateChargeLabel() {
    public void testGetBatteryInfo_chargingWithOverheated_updateChargeLabel() {
        final String expectedString =
                mContext.getString(R.string.battery_tip_limited_temporarily_title);
        doReturn(TEST_CHARGE_TIME_REMAINING)
        doReturn(TEST_CHARGE_TIME_REMAINING)
                .when(mBatteryUsageStats)
                .when(mBatteryUsageStats)
                .getChargeTimeRemainingMs();
                .getChargeTimeRemainingMs();
@@ -269,13 +268,11 @@ public class BatteryInfoTest {
                false /* shortString */);
                false /* shortString */);


        assertThat(info.isOverheated).isTrue();
        assertThat(info.isOverheated).isTrue();
        assertThat(info.chargeLabel.toString()).contains(expectedString);
        assertThat(info.chargeLabel.toString()).contains(STATUS_CHARGING_PAUSED);
    }
    }


    @Test
    @Test
    public void testGetBatteryInfo_dockDefenderActive_updateChargeString() {
    public void testGetBatteryInfo_dockDefenderActive_updateChargeString() {
        final String expectedString =
                mContext.getString(R.string.battery_tip_limited_temporarily_title);
        doReturn(TEST_CHARGE_TIME_REMAINING / 1000)
        doReturn(TEST_CHARGE_TIME_REMAINING / 1000)
                .when(mBatteryUsageStats).getChargeTimeRemainingMs();
                .when(mBatteryUsageStats).getChargeTimeRemainingMs();
        doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isExtraDefend();
        doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isExtraDefend();
@@ -289,7 +286,7 @@ public class BatteryInfoTest {
                mBatteryUsageStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
                mBatteryUsageStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
                false /* shortString */);
                false /* shortString */);


        assertThat(info.chargeLabel.toString()).contains(expectedString);
        assertThat(info.chargeLabel.toString()).contains(STATUS_CHARGING_PAUSED);
    }
    }


    @Test
    @Test