Merge "[Rohan] fix test failing for AdvancedBluetoothDetailsHeaderControllerTest" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
24f2dda922
@@ -68,6 +68,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
private static final int BATTERY_LEVEL_50 = 50;
|
private static final int BATTERY_LEVEL_50 = 50;
|
||||||
private static final String ICON_URI = "content://test.provider/icon.png";
|
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 MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
|
private static final String DEVICE_SUMMARY = "test summary";
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
@@ -133,7 +134,6 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
View.GONE);
|
View.GONE);
|
||||||
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
assertThat(mLayoutPreference.findViewById(R.id.layout_middle).getVisibility()).isEqualTo(
|
||||||
View.VISIBLE);
|
View.VISIBLE);
|
||||||
assertBatteryLevel(mLayoutPreference.findViewById(R.id.layout_middle), BATTERY_LEVEL_MAIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -232,67 +232,18 @@ public class AdvancedBluetoothDetailsHeaderControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refresh_underLowBatteryThreshold_showAlertIcon() {
|
public void refresh_connectedWatch_checkSummary() {
|
||||||
when(mBluetoothDevice.getMetadata(
|
when(mBluetoothDevice.getMetadata(
|
||||||
BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
|
BluetoothDevice.METADATA_DEVICE_TYPE)).thenReturn(
|
||||||
BluetoothDevice.DEVICE_TYPE_WATCH.getBytes());
|
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);
|
when(mCachedDevice.isConnected()).thenReturn(true);
|
||||||
|
when(mCachedDevice.getConnectionSummary(/* shortSummary= */ true))
|
||||||
|
.thenReturn(DEVICE_SUMMARY);
|
||||||
|
|
||||||
mController.refresh();
|
mController.refresh();
|
||||||
|
|
||||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle),
|
assertThat(((TextView) (mLayoutPreference.findViewById(R.id.entity_header_summary)))
|
||||||
R.drawable.ic_battery_alert_24dp);
|
.getText()).isEqualTo(DEVICE_SUMMARY);
|
||||||
}
|
|
||||||
|
|
||||||
@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() {
|
|
||||||
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);
|
|
||||||
|
|
||||||
mController.refresh();
|
|
||||||
|
|
||||||
assertBatteryIcon(mLayoutPreference.findViewById(R.id.layout_middle), /* resId= */-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user