Merge "Try select preset independently after group operation failed" into main

This commit is contained in:
Angela Wang
2024-04-11 01:04:51 +00:00
committed by Android (Google) Code Review
2 changed files with 76 additions and 40 deletions

View File

@@ -87,6 +87,7 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends
when(mLocalManager.getProfileManager()).thenReturn(mProfileManager);
when(mProfileManager.getHapClientProfile()).thenReturn(mHapClientProfile);
when(mCachedDevice.getDevice()).thenReturn(mDevice);
when(mCachedDevice.getProfiles()).thenReturn(List.of(mHapClientProfile));
when(mCachedDevice.isConnectedHapClientDevice()).thenReturn(true);
when(mCachedChildDevice.getDevice()).thenReturn(mChildDevice);
@@ -251,6 +252,16 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends
assertThat(mController.getPreference().getSummary()).isNotNull();
}
@Test
public void onPresetSelectionForGroupFailed_selectPresetIsCalled() {
when(mHapClientProfile.getHapGroup(mDevice)).thenReturn(TEST_HAP_GROUP_ID);
mController.getPreference().setValue(String.valueOf(TEST_PRESET_INDEX));
mController.onPresetSelectionForGroupFailed(TEST_HAP_GROUP_ID, TEST_PRESET_INDEX);
verify(mHapClientProfile).selectPreset(mDevice, TEST_PRESET_INDEX);
}
private BluetoothHapPresetInfo getTestPresetInfo() {
BluetoothHapPresetInfo info = mock(BluetoothHapPresetInfo.class);
when(info.getName()).thenReturn(TEST_PRESET_NAME);