Use FooterPreference in xml explicitly
We don't rely on FooterPreferenceMixinCompat to create footer preference in dashboard fragment. Instead, declare a FooterPreference explicitly in xml of screen. Test: visual, robotest Bug: 124129485 Change-Id: I4c5b60c3926583eb0d9f0d4cd6996bf169d6408c
This commit is contained in:
@@ -67,4 +67,11 @@
|
|||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
settings:controller="com.android.settings.connecteddevice.AdvancedConnectedDeviceController"/>
|
settings:controller="com.android.settings.connecteddevice.AdvancedConnectedDeviceController"/>
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.FooterPreference
|
||||||
|
android:key="discoverable_footer"
|
||||||
|
android:title="@string/bluetooth_off_footer"
|
||||||
|
android:selectable="false"
|
||||||
|
settings:controller="com.android.settings.connecteddevice.DiscoverableFooterPreferenceController">
|
||||||
|
</com.android.settingslib.widget.FooterPreference>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -28,11 +28,8 @@ import com.android.settings.core.SettingsUIDeviceConfig;
|
|||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.slices.SlicePreferenceController;
|
import com.android.settings.slices.SlicePreferenceController;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -66,25 +63,6 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
return R.xml.connected_devices;
|
return R.xml.connected_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
return buildPreferenceControllers(context, getSettingsLifecycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
|
||||||
Lifecycle lifecycle) {
|
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
||||||
final DiscoverableFooterPreferenceController discoverableFooterPreferenceController =
|
|
||||||
new DiscoverableFooterPreferenceController(context);
|
|
||||||
controllers.add(discoverableFooterPreferenceController);
|
|
||||||
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(discoverableFooterPreferenceController);
|
|
||||||
}
|
|
||||||
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
@@ -93,7 +71,6 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
use(AvailableMediaDeviceGroupController.class).init(this);
|
use(AvailableMediaDeviceGroupController.class).init(this);
|
||||||
use(ConnectedDeviceGroupController.class).init(this);
|
use(ConnectedDeviceGroupController.class).init(this);
|
||||||
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
|
use(PreviouslyConnectedDevicePreferenceController.class).init(this);
|
||||||
use(DiscoverableFooterPreferenceController.class).init(this);
|
|
||||||
use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
|
use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
|
||||||
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
|
? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
|
||||||
: null);
|
: null);
|
||||||
@@ -111,11 +88,5 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment {
|
|||||||
sir.xmlResId = R.xml.connected_devices;
|
sir.xmlResId = R.xml.connected_devices;
|
||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(Context
|
|
||||||
context) {
|
|
||||||
return buildPreferenceControllers(context, null /* lifecycle */);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -32,32 +32,29 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.bluetooth.AlwaysDiscoverable;
|
import com.android.settings.bluetooth.AlwaysDiscoverable;
|
||||||
import com.android.settings.bluetooth.Utils;
|
import com.android.settings.bluetooth.Utils;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
|
||||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller that shows and updates the bluetooth device name
|
* Controller that shows and updates the bluetooth device name
|
||||||
*/
|
*/
|
||||||
public class DiscoverableFooterPreferenceController extends BasePreferenceController
|
public class DiscoverableFooterPreferenceController extends BasePreferenceController
|
||||||
implements LifecycleObserver, OnResume, OnPause {
|
implements LifecycleObserver, OnStart, OnStop {
|
||||||
private static final String KEY = "discoverable_footer_preference";
|
private static final String KEY = "discoverable_footer_preference";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
BroadcastReceiver mBluetoothChangedReceiver;
|
BroadcastReceiver mBluetoothChangedReceiver;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
LocalBluetoothManager mLocalManager;
|
LocalBluetoothManager mLocalManager;
|
||||||
private FooterPreferenceMixinCompat mFooterPreferenceMixin;
|
|
||||||
private FooterPreference mPreference;
|
|
||||||
private BluetoothAdapter mBluetoothAdapter;
|
private BluetoothAdapter mBluetoothAdapter;
|
||||||
private AlwaysDiscoverable mAlwaysDiscoverable;
|
private AlwaysDiscoverable mAlwaysDiscoverable;
|
||||||
|
private FooterPreference mPreference;
|
||||||
|
|
||||||
public DiscoverableFooterPreferenceController(Context context) {
|
public DiscoverableFooterPreferenceController(Context context, String key) {
|
||||||
super(context, KEY);
|
super(context, key);
|
||||||
mLocalManager = Utils.getLocalBtManager(context);
|
mLocalManager = Utils.getLocalBtManager(context);
|
||||||
if (mLocalManager == null) {
|
if (mLocalManager == null) {
|
||||||
return;
|
return;
|
||||||
@@ -67,53 +64,21 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
|||||||
initReceiver();
|
initReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initReceiver() {
|
|
||||||
mBluetoothChangedReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
|
||||||
final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
|
||||||
BluetoothAdapter.ERROR);
|
|
||||||
updateFooterPreferenceTitle(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(DashboardFragment fragment) {
|
|
||||||
mFooterPreferenceMixin = new FooterPreferenceMixinCompat(fragment,
|
|
||||||
fragment.getSettingsLifecycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
void init(FooterPreferenceMixinCompat footerPreferenceMixin, FooterPreference preference,
|
|
||||||
AlwaysDiscoverable alwaysDiscoverable) {
|
|
||||||
mFooterPreferenceMixin = footerPreferenceMixin;
|
|
||||||
mPreference = preference;
|
|
||||||
mAlwaysDiscoverable = alwaysDiscoverable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
addFooterPreference(screen);
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||||
? AVAILABLE
|
? AVAILABLE_UNSEARCHABLE
|
||||||
: UNSUPPORTED_ON_DEVICE;
|
: UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFooterPreference(PreferenceScreen screen) {
|
|
||||||
mPreference = mFooterPreferenceMixin.createFooterPreference();
|
|
||||||
mPreference.setKey(KEY);
|
|
||||||
screen.addPreference(mPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onStart() {
|
||||||
if (mLocalManager == null) {
|
if (mLocalManager == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -124,7 +89,7 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onStop() {
|
||||||
if (mLocalManager == null) {
|
if (mLocalManager == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -132,7 +97,7 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
|||||||
mAlwaysDiscoverable.stop();
|
mAlwaysDiscoverable.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFooterPreferenceTitle (int bluetoothState) {
|
private void updateFooterPreferenceTitle(int bluetoothState) {
|
||||||
if (bluetoothState == BluetoothAdapter.STATE_ON) {
|
if (bluetoothState == BluetoothAdapter.STATE_ON) {
|
||||||
mPreference.setTitle(getPreferenceTitle());
|
mPreference.setTitle(getPreferenceTitle());
|
||||||
} else {
|
} else {
|
||||||
@@ -150,4 +115,17 @@ public class DiscoverableFooterPreferenceController extends BasePreferenceContro
|
|||||||
mContext.getText(R.string.bluetooth_device_name_summary),
|
mContext.getText(R.string.bluetooth_device_name_summary),
|
||||||
BidiFormatter.getInstance().unicodeWrap(deviceName));
|
BidiFormatter.getInstance().unicodeWrap(deviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initReceiver() {
|
||||||
|
mBluetoothChangedReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent.getAction().equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||||
|
final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
|
||||||
|
BluetoothAdapter.ERROR);
|
||||||
|
updateFooterPreferenceTitle(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@@ -51,6 +51,7 @@ import java.util.List;
|
|||||||
ShadowConnectivityManager.class, ShadowBluetoothAdapter.class})
|
ShadowConnectivityManager.class, ShadowBluetoothAdapter.class})
|
||||||
public class ConnectedDeviceDashboardFragmentTest {
|
public class ConnectedDeviceDashboardFragmentTest {
|
||||||
private static final String KEY_NEARBY_DEVICES = "bt_nearby_slice";
|
private static final String KEY_NEARBY_DEVICES = "bt_nearby_slice";
|
||||||
|
private static final String KEY_DISCOVERABLE_FOOTER = "discoverable_footer";
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
@@ -81,7 +82,7 @@ public class ConnectedDeviceDashboardFragmentTest {
|
|||||||
.getNonIndexableKeys(mContext);
|
.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
||||||
KEY_NEARBY_DEVICES);
|
KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -30,14 +30,11 @@ import android.content.pm.PackageManager;
|
|||||||
import android.text.BidiFormatter;
|
import android.text.BidiFormatter;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.AlwaysDiscoverable;
|
import com.android.settings.bluetooth.AlwaysDiscoverable;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -49,6 +46,7 @@ import org.robolectric.RuntimeEnvironment;
|
|||||||
import org.robolectric.Shadows;
|
import org.robolectric.Shadows;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -56,16 +54,12 @@ import java.util.List;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = ShadowBluetoothAdapter.class)
|
@Config(shadows = ShadowBluetoothAdapter.class)
|
||||||
public class DiscoverableFooterPreferenceControllerTest {
|
public class DiscoverableFooterPreferenceControllerTest {
|
||||||
|
|
||||||
private static final String DEVICE_NAME = "device name";
|
private static final String DEVICE_NAME = "device name";
|
||||||
private static final String KEY = "discoverable_footer_preference";
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
@Mock
|
|
||||||
private FooterPreferenceMixinCompat mFooterPreferenceMixin;
|
|
||||||
@Mock
|
|
||||||
private AlwaysDiscoverable mAlwaysDiscoverable;
|
private AlwaysDiscoverable mAlwaysDiscoverable;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -82,10 +76,13 @@ public class DiscoverableFooterPreferenceControllerTest {
|
|||||||
|
|
||||||
doReturn(mPackageManager).when(mContext).getPackageManager();
|
doReturn(mPackageManager).when(mContext).getPackageManager();
|
||||||
mDiscoverableFooterPreferenceController =
|
mDiscoverableFooterPreferenceController =
|
||||||
new DiscoverableFooterPreferenceController(mContext);
|
new DiscoverableFooterPreferenceController(mContext, "key");
|
||||||
mPreference = spy(new FooterPreference(mContext));
|
mPreference = new FooterPreference(mContext);
|
||||||
mDiscoverableFooterPreferenceController.init(mFooterPreferenceMixin, mPreference,
|
ReflectionHelpers
|
||||||
mAlwaysDiscoverable);
|
.setField(mDiscoverableFooterPreferenceController, "mPreference", mPreference);
|
||||||
|
ReflectionHelpers
|
||||||
|
.setField(mDiscoverableFooterPreferenceController,
|
||||||
|
"mAlwaysDiscoverable", mAlwaysDiscoverable);
|
||||||
mBluetoothChangedReceiver = mDiscoverableFooterPreferenceController
|
mBluetoothChangedReceiver = mDiscoverableFooterPreferenceController
|
||||||
.mBluetoothChangedReceiver;
|
.mBluetoothChangedReceiver;
|
||||||
}
|
}
|
||||||
@@ -99,33 +96,25 @@ public class DiscoverableFooterPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatus_BluetoothFeature_returnAvailable() {
|
public void getAvailabilityStatus_BluetoothFeature_returnAvailableUnsearchable() {
|
||||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(true);
|
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mDiscoverableFooterPreferenceController.getAvailabilityStatus()).isEqualTo(
|
assertThat(mDiscoverableFooterPreferenceController.getAvailabilityStatus()).isEqualTo(
|
||||||
BasePreferenceController.AVAILABLE);
|
BasePreferenceController.AVAILABLE_UNSEARCHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void displayPreference() {
|
public void onStart_shouldRegisterBluetoothChanged() {
|
||||||
when(mFooterPreferenceMixin.createFooterPreference()).thenReturn(mPreference);
|
mDiscoverableFooterPreferenceController.onStart();
|
||||||
mDiscoverableFooterPreferenceController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
verify(mPreference).setKey(KEY);
|
|
||||||
verify(mScreen).addPreference(mPreference);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onResume() {
|
|
||||||
mDiscoverableFooterPreferenceController.onResume();
|
|
||||||
assertThat(getRegisteredBroadcastReceivers()).contains(mBluetoothChangedReceiver);
|
assertThat(getRegisteredBroadcastReceivers()).contains(mBluetoothChangedReceiver);
|
||||||
verify(mAlwaysDiscoverable).start();
|
verify(mAlwaysDiscoverable).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onPause() {
|
public void onStop_shouldUnregisterBluetoothChanged() {
|
||||||
mDiscoverableFooterPreferenceController.onResume();
|
mDiscoverableFooterPreferenceController.onStart();
|
||||||
mDiscoverableFooterPreferenceController.onPause();
|
mDiscoverableFooterPreferenceController.onStop();
|
||||||
|
|
||||||
assertThat(getRegisteredBroadcastReceivers()).doesNotContain(mBluetoothChangedReceiver);
|
assertThat(getRegisteredBroadcastReceivers()).doesNotContain(mBluetoothChangedReceiver);
|
||||||
verify(mAlwaysDiscoverable).stop();
|
verify(mAlwaysDiscoverable).stop();
|
||||||
@@ -147,6 +136,22 @@ public class DiscoverableFooterPreferenceControllerTest {
|
|||||||
assertThat(mPreference.getTitle()).isEqualTo(generateTitle(null));
|
assertThat(mPreference.getTitle()).isEqualTo(generateTitle(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onStart_localBluetoothManagerNull_shouldNotCrash() {
|
||||||
|
mDiscoverableFooterPreferenceController.mLocalManager = null;
|
||||||
|
|
||||||
|
// Shouldn't crash
|
||||||
|
mDiscoverableFooterPreferenceController.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onStop_localBluetoothManagerNull_shouldNotCrash() {
|
||||||
|
mDiscoverableFooterPreferenceController.mLocalManager = null;
|
||||||
|
|
||||||
|
// Shouldn't crash
|
||||||
|
mDiscoverableFooterPreferenceController.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
private CharSequence generateTitle(String deviceName) {
|
private CharSequence generateTitle(String deviceName) {
|
||||||
if (deviceName == null) {
|
if (deviceName == null) {
|
||||||
return mContext.getString(R.string.bluetooth_off_footer);
|
return mContext.getString(R.string.bluetooth_off_footer);
|
||||||
@@ -176,22 +181,4 @@ public class DiscoverableFooterPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
return registeredBroadcastReceivers;
|
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