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

Commit a2208c00 authored by jackqdyulei's avatar jackqdyulei
Browse files

Fix broken bluetooth robo tests

Bug: 129159331
Test: RunSettingsRoboTests
Change-Id: I3e64659e59fd9b2ac58bf697116e1ee34928a3cd
parent b4ae464e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
    private static final int BATTERY_LEVEL_LEFT = 25;
    private static final int BATTERY_LEVEL_RIGHT = 45;
    private static final String ICON_URI = "content://test.provider/icon.png";
    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";

    private Context mContext;

@@ -83,6 +84,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
        mController.mLayoutPreference = mLayoutPreference;
        mController.mBluetoothAdapter = mBluetoothAdapter;
        when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
        when(mCachedDevice.getAddress()).thenReturn(MAC_ADDRESS);
    }

    @Test
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ import java.util.Collection;
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
        ShadowCachedBluetoothDeviceManager.class})
public class AvailableMediaBluetoothDeviceUpdaterTest {
    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";

    @Mock
    private DashboardFragment mDashboardFragment;
    @Mock
@@ -84,6 +86,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {

        doReturn(mContext).when(mDashboardFragment).getContext();
        when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
        when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);

        mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
                mDashboardFragment, mDevicePreferenceCallback));
+2 −12
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import org.robolectric.util.ReflectionHelpers;
@Config(shadows = {ShadowAlertDialogCompat.class})
public class BluetoothDevicePreferenceTest {
    private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";

    private Context mContext;
    @Mock
@@ -68,6 +69,7 @@ public class BluetoothDevicePreferenceTest {
        mContext = new ContextThemeWrapper(context, R.style.Theme_Settings);
        mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
        mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
        when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
                SHOW_DEVICES_WITHOUT_NAMES);
    }
@@ -163,18 +165,6 @@ public class BluetoothDevicePreferenceTest {
        assertThat(mPreference.shouldHideSecondTarget()).isFalse();
    }

    @Test
    public void imagingDeviceIcon_isICSettingsPrint() {
        when(mCachedBluetoothDevice.getBatteryLevel())
                .thenReturn(BluetoothDevice.BATTERY_LEVEL_UNKNOWN);
        when(mCachedBluetoothDevice.getBtClass())
                .thenReturn(new BluetoothClass(BluetoothClass.Device.Major.IMAGING));

        mPreference.onDeviceAttributesChanged();
        DrawableTestHelper.assertDrawableResId(mPreference.getIcon(),
            com.android.internal.R.drawable.ic_settings_print);
    }

    @Test
    public void testVisible_showDeviceWithoutNames_visible() {
        doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ import java.util.List;
@Config(shadows = {ShadowBluetoothAdapter.class})
public class BluetoothDeviceUpdaterTest {

    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
    private static final String SUB_MAC_ADDRESS = "05:52:C7:0B:D8:3C";

    @Mock
    private DashboardFragment mDashboardFragment;
    @Mock
@@ -93,6 +96,8 @@ public class BluetoothDeviceUpdaterTest {
        when(mSubCachedBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice);
        when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
        when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
        when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);

        mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
        mBluetoothDeviceUpdater =
+4 −0
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ import java.util.Collection;
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
        ShadowCachedBluetoothDeviceManager.class})
public class ConnectedBluetoothDeviceUpdaterTest {

    private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";

    @Mock
    private DashboardFragment mDashboardFragment;
    @Mock
@@ -84,6 +87,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
        mCachedDevices = new ArrayList<>();

        when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
        when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
        mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
        mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
                mDashboardFragment, mDevicePreferenceCallback));
Loading