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:
hughchen
2018-06-25 11:06:45 +08:00
parent a5f68f9c3c
commit 34066fa21a
6 changed files with 81 additions and 3 deletions

View File

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

View File

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