Fix broken bluetooth robo tests
Bug: 129159331 Test: RunSettingsRoboTests Change-Id: I3e64659e59fd9b2ac58bf697116e1ee34928a3cd
This commit is contained in:
@@ -55,6 +55,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
|
|||||||
private static final int BATTERY_LEVEL_LEFT = 25;
|
private static final int BATTERY_LEVEL_LEFT = 25;
|
||||||
private static final int BATTERY_LEVEL_RIGHT = 45;
|
private static final int BATTERY_LEVEL_RIGHT = 45;
|
||||||
private static final String ICON_URI = "content://test.provider/icon.png";
|
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;
|
private Context mContext;
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ public class AdvancedBluetoothDetailsHeaderControllerTest{
|
|||||||
mController.mLayoutPreference = mLayoutPreference;
|
mController.mLayoutPreference = mLayoutPreference;
|
||||||
mController.mBluetoothAdapter = mBluetoothAdapter;
|
mController.mBluetoothAdapter = mBluetoothAdapter;
|
||||||
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
|
when(mCachedDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||||
|
when(mCachedDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -52,6 +52,8 @@ import java.util.Collection;
|
|||||||
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
|
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
|
||||||
ShadowCachedBluetoothDeviceManager.class})
|
ShadowCachedBluetoothDeviceManager.class})
|
||||||
public class AvailableMediaBluetoothDeviceUpdaterTest {
|
public class AvailableMediaBluetoothDeviceUpdaterTest {
|
||||||
|
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -84,6 +86,7 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
|
|||||||
|
|
||||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||||
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||||
|
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
|
|
||||||
mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
|
mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
|
||||||
mDashboardFragment, mDevicePreferenceCallback));
|
mDashboardFragment, mDevicePreferenceCallback));
|
||||||
|
@@ -52,6 +52,7 @@ import org.robolectric.util.ReflectionHelpers;
|
|||||||
@Config(shadows = {ShadowAlertDialogCompat.class})
|
@Config(shadows = {ShadowAlertDialogCompat.class})
|
||||||
public class BluetoothDevicePreferenceTest {
|
public class BluetoothDevicePreferenceTest {
|
||||||
private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
|
private static final boolean SHOW_DEVICES_WITHOUT_NAMES = true;
|
||||||
|
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -68,6 +69,7 @@ public class BluetoothDevicePreferenceTest {
|
|||||||
mContext = new ContextThemeWrapper(context, R.style.Theme_Settings);
|
mContext = new ContextThemeWrapper(context, R.style.Theme_Settings);
|
||||||
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
|
mMetricsFeatureProvider = mFakeFeatureFactory.getMetricsFeatureProvider();
|
||||||
|
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
|
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
|
||||||
SHOW_DEVICES_WITHOUT_NAMES);
|
SHOW_DEVICES_WITHOUT_NAMES);
|
||||||
}
|
}
|
||||||
@@ -163,18 +165,6 @@ public class BluetoothDevicePreferenceTest {
|
|||||||
assertThat(mPreference.shouldHideSecondTarget()).isFalse();
|
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
|
@Test
|
||||||
public void testVisible_showDeviceWithoutNames_visible() {
|
public void testVisible_showDeviceWithoutNames_visible() {
|
||||||
doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
|
doReturn(false).when(mCachedBluetoothDevice).hasHumanReadableName();
|
||||||
|
@@ -56,6 +56,9 @@ import java.util.List;
|
|||||||
@Config(shadows = {ShadowBluetoothAdapter.class})
|
@Config(shadows = {ShadowBluetoothAdapter.class})
|
||||||
public class BluetoothDeviceUpdaterTest {
|
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
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -93,6 +96,8 @@ public class BluetoothDeviceUpdaterTest {
|
|||||||
when(mSubCachedBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice);
|
when(mSubCachedBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice);
|
||||||
when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
|
when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
|
||||||
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
|
||||||
|
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
|
when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);
|
||||||
|
|
||||||
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
|
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice, false);
|
||||||
mBluetoothDeviceUpdater =
|
mBluetoothDeviceUpdater =
|
||||||
|
@@ -54,6 +54,9 @@ import java.util.Collection;
|
|||||||
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
|
@Config(shadows = {ShadowAudioManager.class, ShadowBluetoothAdapter.class,
|
||||||
ShadowCachedBluetoothDeviceManager.class})
|
ShadowCachedBluetoothDeviceManager.class})
|
||||||
public class ConnectedBluetoothDeviceUpdaterTest {
|
public class ConnectedBluetoothDeviceUpdaterTest {
|
||||||
|
|
||||||
|
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -84,6 +87,7 @@ public class ConnectedBluetoothDeviceUpdaterTest {
|
|||||||
mCachedDevices = new ArrayList<>();
|
mCachedDevices = new ArrayList<>();
|
||||||
|
|
||||||
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||||
|
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
|
mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
|
||||||
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
|
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
|
||||||
mDashboardFragment, mDevicePreferenceCallback));
|
mDashboardFragment, mDevicePreferenceCallback));
|
||||||
|
@@ -44,6 +44,8 @@ import org.robolectric.annotation.Config;
|
|||||||
@Config(shadows = {ShadowBluetoothAdapter.class})
|
@Config(shadows = {ShadowBluetoothAdapter.class})
|
||||||
public class SavedBluetoothDeviceUpdaterTest {
|
public class SavedBluetoothDeviceUpdaterTest {
|
||||||
|
|
||||||
|
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DashboardFragment mDashboardFragment;
|
private DashboardFragment mDashboardFragment;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -64,6 +66,7 @@ public class SavedBluetoothDeviceUpdaterTest {
|
|||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
doReturn(mContext).when(mDashboardFragment).getContext();
|
doReturn(mContext).when(mDashboardFragment).getContext();
|
||||||
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
|
||||||
|
when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
|
||||||
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
|
when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
|
||||||
|
|
||||||
mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
|
mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
|
||||||
|
Reference in New Issue
Block a user