Make HearingAid code more generic
-handle UI updating when sub device connection state changes -add test case Bug: 112735753 Test: make -j42 RunSettingsRoboTests Change-Id: Ie2643657c47a0956aac3f8cac4bfdbdea0399ce8
This commit is contained in:
@@ -63,8 +63,12 @@ public class BluetoothDeviceUpdaterTest {
|
||||
@Mock
|
||||
private CachedBluetoothDevice mCachedBluetoothDevice;
|
||||
@Mock
|
||||
private CachedBluetoothDevice mSubCachedBluetoothDevice;
|
||||
@Mock
|
||||
private BluetoothDevice mBluetoothDevice;
|
||||
@Mock
|
||||
private BluetoothDevice mSubBluetoothDevice;
|
||||
@Mock
|
||||
private SettingsActivity mSettingsActivity;
|
||||
@Mock
|
||||
private LocalBluetoothManager mLocalManager;
|
||||
@@ -86,6 +90,7 @@ public class BluetoothDeviceUpdaterTest {
|
||||
mCachedDevices.add(mCachedBluetoothDevice);
|
||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||
when(mSubCachedBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice);
|
||||
when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
|
||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||
|
||||
@@ -146,6 +151,20 @@ public class BluetoothDeviceUpdaterTest {
|
||||
verify(mDevicePreferenceCallback, never()).onDeviceRemoved(any(Preference.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovePreference_subDeviceExist_removePreference() {
|
||||
when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mSubCachedBluetoothDevice);
|
||||
mBluetoothDeviceUpdater.mPreferenceMap.put(mSubBluetoothDevice, mPreference);
|
||||
|
||||
assertThat(mBluetoothDeviceUpdater.mPreferenceMap.
|
||||
containsKey(mSubBluetoothDevice)).isTrue();
|
||||
mBluetoothDeviceUpdater.removePreference(mCachedBluetoothDevice);
|
||||
|
||||
verify(mDevicePreferenceCallback).onDeviceRemoved(mPreference);
|
||||
assertThat(mBluetoothDeviceUpdater.mPreferenceMap.
|
||||
containsKey(mSubBluetoothDevice)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeviceProfilesListener_click_startBluetoothDeviceDetailPage() {
|
||||
doReturn(mSettingsActivity).when(mDashboardFragment).getContext();
|
||||
|
Reference in New Issue
Block a user