Add test case - forceUpdate_deviceIsSubDevice_doNothing

Bug: 201472540
Test: make RunSettingsRoboTests ROBOTEST_FILTER=SavedBluetoothDeviceUpdaterTest
Change-Id: I1aef6429b39109a09931a94b61f15e9470de3854
This commit is contained in:
Alice Kuo
2021-12-17 05:13:02 +08:00
parent bb994f627f
commit 27a0274d6e

View File

@@ -250,4 +250,22 @@ public class SavedBluetoothDeviceUpdaterTest {
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
@Test
public void forceUpdate_deviceIsSubDevice_doesNothing() {
final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
bluetoothDevices.add(mBluetoothDevice);
when(mBluetoothAdapter.isEnabled()).thenReturn(true);
when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
when(mDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
mBluetoothDeviceUpdater.forceUpdate();
verify(mBluetoothDeviceUpdater, never()).removePreference(mCachedBluetoothDevice);
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice,
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
}