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

Commit 24f2dda9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Rohan] fix test failing for AdvancedBluetoothDetailsHeaderControllerTest" into sc-dev

parents 56713ae0 4d41945d
Loading
Loading
Loading
Loading
+6 −55
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
    private static final int BATTERY_LEVEL_50 = 50;
    private static final String ICON_URI = "content://test.provider/icon.png";
    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
    private static final String DEVICE_SUMMARY = "test summary";

    private Context mContext;

@@ -133,7 +134,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
                View.GONE);
        assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
                View.VISIBLE);
        assertBatteryLevel(mLayoutPreference.findViewById(R.id.layout_middle), BATTERY_LEVEL_MAIN);
    }

    @Test
@@ -232,67 +232,18 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
    }

    @Test
    public void refresh_underLowBatteryThreshold_showAlertIcon() {
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
                BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
                String.valueOf(BATTERY_LEVEL_5).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
                String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
                String.valueOf(false).getBytes());
        when(mCachedDevice.isConnected()).thenReturn(true);

        mController.refresh();

        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
                R.drawable.ic_battery_alert_24dp);
    }

    @Test
    public void refresh_underLowBatteryThresholdInCharging_showAlertIcon() {
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
                BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
                String.valueOf(BATTERY_LEVEL_5).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
                String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
                String.valueOf(true).getBytes());
        when(mCachedDevice.isConnected()).thenReturn(true);

        mController.refresh();

        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */-1);
    }

    @Test
    public void refresh_aboveLowBatteryThreshold_noAlertIcon() {
    public void refresh_connectedWatch_checkSummary() {
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
                BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_BATTERY)).thenReturn(
                String.valueOf(BATTERY_LEVEL_50).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_LOW_BATTERY_THRESHOLD)).thenReturn(
                String.valueOf(LOW_BATTERY_LEVEL_THRESHOLD).getBytes());
        when(mBluetoothDevice.getMetadata(
                BluetoothDevice.METADATA_MAIN_CHARGING)).thenReturn(
                String.valueOf(false).getBytes());
        when(mCachedDevice.isConnected()).thenReturn(true);
        when(mCachedDevice.getConnectionSummary(/* shortSummary= */ true))
                .thenReturn(DEVICE_SUMMARY);

        mController.refresh();

        assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */-1);
        assertThat(((TextView) (mLayoutPreference.findViewById(R.id.entity_header_summary)))
                .getText()).isEqualTo(DEVICE_SUMMARY);
    }

    @Test