Fix BluetoothDevicesSlice doesn't appear issue.
In Settings cold launch, it took a little bit time to do Bluetooth profile service connection. If we get the Bluetooth device connected state before service connected, the return value will always false. This behavior caused BluetoothDevicesSlice can't collect media devices immediately in cold launch, therefore, no data to build this card. According latest discussion, this card is used for all Bluetooth devices, so we don't need to wait profile to get specific devices. Hence, update design to show all connected Bluetooth devices and keep the operations are the same with Settings > Connected devices. Fixes: 124462139 Test: visual, robotests Change-Id: I1418e09f2cdc7ea8beaa73d7a59440ee2baae63b
This commit is contained in:
@@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -83,7 +84,7 @@ public class BluetoothDevicesSliceTest {
|
||||
|
||||
// Mock the icon and detail intent of Bluetooth.
|
||||
mIcon = IconCompat.createWithResource(mContext,
|
||||
com.android.internal.R.drawable.ic_settings_bluetooth);
|
||||
com.android.internal.R.drawable.ic_settings_bluetooth);
|
||||
mDetailIntent = PendingIntent.getActivity(mContext, 0, new Intent("test action"), 0);
|
||||
doReturn(mIcon).when(mBluetoothDevicesSlice).getBluetoothDeviceIcon(any());
|
||||
doReturn(mDetailIntent).when(mBluetoothDevicesSlice).getBluetoothDetailIntent(any());
|
||||
@@ -121,6 +122,27 @@ public class BluetoothDevicesSliceTest {
|
||||
SliceTester.assertAnySliceItemContainsTitle(sliceItems, BLUETOOTH_MOCK_TITLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_hasMediaBluetoothDevice_shouldBuildMediaBluetoothAction() {
|
||||
mockBluetoothDeviceList(1 /* deviceCount */);
|
||||
doReturn(true).when(mBluetoothDeviceList.get(0)).isConnectedA2dpDevice();
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
|
||||
mBluetoothDevicesSlice.getSlice();
|
||||
|
||||
verify(mBluetoothDevicesSlice).buildMediaBluetoothAction(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_noMediaBluetoothDevice_shouldNotBuildMediaBluetoothAction() {
|
||||
mockBluetoothDeviceList(1 /* deviceCount */);
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
|
||||
mBluetoothDevicesSlice.getSlice();
|
||||
|
||||
verify(mBluetoothDevicesSlice, never()).buildMediaBluetoothAction(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
|
||||
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
|
||||
@@ -175,7 +197,6 @@ public class BluetoothDevicesSliceTest {
|
||||
doReturn(BLUETOOTH_MOCK_TITLE).when(mCachedBluetoothDevice).getName();
|
||||
doReturn(BLUETOOTH_MOCK_SUMMARY).when(mCachedBluetoothDevice).getConnectionSummary();
|
||||
doReturn(BLUETOOTH_MOCK_ADDRESS).when(mCachedBluetoothDevice).getAddress();
|
||||
doReturn(true).when(mCachedBluetoothDevice).isConnectedA2dpDevice();
|
||||
for (int i = 0; i < deviceCount; i++) {
|
||||
mBluetoothDeviceList.add(mCachedBluetoothDevice);
|
||||
}
|
||||
|
Reference in New Issue
Block a user