Fix a NPE when displaying device detail page.
Bug: 68956750 Test: robotests Change-Id: I1eed4e07ad723ee787a333ae88cd2ced62b3d34f
This commit is contained in:
@@ -72,8 +72,8 @@ public abstract class BluetoothDetailsController extends AbstractPreferenceContr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void displayPreference(PreferenceScreen screen) {
|
public final void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
|
||||||
init(screen);
|
init(screen);
|
||||||
|
super.displayPreference(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,7 +36,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
|
||||||
shadows=SettingsShadowBluetoothDevice.class)
|
shadows=SettingsShadowBluetoothDevice.class)
|
||||||
public class BluetoothDetailsControllerEventsTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsControllerEventsTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
public class BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsControllerTestBase {
|
||||||
protected Context mContext = RuntimeEnvironment.application;
|
protected Context mContext;
|
||||||
protected Lifecycle mLifecycle;
|
protected Lifecycle mLifecycle;
|
||||||
protected DeviceConfig mDeviceConfig;
|
protected DeviceConfig mDeviceConfig;
|
||||||
protected BluetoothDevice mDevice;
|
protected BluetoothDevice mDevice;
|
||||||
@@ -58,6 +58,7 @@ public class BluetoothDetailsControllerTestBase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = RuntimeEnvironment.application;
|
||||||
mPreferenceManager = new PreferenceManager(mContext);
|
mPreferenceManager = new PreferenceManager(mContext);
|
||||||
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
mScreen = mPreferenceManager.createPreferenceScreen(mContext);
|
||||||
mDeviceConfig = makeDefaultDeviceConfig();
|
mDeviceConfig = makeDefaultDeviceConfig();
|
||||||
|
@@ -45,7 +45,7 @@ import org.mockito.Mock;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
|
||||||
shadows={SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class,
|
shadows={SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class,
|
||||||
SettingsShadowResources.class})
|
SettingsShadowResources.class})
|
||||||
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
@@ -17,8 +17,8 @@ package com.android.settings.bluetooth;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
|
||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||||
import com.android.settings.testutils.shadow.SettingsShadowBluetoothDevice;
|
import com.android.settings.testutils.shadow.SettingsShadowBluetoothDevice;
|
||||||
import com.android.settingslib.widget.FooterPreference;
|
import com.android.settingslib.widget.FooterPreference;
|
||||||
|
|
||||||
@@ -27,9 +27,10 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
|
||||||
shadows=SettingsShadowBluetoothDevice.class)
|
shadows = SettingsShadowBluetoothDevice.class)
|
||||||
public class BluetoothDetailsMacAddressControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsMacAddressControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
|
|
||||||
private BluetoothDetailsMacAddressController mController;
|
private BluetoothDetailsMacAddressController mController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -54,7 +54,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
|
||||||
shadows=SettingsShadowBluetoothDevice.class)
|
shadows=SettingsShadowBluetoothDevice.class)
|
||||||
public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsControllerTestBase {
|
public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsControllerTestBase {
|
||||||
private BluetoothDetailsProfilesController mController;
|
private BluetoothDetailsProfilesController mController;
|
||||||
|
Reference in New Issue
Block a user