Fix borken test on Bluetooth and connected package

Bug: 187239965
Test: make RunSettingsRoboTests -j56
Change-Id: Ic0d60a6cd46b1211efb2021f079c0b0a6534b383
This commit is contained in:
Hugh Chen
2021-05-05 14:31:01 +08:00
parent 9246f6f8b0
commit db53d1c6f8
8 changed files with 47 additions and 1 deletions

View File

@@ -26,7 +26,9 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.util.Pair;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
@@ -62,6 +64,8 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
private CachedBluetoothDevice mCachedBluetoothDevice;
@Mock
private BluetoothDevice mBluetoothDevice;
@Mock
private Drawable mDrawable;
private Context mContext;
private AvailableMediaBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -83,10 +87,12 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
Utils.getLocalBtManager(mContext).getCachedDeviceManager());
mCachedDevices = new ArrayList<>();
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
doReturn(mContext).when(mDashboardFragment).getContext();
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
mDashboardFragment, mDevicePreferenceCallback));