import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = ShadowUtils.class
+)
public class DeviceInfoSettingsTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
}
@Test
- @Config(shadows = ShadowUtils.class)
public void testNonIndexableKeys_existInXmlLayout() {
final Context context = RuntimeEnvironment.application;
final List<String> niks = DeviceInfoSettings.SEARCH_INDEX_DATA_PROVIDER
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
-import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {ShadowUtils.class}
+)
public class MasterClearTest {
@Mock
}
@Test
- @Config(shadows = { ShadowUtils.class })
public void testInitiateMasterClear_inDemoMode_sendsIntent() {
ShadowUtils.setIsDemoUser(true);
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {ShadowLockPatternUtils.class}
+)
public class SecuritySettingsTest {
private static final String MOCK_SUMMARY = "summary";
}
@Test
- @Config (shadows = {
- ShadowLockPatternUtils.class,
- })
public void testNonIndexableKeys_existInXmlLayout() {
final Context context = spy(RuntimeEnvironment.application);
UserManager manager = mock(UserManager.class);
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = AccountHeaderPreferenceControllerTest.ShadowAuthenticatorHelper.class
+)
public class AccountHeaderPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
}
@Test
- @Config(shadows = ShadowAuthenticatorHelper.class)
public void onResume_shouldDisplayAccountInEntityHeader() {
final Lifecycle lifecycle = new Lifecycle();
final Account account = new Account("name1@abc.com", "com.abc");
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_linkedUser_shouldAddOneAccountCategory() {
final UserInfo info = new UserInfo(1, "user 1", 0);
when(mUserManager.isManagedProfile()).thenReturn(false);
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneProfile_shouldAddOneAccountCategory() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_twoProfiles_shouldAddTwoAccountCategory() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_noProfileChange_shouldNotAddOrRemoveAccountCategory() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneNewProfile_shouldAddOneAccountCategory() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneProfileRemoved_shouldRemoveOneAccountCategory() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneProfile_shouldSetAccountTitleWithUserName() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_noPreferenceScreen_shouldNotCrash() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_noPreferenceManager_shouldNotCrash() {
when(mFragment.getPreferenceManager()).thenReturn(null);
final List<UserInfo> infos = new ArrayList<>();
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_twoAccountsOfSameType_shouldAddThreePreferences() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_noAccountChange_shouldNotAddAccountPreference() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneNewAccountType_shouldAddOneAccountPreference() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
}
@Test
- @Config(shadows = {ShadowAccountManager.class, ShadowContentResolver.class})
public void onResume_oneAccountRemoved_shouldRemoveOneAccountPreference() {
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = InstalledAppDetailsTest.ShadowUtils.class
+)
public final class InstalledAppDetailsTest {
private static final String PACKAGE_NAME = "test_package_name";
}
@Test
- @Config(shadows = ShadowUtils.class)
public void handleDisableable_appIsEnabled_buttonShouldWork() {
final ApplicationInfo info = new ApplicationInfo();
info.packageName = "pkg";
}
@Test
- @Config(shadows = ShadowUtils.class)
public void handleDisableable_appIsEnabledAndInKeepEnabledWhitelist_buttonShouldNotWork() {
final ApplicationInfo info = new ApplicationInfo();
info.packageName = "pkg";
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION,
- shadows = ShadowSecureSettings.class)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {ShadowSecureSettings.class, SettingsShadowResources.class}
+)
public class SuggestionFeatureProviderImplTest {
private static final String DOUBLE_TWIST_SENSOR_NAME = "double_twist_sensor_name";
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_doubleTapPower_trueWhenNotAvailable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, false);
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_doubleTapPower_falseWhenNotVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, true);
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_doubleTapPower_trueWhenVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, true);
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_doubleTwist_trueWhenNotAvailable() {
SettingsShadowResources.overrideResource(
R.string.gesture_double_twist_sensor_name, "nonexistant name");
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_ambientDisplay_falseWhenNotVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_ambientDisplay_trueWhenVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_ambientDisplayPickup_falseWhenNotVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
}
@Test
- @Config(shadows = SettingsShadowResources.class)
public void isSuggestionCompleted_ambientDisplayPickup_trueWhenVisited() {
SettingsShadowResources.overrideResource(
com.android.internal.R.string.config_dozeComponent, "foo");
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {SettingsShadowSystemProperties.class}
+)
public class AutomaticStorageManagementSwitchPreferenceControllerTest {
@Mock
}
@Test
- @Config(shadows = {SettingsShadowSystemProperties.class})
public void isAvailable_shouldAlwaysReturnFalse_forLowRamDevice() {
SettingsShadowSystemProperties.set("ro.config.low_ram", "true");
assertThat(mController.isAvailable()).isFalse();
}
- @Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void togglingOnShouldNotTriggerWarningFragmentIfEnabledByDefault() {
FragmentTransaction transaction = mock(FragmentTransaction.class);
verify(transaction, never()).add(any(), eq(ActivationWarningFragment.TAG));
}
- @Config(shadows = {SettingsShadowSystemProperties.class})
@Test
public void togglingOnShouldTriggerWarningFragmentIfEnabledByDefaultAndDisabledByPolicy() {
FragmentTransaction transaction = mock(FragmentTransaction.class);
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = ShadowSystemSettings.class
+)
public class AutoRotatePreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
}
@Test
- @Config(shadows = ShadowSystemSettings.class)
public void updatePreference_settingsIsOff_shouldTurnOffToggle() {
Settings.System.putIntForUser(mContentResolver,
Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT);
}
@Test
- @Config(shadows = ShadowSystemSettings.class)
public void updatePreference_settingsIsOn_shouldTurnOnToggle() {
Settings.System.putIntForUser(mContentResolver,
Settings.System.ACCELEROMETER_ROTATION, 1, UserHandle.USER_CURRENT);
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = ShadowSecureSettings.class
+)
public class AssistGestureSettingsPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
}
@Test
- @Config(shadows = ShadowSecureSettings.class)
public void testSetValue_updatesCorrectly() {
int newValue = 1;
ContentResolver resolver = mContext.getContentResolver();
}
@Test
- @Config(shadows = ShadowSecureSettings.class)
public void testGetValue_correctValueReturned() {
int currentValue = 1;
ContentResolver resolver = mContext.getContentResolver();
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = ShadowRestrictedLockUtilsWrapper.class
+)
public class MobileNetworkPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
}
@Test
- @Config(shadows = ShadowRestrictedLockUtilsWrapper.class)
public void wifiOnly_prefIsNotAvailable() {
when(mUserManager.isAdminUser()).thenReturn(true);
when(mUserManager.hasUserRestriction(anyString(), any(UserHandle.class)))
import java.util.Set;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows = {ShadowRunnableAsyncTask.class})
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {
+ ShadowRunnableAsyncTask.class,
+ ShadowDatabaseIndexingUtils.class,
+ ShadowContentResolver.class
+ }
+)
public class DatabaseIndexingManagerTest {
private final String localeStr = "en_US";
// Test new public indexing flow
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class})
public void testPerformIndexing_fullIndex_getsDataFromProviders() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
}
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_incrementalIndex_noDataAdded() {
final List<ResolveInfo> providerInfo = getDummyResolveInfo();
skipFullIndex(providerInfo);
}
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_localeChanged_databaseDropped() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
}
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_onOta_FullIndex() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
}
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_onPackageChange_shouldFullIndex() {
final List<ResolveInfo> providers = getDummyResolveInfo();
final String buildNumber = Build.FINGERPRINT;
}
@Test
- @Config(shadows = {ShadowDatabaseIndexingUtils.class,})
public void testPerformIndexing_onOta_buildNumberIsCached() {
DummyProvider provider = new DummyProvider();
provider.onCreate();
}
@Test
- @Config(shadows = {ShadowContentResolver.class})
public void testEmptyNonIndexableKeys_emptyDataKeyResources_addedToDatabase() {
insertSpecialCase(TITLE_ONE, true /* enabled */, null /* dataReferenceKey */);
import static org.mockito.Mockito.verify;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = ShadowEventLogWriter.class
+)
public class ConfigureKeyGuardDialogTest {
@Test
- @Config(shadows = ShadowEventLogWriter.class)
public void displayDialog_clickPositiveButton_launchSetNewPassword() {
final FragmentController<ConfigureKeyGuardDialog> fragmentController =
Robolectric.buildFragment(ConfigureKeyGuardDialog.class);
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {ShadowSecureSettings.class, ShadowUtils.class}
+)
public class FactoryResetPreferenceControllerTest {
private static final String FACTORY_RESET_KEY = "factory_reset";
}
@Test
- @Config(shadows = { ShadowSecureSettings.class, ShadowUtils.class })
public void isAvailable_nonSystemUser() {
when(mUserManager.isAdminUser()).thenReturn(false);
ShadowUtils.setIsDemoUser(false);
}
@Test
- @Config(shadows = { ShadowSecureSettings.class, ShadowUtils.class })
public void isAvailable_demoUser() {
when(mUserManager.isAdminUser()).thenReturn(false);
ShadowUtils.setIsDemoUser(true);
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(
+ manifest = TestConfig.MANIFEST_PATH,
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {ShadowTextUtils.class}
+)
public class RtlCompatibleViewPagerTest {
private Locale mLocaleEn;
}
@Test
- @Config(shadows = {ShadowTextUtils.class})
public void testGetCurrentItem_shouldMaintainIndexDuringLocaleChange() {
testRtlCompatibleInner(0);
testRtlCompatibleInner(1);