Fix the testcase error

The BluetoothDeviceUdater added the checking whether the item is in the
list. It caused this testcase failed.
Add more mocks for this testcase.

Bug: 237223797
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDevicesSliceTest
Change-Id: Idb746e42480f99846efb5d1e4d4a411a5a9ca296
Merged-In: Idb746e42480f99846efb5d1e4d4a411a5a9ca296
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index cbd4390..2d5a0e9 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -46,8 +46,10 @@
 import androidx.slice.widget.SliceLiveData;
 
 import com.android.settings.R;
+import com.android.settings.bluetooth.Utils;
 import com.android.settings.testutils.SliceTester;
 import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
+import com.android.settings.testutils.shadow.ShadowCachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
 
 import org.junit.After;
@@ -67,7 +69,7 @@
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowBluetoothAdapter.class)
+@Config(shadows = {ShadowBluetoothAdapter.class, ShadowCachedBluetoothDeviceManager.class})
 public class BluetoothDevicesSliceTest {
 
     private static final String BLUETOOTH_MOCK_ADDRESS = "00:11:00:11:00:11";
@@ -111,6 +113,9 @@
             mShadowBluetoothAdapter.setEnabled(true);
             mShadowBluetoothAdapter.setState(BluetoothAdapter.STATE_ON);
         }
+        final ShadowCachedBluetoothDeviceManager shadowCachedBluetoothDeviceManager =
+                Shadow.extract(Utils.getLocalBtManager(mContext).getCachedDeviceManager());
+        shadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mBluetoothDeviceList);
     }
 
     @After