Fix broken bluetooth robo tests

Bug: 129159331
Test: RunSettingsRoboTests
Change-Id: I3e64659e59fd9b2ac58bf697116e1ee34928a3cd
This commit is contained in:
jackqdyulei
2019-03-25 13:15:30 -07:00
parent b4ae464e99
commit a2208c008b
6 changed files with 19 additions and 12 deletions

View File

@@ -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();