Show device in Media devices section if has LEA member connected
Test: atest Bug: 396009828 Flag: EXEMPT simple fix Change-Id: Icc6bd1c4fa7cf3c43eec1c4c950fbf778975f803
This commit is contained in:
@@ -282,6 +282,28 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void
|
||||
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallFlagOff_addPref() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
|
||||
.thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mBroadcastReceiveState));
|
||||
List<Long> bisSyncState = new ArrayList<>();
|
||||
bisSyncState.add(1L);
|
||||
when(mBroadcastReceiveState.getBisSyncState()).thenReturn(bisSyncState);
|
||||
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaConnected_notInCallNotInSharing_addPref() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
@@ -299,6 +321,25 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void
|
||||
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallNotInSharing_addPref() {
|
||||
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
|
||||
.thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
|
||||
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaConnected_inCallSharingFlagOff_addPref() {
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
|
@@ -272,6 +272,20 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hasLeaMemberConnected_inCall_removesPreference() {
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_IN_CALL);
|
||||
when(mBluetoothDeviceUpdater
|
||||
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
|
||||
{
|
||||
@@ -285,6 +299,22 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
||||
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void
|
||||
onProfileConnectionStateChanged_hasLeaMemberConnected_notInCall_removesPreference() {
|
||||
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
|
||||
when(mBluetoothDeviceUpdater
|
||||
.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
|
||||
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
|
||||
|
||||
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovesPreference()
|
||||
{
|
||||
|
@@ -153,6 +153,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -172,6 +177,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaConnected_flagOff_hysteresisMode_removesPref() {
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -191,6 +201,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaConnected_noSource_removesPref() {
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -210,6 +225,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaConnected_noSource_hysteresisMode_removesPref() {
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -229,6 +249,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mCachedDevices.clear();
|
||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||
@@ -249,6 +274,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_deviceIsNotInList_hysteresisMode_removesPref() {
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mCachedDevices.clear();
|
||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||
@@ -269,6 +299,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDisconnected_removesPref() {
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -288,6 +323,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDisconnected_hysteresisMode_removesPref() {
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -307,6 +347,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDisconnecting_removesPref() {
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
|
||||
@@ -325,6 +370,11 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDisconnecting_hysteresisMode_removesPref() {
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
|
||||
@@ -344,6 +394,29 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
public void onProfileConnectionStateChanged_leaConnected_hasSource_addsPref() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice(false);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||
assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
|
||||
.isEqualTo(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPref() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice(false);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||
@@ -355,6 +428,30 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
public void onProfileConnectionStateChanged_leaConnected_hasSource_hysteresisMode_addsPref() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||
assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
|
||||
.isEqualTo(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void
|
||||
onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_hysteresis_addsPref() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
|
||||
@@ -397,10 +494,5 @@ public class AudioSharingBluetoothDeviceUpdaterTest {
|
||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
doReturn(true).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
}
|
||||
}
|
||||
|
@@ -127,6 +127,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mBroadcast.isEnabled(null)).thenReturn(false);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -146,6 +151,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceConnected_noSource_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -165,6 +175,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
mCachedDevices.clear();
|
||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||
@@ -185,6 +200,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceDisconnected_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -204,6 +224,11 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_leaDeviceDisconnecting_removesPref() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
@@ -224,6 +249,29 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
public void onProfileConnectionStateChanged_leaDeviceConnected_hasSource_addsPreference() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
|
||||
assertThat(((AudioSharingDeviceVolumePreference) captor.getValue()).getCachedDevice())
|
||||
.isEqualTo(mCachedBluetoothDevice);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPreference() {
|
||||
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
|
||||
setupPreferenceMapWithDevice();
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
|
||||
when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
|
||||
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
|
||||
@@ -262,6 +310,12 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
@Test
|
||||
public void refreshPreference_doNothing() {
|
||||
setupPreferenceMapWithDevice();
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
|
||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(ImmutableList.of());
|
||||
mDeviceUpdater.refreshPreference();
|
||||
@@ -276,10 +330,5 @@ public class AudioSharingDeviceVolumeControlUpdaterTest {
|
||||
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
|
||||
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
|
||||
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
|
||||
mDeviceUpdater.onProfileConnectionStateChanged(
|
||||
mCachedBluetoothDevice,
|
||||
BluetoothProfile.STATE_CONNECTED,
|
||||
BluetoothProfile.LE_AUDIO);
|
||||
shadowOf(Looper.getMainLooper()).idle();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user