Add error handle for device that not support Bluetooth
- Add LocalBluetoothManager null check for device that not support Bluetooth - Add test to verify when LocalBluetoothManager is null will not crash Bug: 110712414 Test: make -j42 RunSettingsRoboTests Change-Id: Ib506a0206cfcfdfec60bdfcf9a1944338a7ab729
This commit is contained in:
@@ -197,4 +197,20 @@ public class AvailableMediaDeviceGroupControllerTest {
|
||||
assertThat(mPreferenceGroup.getTitle()).isEqualTo(
|
||||
mContext.getText(R.string.connected_device_available_media_title));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_localBluetoothManagerNull_shouldNotCrash() {
|
||||
mAvailableMediaDeviceGroupController.mLocalBluetoothManager = null;
|
||||
|
||||
// Shouldn't crash
|
||||
mAvailableMediaDeviceGroupController.onStart();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStop_localBluetoothManagerNull_shouldNotCrash() {
|
||||
mAvailableMediaDeviceGroupController.mLocalBluetoothManager = null;
|
||||
|
||||
// Shouldn't crash
|
||||
mAvailableMediaDeviceGroupController.onStop();
|
||||
}
|
||||
}
|
||||
|
@@ -178,4 +178,22 @@ public class DiscoverableFooterPreferenceControllerTest {
|
||||
}
|
||||
return registeredBroadcastReceivers;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_localBluetoothManagerNull_shouldNotCrash() {
|
||||
mDiscoverableFooterPreferenceController.mLocalManager = null;
|
||||
mDiscoverableFooterPreferenceController.init(mFooterPreferenceMixin, mPreference, null);
|
||||
|
||||
// Shouldn't crash
|
||||
mDiscoverableFooterPreferenceController.onResume();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_localBluetoothManagerNull_shouldNotCrash() {
|
||||
mDiscoverableFooterPreferenceController.mLocalManager = null;
|
||||
mDiscoverableFooterPreferenceController.init(mFooterPreferenceMixin, mPreference, null);
|
||||
|
||||
// Shouldn't crash
|
||||
mDiscoverableFooterPreferenceController.onPause();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user