Use another callback to notify the updater that UI should be updated
Replace onConnectionStateChanged callback with onProfileConnectionStateChanged. While updater is notified, isFilterMatched(cachedDevice) will decide whether to add/remove from UI based on audio profiles and audio mode. Bug: 76447449 Test: make RunSettingsRoboTests -j28 Change-Id: Icfba1ce2297e4638679158f9f99bae276940d885
This commit is contained in:
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_filterMatch_addPreference() {
|
||||
public void update_filterMatch_addPreference() {
|
||||
doReturn(BluetoothDevice.BOND_BONDED).when(mBluetoothDevice).getBondState();
|
||||
doReturn(false).when(mBluetoothDevice).isConnected();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_filterNotMatch_removePreference() {
|
||||
public void update_filterNotMatch_removePreference() {
|
||||
doReturn(BluetoothDevice.BOND_NONE).when(mBluetoothDevice).getBondState();
|
||||
doReturn(true).when(mBluetoothDevice).isConnected();
|
||||
|
||||
@@ -96,17 +96,17 @@ public class SavedBluetoothDeviceUpdaterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnConnectionStateChanged_deviceConnected_removePreference() {
|
||||
mBluetoothDeviceUpdater
|
||||
.onConnectionStateChanged(mCachedBluetoothDevice, BluetoothAdapter.STATE_CONNECTED);
|
||||
public void onProfileConnectionStateChanged_deviceConnected_removePreference() {
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.A2DP);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnConnectionStateChanged_deviceDisconnected_addPreference() {
|
||||
mBluetoothDeviceUpdater
|
||||
.onConnectionStateChanged(mCachedBluetoothDevice, BluetoothAdapter.STATE_DISCONNECTED);
|
||||
public void onProfileConnectionStateChanged_deviceDisconnected_addPreference() {
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
Reference in New Issue
Block a user