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

@@ -28,7 +28,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;
@@ -65,6 +67,8 @@ public class ConnectedBluetoothDeviceUpdaterTest {
private CachedBluetoothDevice mCachedBluetoothDevice;
@Mock
private BluetoothDevice mBluetoothDevice;
@Mock
private Drawable mDrawable;
private Context mContext;
private ConnectedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -77,6 +81,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
public void setUp() {
MockitoAnnotations.initMocks(this);
Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
mContext = RuntimeEnvironment.application;
mAudioManager = mContext.getSystemService(AudioManager.class);
mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
@@ -88,6 +93,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
mDashboardFragment, mDevicePreferenceCallback));