From 27a0274d6eb93d2845a32756d239127c394370d3 Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Fri, 17 Dec 2021 05:13:02 +0800 Subject: [PATCH] Add test case - forceUpdate_deviceIsSubDevice_doNothing Bug: 201472540 Test: make RunSettingsRoboTests ROBOTEST_FILTER=SavedBluetoothDeviceUpdaterTest Change-Id: I1aef6429b39109a09931a94b61f15e9470de3854 --- .../SavedBluetoothDeviceUpdaterTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java index 78a7a69a2b8..da7516b1fab 100644 --- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java +++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java @@ -250,4 +250,22 @@ public class SavedBluetoothDeviceUpdaterTest { verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT); } + + @Test + public void forceUpdate_deviceIsSubDevice_doesNothing() { + final List 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); + } }