Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db53d1c6 authored by Hugh Chen's avatar Hugh Chen
Browse files

Fix borken test on Bluetooth and connected package

Bug: 187239965
Test: make RunSettingsRoboTests -j56
Change-Id: Ic0d60a6cd46b1211efb2021f079c0b0a6534b383
parent 9246f6f8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -61,9 +61,10 @@ public class UsbDefaultFragment extends RadioButtonPickerFragment {
    long mCurrentFunctions;
    @VisibleForTesting
    boolean mIsStartTethering = false;
    @VisibleForTesting
    Handler mHandler;

    private UsbConnectionBroadcastReceiver mUsbReceiver;
    private Handler mHandler;
    private boolean mIsConnected = false;

    @VisibleForTesting
+6 −0
Original line number Diff line number Diff line
@@ -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));
+6 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.Pair;

import androidx.preference.Preference;

@@ -78,6 +80,8 @@ public class BluetoothDeviceUpdaterTest {
    private LocalBluetoothManager mLocalManager;
    @Mock
    private CachedBluetoothDeviceManager mCachedDeviceManager;
    @Mock
    private Drawable mDrawable;

    private Context mContext;
    private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -89,6 +93,7 @@ public class BluetoothDeviceUpdaterTest {
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
        mContext = RuntimeEnvironment.application;
        mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
        mCachedDevices.add(mCachedBluetoothDevice);
@@ -99,6 +104,7 @@ public class BluetoothDeviceUpdaterTest {
        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
        when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
        when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);
        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);

        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
                false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+7 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.util.Pair;

import androidx.preference.PreferenceGroup;

@@ -70,6 +72,9 @@ public class BluetoothPairingDetailTest {
    private PreferenceGroup mPreferenceGroup;
    @Mock
    private CachedBluetoothDevice mCachedBluetoothDevice;
    @Mock
    private Drawable mDrawable;

    private BluetoothPairingDetail mFragment;
    private Context mContext;
    private BluetoothProgressCategory mAvailableDevicesCategory;
@@ -82,11 +87,13 @@ public class BluetoothPairingDetailTest {
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
        mContext = RuntimeEnvironment.application;
        mFragment = spy(new BluetoothPairingDetail());
        doReturn(mContext).when(mFragment).getContext();
        doReturn(mResource).when(mFragment).getResources();
        when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS);
        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);

        mAvailableDevicesCategory = spy(new BluetoothProgressCategory(mContext));
        mFooterPreference = new FooterPreference(mContext);
+6 −0
Original line number Diff line number Diff line
@@ -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));
Loading