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:
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -31,7 +30,6 @@ import android.provider.Settings;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.search.InlinePayload;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -42,26 +40,30 @@ import org.junit.Test;
|
||||
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,
|
||||
shadows = {ShadowSecureSettings.class})
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
@Mock
|
||||
private SwitchPreference mSwitchPreference;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
private AmbientDisplayAlwaysOnPreferenceController mController;
|
||||
private boolean mCallbackInvoked;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
mController = new AmbientDisplayAlwaysOnPreferenceController(mContext, mConfig,
|
||||
() -> {
|
||||
mCallbackInvoked = true;
|
||||
@@ -69,9 +71,8 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_enabled() throws Exception {
|
||||
when(mConfig.alwaysOnEnabled(anyInt()))
|
||||
.thenReturn(true);
|
||||
public void updateState_enabled() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true);
|
||||
|
||||
mController.updateState(mSwitchPreference);
|
||||
|
||||
@@ -79,9 +80,8 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_disabled() throws Exception {
|
||||
when(mConfig.alwaysOnEnabled(anyInt()))
|
||||
.thenReturn(false);
|
||||
public void updateState_disabled() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
||||
|
||||
mController.updateState(mSwitchPreference);
|
||||
|
||||
@@ -89,30 +89,30 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_callback() throws Exception {
|
||||
public void onPreferenceChange_callback() {
|
||||
assertThat(mCallbackInvoked).isFalse();
|
||||
mController.onPreferenceChange(mSwitchPreference, true);
|
||||
assertThat(mCallbackInvoked).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_enable() throws Exception {
|
||||
public void onPreferenceChange_enable() {
|
||||
mController.onPreferenceChange(mSwitchPreference, true);
|
||||
|
||||
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||
.isEqualTo(1);
|
||||
assertThat(Settings.Secure.getInt(mContentResolver, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_disable() throws Exception {
|
||||
public void onPreferenceChange_disable() {
|
||||
mController.onPreferenceChange(mSwitchPreference, false);
|
||||
|
||||
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||
.isEqualTo(0);
|
||||
assertThat(Settings.Secure.getInt(mContentResolver, Settings.Secure.DOZE_ALWAYS_ON, -1))
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_available() throws Exception {
|
||||
public void isAvailable_available() {
|
||||
mController = spy(mController);
|
||||
doReturn(true).when(mController).alwaysOnAvailableForUser(any());
|
||||
|
||||
@@ -120,11 +120,10 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_unavailable() throws Exception {
|
||||
public void isAvailable_unavailable() {
|
||||
mController = spy(mController);
|
||||
doReturn(false).when(mController).alwaysOnAvailableForUser(any());
|
||||
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@@ -132,33 +131,30 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
|
||||
public void testPreferenceController_ProperResultPayloadType() {
|
||||
mController = spy(mController);
|
||||
doReturn(false).when(mController).alwaysOnAvailableForUser(any());
|
||||
|
||||
assertThat(mController.getResultPayload()).isInstanceOf(InlineSwitchPayload.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void testSetValue_updatesCorrectly() {
|
||||
mController = spy(mController);
|
||||
doReturn(false).when(mController).alwaysOnAvailableForUser(any());
|
||||
final int newValue = 1;
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, 0 /* value */);
|
||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.DOZE_ALWAYS_ON, 0 /* value */);
|
||||
|
||||
((InlinePayload) mController.getResultPayload()).setValue(mContext, newValue);
|
||||
final int updatedValue = Settings.Secure.getInt(resolver,
|
||||
Settings.Secure.DOZE_ALWAYS_ON, 1 /* default */);
|
||||
final int updatedValue = Settings.Secure.
|
||||
getInt(mContentResolver, Settings.Secure.DOZE_ALWAYS_ON, 1 /* default */);
|
||||
|
||||
assertThat(updatedValue).isEqualTo(newValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void testGetValue_correctValueReturned() {
|
||||
mController = spy(mController);
|
||||
doReturn(false).when(mController).alwaysOnAvailableForUser(any());
|
||||
final int currentValue = 1;
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ALWAYS_ON, currentValue);
|
||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.DOZE_ALWAYS_ON, currentValue);
|
||||
|
||||
final int newValue = ((InlinePayload) mController.getResultPayload()).getValue(mContext);
|
||||
|
||||
|
@@ -31,7 +31,6 @@ import android.provider.Settings;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.search.InlinePayload;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
@@ -43,31 +42,38 @@ import org.junit.Test;
|
||||
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,
|
||||
shadows = {ShadowSecureSettings.class})
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public class AmbientDisplayNotificationsPreferenceControllerTest {
|
||||
|
||||
@Mock Context mContext;
|
||||
@Mock AmbientDisplayConfiguration mConfig;
|
||||
@Mock SwitchPreference mSwitchPreference;
|
||||
@Mock MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
@Mock
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
@Mock
|
||||
private SwitchPreference mSwitchPreference;
|
||||
@Mock
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
AmbientDisplayNotificationsPreferenceController mController;
|
||||
private Context mContext;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
private AmbientDisplayNotificationsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
mController = new AmbientDisplayNotificationsPreferenceController(mContext, mConfig,
|
||||
mMetricsFeatureProvider);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_enabled() throws Exception {
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt()))
|
||||
.thenReturn(true);
|
||||
public void updateState_enabled() {
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
|
||||
|
||||
mController.updateState(mSwitchPreference);
|
||||
|
||||
@@ -75,9 +81,8 @@ public class AmbientDisplayNotificationsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_disabled() throws Exception {
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt()))
|
||||
.thenReturn(false);
|
||||
public void updateState_disabled() {
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
|
||||
|
||||
mController.updateState(mSwitchPreference);
|
||||
|
||||
@@ -85,39 +90,37 @@ public class AmbientDisplayNotificationsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_enable() throws Exception {
|
||||
public void onPreferenceChange_enable() {
|
||||
mController.onPreferenceChange(mSwitchPreference, true);
|
||||
|
||||
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ENABLED, -1))
|
||||
.isEqualTo(1);
|
||||
assertThat(Settings.Secure.getInt(mContentResolver, Settings.Secure.DOZE_ENABLED, -1))
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_disable() throws Exception {
|
||||
public void onPreferenceChange_disable() {
|
||||
mController.onPreferenceChange(mSwitchPreference, false);
|
||||
|
||||
assertThat(Settings.Secure.getInt(null, Settings.Secure.DOZE_ENABLED, -1))
|
||||
.isEqualTo(0);
|
||||
assertThat(Settings.Secure.getInt(mContentResolver, Settings.Secure.DOZE_ENABLED, -1))
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_available() throws Exception {
|
||||
when(mConfig.pulseOnNotificationAvailable())
|
||||
.thenReturn(true);
|
||||
public void isAvailable_available() {
|
||||
when(mConfig.pulseOnNotificationAvailable()).thenReturn(true);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_unavailable() throws Exception {
|
||||
when(mConfig.pulseOnNotificationAvailable())
|
||||
.thenReturn(false);
|
||||
public void isAvailable_unavailable() {
|
||||
when(mConfig.pulseOnNotificationAvailable()).thenReturn(false);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_reportsEventForItsPreference() throws Exception {
|
||||
public void handlePreferenceTreeClick_reportsEventForItsPreference() {
|
||||
when(mSwitchPreference.getKey()).thenReturn(
|
||||
AmbientDisplayNotificationsPreferenceController.KEY_AMBIENT_DISPLAY_NOTIFICATIONS);
|
||||
|
||||
@@ -127,7 +130,7 @@ public class AmbientDisplayNotificationsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_doesntReportEventForOtherPreferences() throws Exception {
|
||||
public void handlePreferenceTreeClick_doesntReportEventForOtherPreferences() {
|
||||
when(mSwitchPreference.getKey()).thenReturn("some_other_key");
|
||||
|
||||
mController.handlePreferenceTreeClick(mSwitchPreference);
|
||||
@@ -141,24 +144,21 @@ public class AmbientDisplayNotificationsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void testSetValue_updatesCorrectly() {
|
||||
int newValue = 1;
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ENABLED, 0);
|
||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.DOZE_ENABLED, 0);
|
||||
|
||||
((InlinePayload) mController.getResultPayload()).setValue(mContext, newValue);
|
||||
int updatedValue = Settings.Secure.getInt(resolver, Settings.Secure.DOZE_ENABLED, 1);
|
||||
int updatedValue =
|
||||
Settings.Secure.getInt(mContentResolver, Settings.Secure.DOZE_ENABLED, 1);
|
||||
|
||||
assertThat(updatedValue).isEqualTo(newValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public void testGetValue_correctValueReturned() {
|
||||
int currentValue = 1;
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.Secure.putInt(resolver, Settings.Secure.DOZE_ENABLED, currentValue);
|
||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.DOZE_ENABLED, currentValue);
|
||||
|
||||
int newValue = ((InlinePayload) mController.getResultPayload()).getValue(mContext);
|
||||
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -28,7 +27,6 @@ import android.support.v7.preference.Preference;
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -39,36 +37,38 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = {ShadowSecureSettings.class})
|
||||
@Config(shadows = ShadowSecureSettings.class)
|
||||
public class AmbientDisplayPreferenceControllerTest {
|
||||
|
||||
@Mock Context mContext;
|
||||
@Mock AmbientDisplayConfiguration mConfig;
|
||||
@Mock Preference mPreference;
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
@Mock
|
||||
private Preference mPreference;
|
||||
|
||||
AmbientDisplayPreferenceController mController;
|
||||
private AmbientDisplayPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new AmbientDisplayPreferenceController(mContext, mConfig, "key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_available() throws Exception {
|
||||
public void isAvailable_available() {
|
||||
when(mConfig.available()).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_unavailable() throws Exception {
|
||||
public void isAvailable_unavailable() {
|
||||
when(mConfig.available()).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_alwaysOn() throws Exception {
|
||||
public void updateState_alwaysOn() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(true);
|
||||
|
||||
mController.updateState(mPreference);
|
||||
@@ -77,7 +77,7 @@ public class AmbientDisplayPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_notifications() throws Exception {
|
||||
public void updateState_notifications() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(true);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class AmbientDisplayPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_gestures() throws Exception {
|
||||
public void updateState_gestures() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
|
||||
when(mConfig.enabled(anyInt())).thenReturn(true);
|
||||
@@ -98,7 +98,7 @@ public class AmbientDisplayPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_off() throws Exception {
|
||||
public void updateState_off() {
|
||||
when(mConfig.alwaysOnEnabled(anyInt())).thenReturn(false);
|
||||
when(mConfig.pulseOnNotificationEnabled(anyInt())).thenReturn(false);
|
||||
when(mConfig.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
|
||||
@@ -110,8 +110,7 @@ public class AmbientDisplayPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceKey() throws Exception {
|
||||
public void getPreferenceKey() {
|
||||
assertThat(mController.getPreferenceKey()).isEqualTo("key");
|
||||
}
|
||||
|
||||
}
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -30,7 +29,6 @@ import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.IconDrawableFactory;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -39,10 +37,8 @@ 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 AppGridViewTest {
|
||||
|
||||
@Mock
|
||||
@@ -70,10 +66,10 @@ public class AppGridViewTest {
|
||||
|
||||
@Test
|
||||
public void appEntry_shouldLoadIcon() {
|
||||
when(mPackageManager.loadUnbadgedItemIcon(mActivityInfo, mApplicationInfo)).thenReturn(
|
||||
mIcon);
|
||||
final AppGridView.ActivityEntry activityEntry = new AppGridView.ActivityEntry(
|
||||
mInfo, "label", mIconFactory);
|
||||
when(mPackageManager.loadUnbadgedItemIcon(mActivityInfo, mApplicationInfo))
|
||||
.thenReturn(mIcon);
|
||||
final AppGridView.ActivityEntry activityEntry =
|
||||
new AppGridView.ActivityEntry(mInfo, "label", mIconFactory);
|
||||
|
||||
assertThat(activityEntry.label).isEqualTo("label");
|
||||
assertThat(activityEntry.getIcon()).isNotNull();
|
||||
@@ -81,12 +77,12 @@ public class AppGridViewTest {
|
||||
|
||||
@Test
|
||||
public void appEntry_compare_shouldCompareIgnoreCase() {
|
||||
final AppGridView.ActivityEntry entry1 = new AppGridView.ActivityEntry(
|
||||
mInfo, "label", mIconFactory);
|
||||
final AppGridView.ActivityEntry entry2 = new AppGridView.ActivityEntry(
|
||||
mInfo, "LABEL", mIconFactory);
|
||||
final AppGridView.ActivityEntry entry3 = new AppGridView.ActivityEntry(
|
||||
mInfo, "label2", mIconFactory);
|
||||
final AppGridView.ActivityEntry entry1 =
|
||||
new AppGridView.ActivityEntry(mInfo, "label", mIconFactory);
|
||||
final AppGridView.ActivityEntry entry2 =
|
||||
new AppGridView.ActivityEntry(mInfo, "LABEL", mIconFactory);
|
||||
final AppGridView.ActivityEntry entry3 =
|
||||
new AppGridView.ActivityEntry(mInfo, "label2", mIconFactory);
|
||||
|
||||
assertThat(entry1.compareTo(entry2)).isEqualTo(0);
|
||||
assertThat(entry1.compareTo(entry3)).isNotEqualTo(0);
|
||||
|
@@ -19,36 +19,35 @@ package com.android.settings.display;
|
||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
|
||||
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class AutoBrightnessPreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
||||
private static final String PREFERENCE_KEY = "auto_brightness";
|
||||
|
||||
private Context mContext;
|
||||
private AutoBrightnessPreferenceController mController;
|
||||
private final String PREFERENCE_KEY = "auto_brightness";
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
mController = new AutoBrightnessPreferenceController(mContext, PREFERENCE_KEY);
|
||||
}
|
||||
|
||||
@@ -56,8 +55,8 @@ public class AutoBrightnessPreferenceControllerTest {
|
||||
public void testOnPreferenceChange_TurnOnAuto_ReturnAuto() {
|
||||
mController.onPreferenceChange(null, true);
|
||||
|
||||
final int mode = Settings.System.getInt(mContext.getContentResolver(),
|
||||
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
}
|
||||
|
||||
@@ -65,19 +64,19 @@ public class AutoBrightnessPreferenceControllerTest {
|
||||
public void testOnPreferenceChange_TurnOffAuto_ReturnManual() {
|
||||
mController.onPreferenceChange(null, false);
|
||||
|
||||
final int mode = Settings.System.getInt(mContext.getContentResolver(),
|
||||
SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
final int mode = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
assertThat(mode).isEqualTo(SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetValue_updatesCorrectly() {
|
||||
boolean newValue = true;
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_MANUAL);
|
||||
|
||||
mController.setChecked(newValue);
|
||||
boolean updatedValue = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE, -1)
|
||||
boolean updatedValue = Settings.System.getInt(mContentResolver, SCREEN_BRIGHTNESS_MODE, -1)
|
||||
!= SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||
|
||||
assertThat(updatedValue).isEqualTo(newValue);
|
||||
@@ -85,8 +84,8 @@ public class AutoBrightnessPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testGetValue_correctValueReturned() {
|
||||
ContentResolver resolver = mContext.getContentResolver();
|
||||
Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
Settings.System.putInt(mContentResolver, SCREEN_BRIGHTNESS_MODE,
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
|
||||
|
||||
int newValue = mController.isChecked() ?
|
||||
SCREEN_BRIGHTNESS_MODE_AUTOMATIC
|
||||
|
@@ -29,7 +29,6 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowSystemSettings;
|
||||
@@ -46,11 +45,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(
|
||||
manifest = TestConfig.MANIFEST_PATH,
|
||||
sdk = TestConfig.SDK_VERSION,
|
||||
shadows = ShadowSystemSettings.class
|
||||
)
|
||||
@Config(shadows = ShadowSystemSettings.class)
|
||||
public class AutoRotatePreferenceControllerTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
@@ -21,24 +21,23 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class BatteryPercentagePreferenceControllerTest {
|
||||
@Mock private Context mContext;
|
||||
|
||||
private Context mContext;
|
||||
private BatteryPercentagePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new BatteryPercentagePreferenceController(mContext);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.reset;
|
||||
@@ -31,7 +30,6 @@ import android.provider.Settings.System;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.wrapper.PowerManagerWrapper;
|
||||
|
||||
@@ -41,17 +39,12 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
import org.robolectric.shadows.ShadowContentResolver;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class BrightnessLevelPreferenceControllerTest {
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
@Mock
|
||||
private PowerManagerWrapper mPowerManager;
|
||||
@Mock
|
||||
@@ -59,12 +52,17 @@ public class BrightnessLevelPreferenceControllerTest {
|
||||
@Mock
|
||||
private Preference mPreference;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
|
||||
private BrightnessLevelPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContentResolver = mContext.getContentResolver();
|
||||
when(mPowerManager.getMinimumScreenBrightnessSetting()).thenReturn(0);
|
||||
when(mPowerManager.getMaximumScreenBrightnessSetting()).thenReturn(100);
|
||||
when(mPowerManager.getMinimumScreenBrightnessForVrSetting()).thenReturn(0);
|
||||
@@ -72,7 +70,6 @@ public class BrightnessLevelPreferenceControllerTest {
|
||||
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
|
||||
mController = spy(new BrightnessLevelPreferenceController(mContext, null, mPowerManager));
|
||||
doReturn(false).when(mController).isInVrMode();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,10 +79,9 @@ public class BrightnessLevelPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onStart_shouldRegisterObserver() {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
BrightnessLevelPreferenceController controller =
|
||||
new BrightnessLevelPreferenceController(context, null, mPowerManager);
|
||||
ShadowContentResolver shadowContentResolver = Shadow.extract(context.getContentResolver());
|
||||
new BrightnessLevelPreferenceController(mContext, null, mPowerManager);
|
||||
ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
|
||||
|
||||
controller.onStart();
|
||||
|
||||
@@ -99,10 +95,9 @@ public class BrightnessLevelPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onStop_shouldUnregisterObserver() {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
BrightnessLevelPreferenceController controller =
|
||||
new BrightnessLevelPreferenceController(context, null, mPowerManager);
|
||||
ShadowContentResolver shadowContentResolver = Shadow.extract(context.getContentResolver());
|
||||
new BrightnessLevelPreferenceController(mContext, null, mPowerManager);
|
||||
ShadowContentResolver shadowContentResolver = Shadow.extract(mContext.getContentResolver());
|
||||
|
||||
controller.displayPreference(mScreen);
|
||||
controller.onStart();
|
||||
|
@@ -17,8 +17,8 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -26,7 +26,6 @@ import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -35,10 +34,8 @@ 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 ColorModePreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
|
@@ -16,7 +16,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -30,12 +29,9 @@ import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -46,13 +42,11 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ColorModePreferenceFragmentTest {
|
||||
|
||||
private ColorModePreferenceFragment mFragment;
|
||||
@@ -63,7 +57,6 @@ public class ColorModePreferenceFragmentTest {
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
SettingsShadowSystemProperties.clear();
|
||||
|
||||
mFragment = spy(new ColorModePreferenceFragment());
|
||||
ReflectionHelpers.setField(mFragment, "mController", mController);
|
||||
@@ -89,51 +82,45 @@ public class ColorModePreferenceFragmentTest {
|
||||
.isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void getKey_natural() {
|
||||
Mockito.when(mController.getColorMode()).thenReturn(
|
||||
ColorDisplayController.COLOR_MODE_NATURAL);
|
||||
Mockito.when(mController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_NATURAL);
|
||||
|
||||
assertThat(mFragment.getDefaultKey())
|
||||
.isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void getKey_boosted() {
|
||||
Mockito.when(mController.getColorMode()).thenReturn(
|
||||
ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||
Mockito.when(mController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||
|
||||
assertThat(mFragment.getDefaultKey())
|
||||
.isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void getKey_saturated() {
|
||||
Mockito.when(mController.getColorMode()).thenReturn(
|
||||
ColorDisplayController.COLOR_MODE_SATURATED);
|
||||
Mockito.when(mController.getColorMode())
|
||||
.thenReturn(ColorDisplayController.COLOR_MODE_SATURATED);
|
||||
|
||||
assertThat(mFragment.getDefaultKey())
|
||||
.isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void setKey_natural() {
|
||||
mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL);
|
||||
verify(mController).setColorMode(ColorDisplayController.COLOR_MODE_NATURAL);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void setKey_boosted() {
|
||||
mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED);
|
||||
verify(mController).setColorMode(ColorDisplayController.COLOR_MODE_BOOSTED);
|
||||
}
|
||||
|
||||
@Config(shadows = {SettingsShadowSystemProperties.class})
|
||||
@Test
|
||||
public void setKey_saturated() {
|
||||
mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED);
|
||||
|
@@ -17,38 +17,26 @@ package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class NightDisplaySettingsTest {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNightDisplayIndexing_containsResource() {
|
||||
List<SearchIndexableResource> resources =
|
||||
NightDisplaySettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext,
|
||||
true /* enabled */);
|
||||
NightDisplaySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getXmlResourcesToIndex(RuntimeEnvironment.application, true /* enabled */);
|
||||
|
||||
List<Integer> indexedXml = new ArrayList<>();
|
||||
for (SearchIndexableResource resource : resources) {
|
||||
|
@@ -16,13 +16,15 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -30,13 +32,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class ShowOperatorNamePreferenceControllerTest {
|
||||
|
||||
private static final String KEY_SHOW_OPERATOR_NAME = "show_operator_name";
|
||||
@@ -57,15 +54,15 @@ public class ShowOperatorNamePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_configIsTrue_ReturnTrue() {
|
||||
when(mContext.getResources().getBoolean(R.bool.config_showOperatorNameInStatusBar))
|
||||
.thenReturn(true);
|
||||
when(mContext.getResources()
|
||||
.getBoolean(R.bool.config_showOperatorNameInStatusBar)).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAvailable_configIsFalse_ReturnFalse() {
|
||||
when(mContext.getResources().getBoolean(R.bool.config_showOperatorNameInStatusBar))
|
||||
.thenReturn(false);
|
||||
when(mContext.getResources()
|
||||
.getBoolean(R.bool.config_showOperatorNameInStatusBar)).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@@ -73,8 +70,8 @@ public class ShowOperatorNamePreferenceControllerTest {
|
||||
public void testOnPreferenceChange_TurnOn_ReturnOn() {
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
KEY_SHOW_OPERATOR_NAME, 0);
|
||||
final int mode =
|
||||
Settings.Secure.getInt(mContext.getContentResolver(), KEY_SHOW_OPERATOR_NAME, 0);
|
||||
assertThat(mode).isEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -82,8 +79,8 @@ public class ShowOperatorNamePreferenceControllerTest {
|
||||
public void testOnPreferenceChange_TurnOff_ReturnOff() {
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
KEY_SHOW_OPERATOR_NAME, 1);
|
||||
final int mode =
|
||||
Settings.Secure.getInt(mContext.getContentResolver(), KEY_SHOW_OPERATOR_NAME, 1);
|
||||
assertThat(mode).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.support.v7.preference.ListPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.wrapper.OverlayManagerWrapper;
|
||||
@@ -44,10 +43,8 @@ import org.mockito.Answers;
|
||||
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 ThemePreferenceControllerTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
@@ -70,8 +67,8 @@ public class ThemePreferenceControllerTest {
|
||||
when(mContext.getString(R.string.default_theme))
|
||||
.thenReturn(RuntimeEnvironment.application.getString(R.string.default_theme));
|
||||
|
||||
mController = spy(new ThemePreferenceController(mContext,
|
||||
mock(OverlayManagerWrapper.class)));
|
||||
mController =
|
||||
spy(new ThemePreferenceController(mContext, mock(OverlayManagerWrapper.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -17,12 +17,9 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -34,7 +31,6 @@ import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.TimeoutListPreference;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowDevicePolicyManagerWrapper;
|
||||
@@ -54,10 +50,12 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows = {ShadowDevicePolicyManagerWrapper.class})
|
||||
@Config(shadows = ShadowDevicePolicyManagerWrapper.class)
|
||||
public class TimeoutPreferenceControllerTest {
|
||||
|
||||
private static final int TIMEOUT = 30;
|
||||
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private TimeoutListPreference mPreference;
|
||||
@@ -65,7 +63,6 @@ public class TimeoutPreferenceControllerTest {
|
||||
private UserManager mUserManager;
|
||||
|
||||
private TimeoutPreferenceController mController;
|
||||
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -126,8 +123,8 @@ public class TimeoutPreferenceControllerTest {
|
||||
ArgumentCaptor<Long> longCaptor = ArgumentCaptor.forClass(Long.class);
|
||||
ArgumentCaptor<EnforcedAdmin> adminCaptor = ArgumentCaptor.forClass(EnforcedAdmin.class);
|
||||
|
||||
verify(mPreference, times(2)).removeUnusableTimeouts(
|
||||
longCaptor.capture(), adminCaptor.capture());
|
||||
verify(mPreference, times(2))
|
||||
.removeUnusableTimeouts(longCaptor.capture(), adminCaptor.capture());
|
||||
assertEquals(0, (long)longCaptor.getValue());
|
||||
assertTrue(adminCaptor.getValue() != null);
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ import android.provider.Settings;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -39,7 +38,6 @@ import org.robolectric.annotation.Config;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class VrDisplayPreferencePickerTest {
|
||||
|
||||
private VrDisplayPreferencePicker mPicker;
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -29,7 +28,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -37,13 +35,11 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class WallpaperPreferenceControllerTest {
|
||||
|
||||
private static final String WALLPAPER_PACKAGE = "TestPkg";
|
||||
|
Reference in New Issue
Block a user