Device details LCR should be show up " ! " with low battery.
screenshot: https://screenshot.googleplex.com/f72YS3THutW.png https://screenshot.googleplex.com/v6uw7XsOs9x.png Bug: 151187813 Test: make -j42 RunSettingsRoboTests Change-Id: Iabb4ac54e6f827f54cd7c5512995f185875e4a06
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -58,6 +59,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
||||
private static final int BATTERY_LEVEL_MAIN = 30;
|
||||
private static final int BATTERY_LEVEL_LEFT = 25;
|
||||
private static final int BATTERY_LEVEL_RIGHT = 45;
|
||||
private static final int LOW_BATTERY_LEVEL = 5;
|
||||
private static final String ICON_URI = "content://test.provider/icon.png";
|
||||
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||
|
||||
@@ -115,6 +117,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY)).thenReturn(
|
||||
String.valueOf(BATTERY_LEVEL_MAIN).getBytes());
|
||||
|
||||
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||
mController.refresh();
|
||||
|
||||
@@ -143,6 +146,36 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
||||
assertThat(layout.findViewById(R.id.header_icon).getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refresh_withLowBatteryAndUncharged_showAlertIcon() {
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_LEFT_BATTERY)).thenReturn(
|
||||
String.valueOf(LOW_BATTERY_LEVEL).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_RIGHT_BATTERY)).thenReturn(
|
||||
String.valueOf(LOW_BATTERY_LEVEL).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_CASE_BATTERY)).thenReturn(
|
||||
String.valueOf(BATTERY_LEVEL_MAIN).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_LEFT_CHARGING)).thenReturn(
|
||||
String.valueOf(false).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_RIGHT_CHARGING)).thenReturn(
|
||||
String.valueOf(true).getBytes());
|
||||
when(mBluetoothDevice.getMetadata(
|
||||
BluetoothDevice.METADATA_UNTETHERED_CASE_CHARGING)).thenReturn(
|
||||
String.valueOf(false).getBytes());
|
||||
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||
|
||||
mController.refresh();
|
||||
|
||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_left),
|
||||
R.drawable.ic_battery_alert_24dp);
|
||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_right), /* resId= */-1);
|
||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */ -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_untetheredHeadsetWithConfigOn_returnAvailable() {
|
||||
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
@@ -256,4 +289,10 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
||||
com.android.settings.Utils.formatPercentage(batteryLevel));
|
||||
}
|
||||
|
||||
private void assertBatteryIcon(LinearLayout linearLayout, int resId) {
|
||||
final ImageView imageView = linearLayout.findViewById(R.id.bt_battery_icon);
|
||||
assertThat(shadowOf(imageView.getDrawable()).getCreatedFromResId())
|
||||
.isEqualTo(resId);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user