Use external/robolectric-shadows/run_robotests.mk
This allows Settings to test against the latest framework changes. Also replaced TestConfig with traditional robolectric.properties. Bug: 73173204 Bug: 73892008 Test: make -j56 RunSettingsRoboTests Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
This commit is contained in:
@@ -16,15 +16,14 @@
|
||||
package com.android.settings.location;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Global;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -33,30 +32,27 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class BluetoothScanningPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private SwitchPreference mPreference;
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mContentResolver;
|
||||
private BluetoothScanningPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new BluetoothScanningPreferenceController(mContext);
|
||||
mContentResolver = RuntimeEnvironment.application.getContentResolver();
|
||||
mController = new BluetoothScanningPreferenceController(RuntimeEnvironment.application);
|
||||
when(mPreference.getKey()).thenReturn(mController.getPreferenceKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_bluetoothScanningEnabled_shouldCheckedPreference() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -65,8 +61,7 @@ public class BluetoothScanningPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void updateState_bluetoothScanningDisabled_shouldUncheckedPreference() {
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
|
||||
@@ -79,9 +74,8 @@ public class BluetoothScanningPreferenceControllerTest {
|
||||
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0)).isEqualTo(1);
|
||||
|
||||
final int btScanning = Global.getInt(mContentResolver, Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
|
||||
assertThat(btScanning).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,8 +84,7 @@ public class BluetoothScanningPreferenceControllerTest {
|
||||
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
assertThat(Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1)).isEqualTo(0);
|
||||
|
||||
final int btScanning = Global.getInt(mContentResolver, Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
|
||||
assertThat(btScanning).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user