Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference Bug: 161896447 Test: robotest & manual Change-Id: I36829e0055437dab79d9e5339ac002a87a4b874f
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
android:persistent="false"
|
||||
settings:controller="com.android.settings.backup.ConfigureAccountPreferenceController">
|
||||
<!-- the Intent declared here is always overwritten by a real one -->
|
||||
<intent android:action="dummy" />
|
||||
<intent android:action="placeholder" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
|
@@ -588,7 +588,7 @@ public class AppOpsState {
|
||||
if (appEntry == null) {
|
||||
continue;
|
||||
}
|
||||
List<AppOpsManager.OpEntry> dummyOps = null;
|
||||
List<AppOpsManager.OpEntry> stubOps = null;
|
||||
AppOpsManager.PackageOps pkgOps = null;
|
||||
if (appInfo.requestedPermissions != null) {
|
||||
for (int j=0; j<appInfo.requestedPermissions.length; j++) {
|
||||
@@ -611,15 +611,15 @@ public class AppOpsState {
|
||||
if (appEntry.hasOp(permOps.get(k))) {
|
||||
continue;
|
||||
}
|
||||
if (dummyOps == null) {
|
||||
dummyOps = new ArrayList<AppOpsManager.OpEntry>();
|
||||
if (stubOps == null) {
|
||||
stubOps = new ArrayList<AppOpsManager.OpEntry>();
|
||||
pkgOps = new AppOpsManager.PackageOps(
|
||||
appInfo.packageName, appInfo.applicationInfo.uid, dummyOps);
|
||||
appInfo.packageName, appInfo.applicationInfo.uid, stubOps);
|
||||
|
||||
}
|
||||
AppOpsManager.OpEntry opEntry = new AppOpsManager.OpEntry(
|
||||
permOps.get(k), AppOpsManager.MODE_ALLOWED, Collections.emptyMap());
|
||||
dummyOps.add(opEntry);
|
||||
stubOps.add(opEntry);
|
||||
addOp(entries, pkgOps, appEntry, opEntry, packageName == null,
|
||||
packageName == null ? 0 : opToOrder[opEntry.getOp()]);
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ public class SettingsBackupHelper extends BackupAgentHelper {
|
||||
|
||||
try (FileOutputStream out = new FileOutputStream(newState.getFileDescriptor())) {
|
||||
if (getVersionCode(oldState) != VERSION_CODE) {
|
||||
data.writeEntityHeader("dummy", 1);
|
||||
data.writeEntityHeader("placeholder", 1);
|
||||
data.writeEntityData(new byte[1], 1);
|
||||
}
|
||||
|
||||
|
@@ -142,7 +142,7 @@ public abstract class ProfileSelectFragment extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.dummy_preference_screen;
|
||||
return R.xml.placeholder_preference_screen;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -35,7 +35,7 @@ public class TopLevelAboutDevicePreferenceController extends BasePreferenceContr
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final DeviceNamePreferenceController deviceNamePreferenceController =
|
||||
new DeviceNamePreferenceController(mContext, "dummy_key");
|
||||
new DeviceNamePreferenceController(mContext, "unused_key");
|
||||
return deviceNamePreferenceController.getSummary();
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public class TopLevelDisplayPreferenceController extends BasePreferenceControlle
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final WallpaperPreferenceController controller =
|
||||
new WallpaperPreferenceController(mContext, "dummy_key");
|
||||
new WallpaperPreferenceController(mContext, "unused_key");
|
||||
if (controller.isAvailable()) {
|
||||
return mContext.getText(
|
||||
controller.areStylesAvailable()
|
||||
|
@@ -77,7 +77,7 @@ public class InactiveApps extends SettingsPreferenceFragment
|
||||
super.onCreate(icicle);
|
||||
|
||||
mUsageStats = getActivity().getSystemService(UsageStatsManager.class);
|
||||
addPreferencesFromResource(R.xml.dummy_preference_screen);
|
||||
addPreferencesFromResource(R.xml.placeholder_preference_screen);
|
||||
getActivity().setTitle(R.string.inactive_apps_title);
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public abstract class StyleSuggestionActivityBase extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
final PackageManager pm = getPackageManager();
|
||||
final Intent intent = new Intent()
|
||||
.setComponent(new WallpaperPreferenceController(this, "dummy key")
|
||||
.setComponent(new WallpaperPreferenceController(this, "unused key")
|
||||
.getComponentName())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
|
||||
|
@@ -69,7 +69,7 @@ public class WallpaperSuggestionActivity extends StyleSuggestionActivityBase imp
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableRaw> result = new ArrayList<>();
|
||||
WallpaperPreferenceController controller =
|
||||
new WallpaperPreferenceController(context, "dummy key");
|
||||
new WallpaperPreferenceController(context, "unused key");
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = controller.getTitle();
|
||||
data.screenTitle = data.title;
|
||||
|
@@ -60,8 +60,8 @@ import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilitySettingsTest {
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.dummy.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".dummy_a11y_service";
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.mock.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".mock_a11y_service";
|
||||
private static final ComponentName DUMMY_COMPONENT_NAME = new ComponentName(DUMMY_PACKAGE_NAME,
|
||||
DUMMY_CLASS_NAME);
|
||||
private static final int ON = 1;
|
||||
|
@@ -44,9 +44,9 @@ public final class AccessibilityUtilTest {
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
private static final String SECURE_TEST_KEY = "secure_test_key";
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.dummy.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".dummy_a11y_service";
|
||||
private static final String DUMMY_CLASS_NAME2 = DUMMY_PACKAGE_NAME + ".dummy_a11y_service2";
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.mock.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".mock_a11y_service";
|
||||
private static final String DUMMY_CLASS_NAME2 = DUMMY_PACKAGE_NAME + ".mock_a11y_service2";
|
||||
private static final ComponentName DUMMY_COMPONENT_NAME = new ComponentName(DUMMY_PACKAGE_NAME,
|
||||
DUMMY_CLASS_NAME);
|
||||
private static final ComponentName DUMMY_COMPONENT_NAME2 = new ComponentName(DUMMY_PACKAGE_NAME,
|
||||
|
@@ -35,8 +35,8 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ToggleScreenMagnificationPreferenceFragmentTest {
|
||||
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.dummy.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".dummy_a11y_service";
|
||||
private static final String DUMMY_PACKAGE_NAME = "com.mock.example";
|
||||
private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".mock_a11y_service";
|
||||
private static final ComponentName DUMMY_COMPONENT_NAME = new ComponentName(DUMMY_PACKAGE_NAME,
|
||||
DUMMY_CLASS_NAME);
|
||||
private static final String SOFTWARE_SHORTCUT_KEY =
|
||||
|
@@ -62,9 +62,9 @@ import org.robolectric.shadows.ShadowPackageManager;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AvatarViewMixinTest {
|
||||
private static final String DUMMY_ACCOUNT = "test@domain.com";
|
||||
private static final String DUMMY_DOMAIN = "domain.com";
|
||||
private static final String DUMMY_AUTHORITY = "authority.domain.com";
|
||||
private static final String FAKE_ACCOUNT = "test@domain.com";
|
||||
private static final String FAKE_DOMAIN = "domain.com";
|
||||
private static final String FAKE_AUTHORITY = "authority.domain.com";
|
||||
private static final String METHOD_GET_ACCOUNT_AVATAR = "getAccountAvatar";
|
||||
|
||||
private Context mContext;
|
||||
@@ -134,7 +134,7 @@ public class AvatarViewMixinTest {
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void onStart_noAccount_mAccountNameShouldBeNull() {
|
||||
final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);
|
||||
avatarViewMixin.mAccountName = DUMMY_ACCOUNT;
|
||||
avatarViewMixin.mAccountName = FAKE_ACCOUNT;
|
||||
|
||||
avatarViewMixin.onStart();
|
||||
|
||||
@@ -159,7 +159,7 @@ public class AvatarViewMixinTest {
|
||||
accountProvider.applicationInfo.packageName = accountProvider.packageName;
|
||||
accountProvider.providers = new ProviderInfo[1];
|
||||
accountProvider.providers[0] = new ProviderInfo();
|
||||
accountProvider.providers[0].authority = DUMMY_AUTHORITY;
|
||||
accountProvider.providers[0].authority = FAKE_AUTHORITY;
|
||||
accountProvider.providers[0].packageName = accountProvider.packageName;
|
||||
accountProvider.providers[0].name = "test.class";
|
||||
accountProvider.providers[0].applicationInfo = accountProvider.applicationInfo;
|
||||
@@ -168,22 +168,22 @@ public class AvatarViewMixinTest {
|
||||
resolveInfo.providerInfo = accountProvider.providers[0];
|
||||
shadowPackageManager.addResolveInfoForIntent(AvatarViewMixin.INTENT_GET_ACCOUNT_DATA,
|
||||
resolveInfo);
|
||||
assertThat(avatarViewMixin.queryProviderAuthority()).isEqualTo(DUMMY_AUTHORITY);
|
||||
assertThat(avatarViewMixin.queryProviderAuthority()).isEqualTo(FAKE_AUTHORITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callWithGetAccountAvatarMethod_useDummyData_shouldReturnAccountNameAndAvatar() {
|
||||
public void callWithGetAccountAvatarMethod_useFakeData_shouldReturnAccountNameAndAvatar() {
|
||||
final ContentResolver contentResolver = mContext.getContentResolver();
|
||||
final Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(
|
||||
DUMMY_AUTHORITY).build();
|
||||
FAKE_AUTHORITY).build();
|
||||
final ContentProvider mockContentProvider = mock(ContentProvider.class);
|
||||
|
||||
ShadowContentResolver.registerProviderInternal(DUMMY_AUTHORITY, mockContentProvider);
|
||||
ShadowContentResolver.registerProviderInternal(FAKE_AUTHORITY, mockContentProvider);
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
final Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
|
||||
bundle.putParcelable("account_avatar", bitmap);
|
||||
bundle.putString("account_name", DUMMY_ACCOUNT);
|
||||
bundle.putString("account_name", FAKE_ACCOUNT);
|
||||
doReturn(bundle).when(mockContentProvider).call(anyString(), anyString(),
|
||||
any(Bundle.class));
|
||||
|
||||
@@ -191,7 +191,7 @@ public class AvatarViewMixinTest {
|
||||
|
||||
final Object object = bundle.getParcelable("account_avatar");
|
||||
assertThat(object instanceof Bitmap).isTrue();
|
||||
assertThat(bundle.getString("account_name")).isEqualTo(DUMMY_ACCOUNT);
|
||||
assertThat(bundle.getString("account_name")).isEqualTo(FAKE_ACCOUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,7 +209,7 @@ public class AvatarViewMixinTest {
|
||||
|
||||
@Implementation
|
||||
protected Account[] getAccounts(Context context) {
|
||||
return new Account[]{new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
|
||||
return new Account[]{new Account(FAKE_ACCOUNT, FAKE_DOMAIN)};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,18 +55,18 @@ public class PictureInPictureDetailsTest {
|
||||
|
||||
@Test
|
||||
public void testNonPippableApp() {
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.dummypackage")).isFalse();
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.dummypackage",
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.fakepackage")).isFalse();
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.fakepackage",
|
||||
false, false, false)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPippableApp() {
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.dummypackage",
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.fakepackage",
|
||||
true)).isTrue();
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.dummypackage",
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.fakepackage",
|
||||
false, true)).isTrue();
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.dummypackage",
|
||||
assertThat(checkPackageHasPictureInPictureActivities("com.android.fakepackage",
|
||||
true, false)).isTrue();
|
||||
}
|
||||
|
||||
|
@@ -66,24 +66,30 @@ import java.util.List;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
private final ComponentName OWNER = new ComponentName("dummy", "component");
|
||||
private final ComponentName ADMIN_1 = new ComponentName("dummy", "admin1");
|
||||
private final ComponentName ADMIN_2 = new ComponentName("dummy", "admin2");
|
||||
private final String OWNER_ORGANIZATION = new String("ACME");
|
||||
private final Date TIMESTAMP = new Date(2011, 11, 11);
|
||||
private final int MY_USER_ID = UserHandle.myUserId();
|
||||
private final int MANAGED_PROFILE_USER_ID = MY_USER_ID + 1;
|
||||
private final String VPN_PACKAGE_ID = "com.example.vpn";
|
||||
private final String IME_PACKAGE_ID = "com.example.ime";
|
||||
private final String IME_PACKAGE_LABEL = "Test IME";
|
||||
private static final String OWNER_ORGANIZATION = "ACME";
|
||||
private static final String VPN_PACKAGE_ID = "com.example.vpn";
|
||||
private static final String IME_PACKAGE_ID = "com.example.ime";
|
||||
private static final String IME_PACKAGE_LABEL = "Test IME";
|
||||
|
||||
private final ComponentName mOwner = new ComponentName("mock", "component");
|
||||
private final ComponentName mAdmin1 = new ComponentName("mock", "admin1");
|
||||
private final ComponentName mAdmin2 = new ComponentName("mock", "admin2");
|
||||
private final Date mDate = new Date(2011, 11, 11);
|
||||
private final int mUserId = UserHandle.myUserId();
|
||||
private final int mManagedProfileUserId = mUserId + 1;
|
||||
|
||||
private List<UserInfo> mProfiles = new ArrayList<>();
|
||||
|
||||
private @Mock Context mContext;
|
||||
private @Mock DevicePolicyManager mDevicePolicyManager;
|
||||
private @Mock PackageManager mPackageManager;
|
||||
private @Mock UserManager mUserManager;
|
||||
private @Mock ConnectivityManager mConnectivityManger;
|
||||
@Mock
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
@Mock
|
||||
private ConnectivityManager mConnectivityManger;
|
||||
private Resources mResources;
|
||||
|
||||
private EnterprisePrivacyFeatureProvider mProvider;
|
||||
@@ -94,8 +100,8 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||
resetAndInitializePackageManager();
|
||||
when(mUserManager.getProfiles(MY_USER_ID)).thenReturn(mProfiles);
|
||||
mProfiles.add(new UserInfo(MY_USER_ID, "", "", 0 /* flags */));
|
||||
when(mUserManager.getProfiles(mUserId)).thenReturn(mProfiles);
|
||||
mProfiles.add(new UserInfo(mUserId, "", "", 0 /* flags */));
|
||||
mResources = RuntimeEnvironment.application.getResources();
|
||||
|
||||
mProvider = new EnterprisePrivacyFeatureProviderImpl(mContext, mDevicePolicyManager,
|
||||
@@ -107,16 +113,16 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
|
||||
assertThat(mProvider.hasDeviceOwner()).isFalse();
|
||||
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(mOwner);
|
||||
assertThat(mProvider.hasDeviceOwner()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInCompMode() {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(mOwner);
|
||||
assertThat(mProvider.isInCompMode()).isFalse();
|
||||
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
assertThat(mProvider.isInCompMode()).isTrue();
|
||||
}
|
||||
|
||||
@@ -139,7 +145,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
disclosure.append(mResources.getString(R.string.do_disclosure_learn_more_separator));
|
||||
disclosure.append(mResources.getString(R.string.learn_more),
|
||||
new EnterprisePrivacyFeatureProviderImpl.EnterprisePrivacySpan(mContext), 0);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(mOwner);
|
||||
when(mDevicePolicyManager.getDeviceOwnerOrganizationName()).thenReturn(null);
|
||||
assertThat(mProvider.getDeviceOwnerDisclosure()).isEqualTo(disclosure);
|
||||
|
||||
@@ -159,8 +165,8 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
assertThat(mProvider.getLastSecurityLogRetrievalTime()).isNull();
|
||||
|
||||
when(mDevicePolicyManager.getLastSecurityLogRetrievalTime())
|
||||
.thenReturn(TIMESTAMP.getTime());
|
||||
assertThat(mProvider.getLastSecurityLogRetrievalTime()).isEqualTo(TIMESTAMP);
|
||||
.thenReturn(mDate.getTime());
|
||||
assertThat(mProvider.getLastSecurityLogRetrievalTime()).isEqualTo(mDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,8 +174,8 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
when(mDevicePolicyManager.getLastBugReportRequestTime()).thenReturn(-1L);
|
||||
assertThat(mProvider.getLastBugReportRequestTime()).isNull();
|
||||
|
||||
when(mDevicePolicyManager.getLastBugReportRequestTime()).thenReturn(TIMESTAMP.getTime());
|
||||
assertThat(mProvider.getLastBugReportRequestTime()).isEqualTo(TIMESTAMP);
|
||||
when(mDevicePolicyManager.getLastBugReportRequestTime()).thenReturn(mDate.getTime());
|
||||
assertThat(mProvider.getLastBugReportRequestTime()).isEqualTo(mDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,8 +183,8 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
when(mDevicePolicyManager.getLastNetworkLogRetrievalTime()).thenReturn(-1L);
|
||||
assertThat(mProvider.getLastNetworkLogRetrievalTime()).isNull();
|
||||
|
||||
when(mDevicePolicyManager.getLastNetworkLogRetrievalTime()).thenReturn(TIMESTAMP.getTime());
|
||||
assertThat(mProvider.getLastNetworkLogRetrievalTime()).isEqualTo(TIMESTAMP);
|
||||
when(mDevicePolicyManager.getLastNetworkLogRetrievalTime()).thenReturn(mDate.getTime());
|
||||
assertThat(mProvider.getLastNetworkLogRetrievalTime()).isEqualTo(mDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,10 +207,10 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
@Test
|
||||
public void testIsAlwaysOnVpnSetInCurrentUser() {
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MY_USER_ID)).thenReturn(null);
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(mUserId)).thenReturn(null);
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInCurrentUser()).isFalse();
|
||||
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MY_USER_ID))
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(mUserId))
|
||||
.thenReturn(VPN_PACKAGE_ID);
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInCurrentUser()).isTrue();
|
||||
}
|
||||
@@ -213,13 +219,13 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
public void testIsAlwaysOnVpnSetInManagedProfileProfile() {
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isFalse();
|
||||
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MANAGED_PROFILE_USER_ID))
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(mManagedProfileUserId))
|
||||
.thenReturn(null);
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isFalse();
|
||||
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(MANAGED_PROFILE_USER_ID))
|
||||
when(mConnectivityManger.getAlwaysOnVpnPackageForUser(mManagedProfileUserId))
|
||||
.thenReturn(VPN_PACKAGE_ID);
|
||||
assertThat(mProvider.isAlwaysOnVpnSetInManagedProfile()).isTrue();
|
||||
}
|
||||
@@ -237,27 +243,27 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
@Test
|
||||
public void testGetMaximumFailedPasswordsForWipeInCurrentUser() {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(null);
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(null);
|
||||
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, MY_USER_ID))
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mUserId)).thenReturn(null);
|
||||
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(mOwner, mUserId))
|
||||
.thenReturn(10);
|
||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(0);
|
||||
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mUserId)).thenReturn(mOwner);
|
||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(10);
|
||||
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(null);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnCallingUser()).thenReturn(mOwner);
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mUserId)).thenReturn(null);
|
||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInCurrentUser()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMaximumFailedPasswordsForWipeInManagedProfile() {
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MANAGED_PROFILE_USER_ID)).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(OWNER, MANAGED_PROFILE_USER_ID))
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mManagedProfileUserId)).thenReturn(mOwner);
|
||||
when(mDevicePolicyManager.getMaximumFailedPasswordsForWipe(mOwner, mManagedProfileUserId))
|
||||
.thenReturn(10);
|
||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInManagedProfile()).isEqualTo(0);
|
||||
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
assertThat(mProvider.getMaximumFailedPasswordsBeforeWipeInManagedProfile()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@@ -267,7 +273,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
when(applicationInfo.loadLabel(mPackageManager)).thenReturn(IME_PACKAGE_LABEL);
|
||||
|
||||
Settings.Secure.putString(null, Settings.Secure.DEFAULT_INPUT_METHOD, IME_PACKAGE_ID);
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, MY_USER_ID))
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, mUserId))
|
||||
.thenReturn(applicationInfo);
|
||||
|
||||
// IME not set by Device Owner.
|
||||
@@ -281,13 +287,13 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
// Device Owner set IME to nonexistent package.
|
||||
Settings.Secure.putString(null, Settings.Secure.DEFAULT_INPUT_METHOD, IME_PACKAGE_ID);
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, MY_USER_ID))
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, mUserId))
|
||||
.thenThrow(new PackageManager.NameNotFoundException());
|
||||
assertThat(mProvider.getImeLabelIfOwnerSet()).isNull();
|
||||
|
||||
// Device Owner set IME to existent package.
|
||||
resetAndInitializePackageManager();
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, MY_USER_ID))
|
||||
when(mPackageManager.getApplicationInfoAsUser(IME_PACKAGE_ID, 0, mUserId))
|
||||
.thenReturn(applicationInfo);
|
||||
assertThat(mProvider.getImeLabelIfOwnerSet()).isEqualTo(IME_PACKAGE_LABEL);
|
||||
}
|
||||
@@ -295,7 +301,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
@Test
|
||||
public void testGetNumberOfOwnerInstalledCaCertsForCurrent() {
|
||||
final UserHandle userHandle = new UserHandle(UserHandle.USER_SYSTEM);
|
||||
final UserHandle managedProfileUserHandle = new UserHandle(MANAGED_PROFILE_USER_ID);
|
||||
final UserHandle managedProfileUserHandle = new UserHandle(mManagedProfileUserId);
|
||||
|
||||
when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
|
||||
.thenReturn(Arrays.asList("ca1", "ca2"));
|
||||
@@ -317,9 +323,9 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
@Test
|
||||
public void testGetNumberOfOwnerInstalledCaCertsForManagedProfile() {
|
||||
final UserHandle userHandle = new UserHandle(UserHandle.USER_SYSTEM);
|
||||
final UserHandle managedProfileUserHandle = new UserHandle(MANAGED_PROFILE_USER_ID);
|
||||
final UserHandle managedProfileUserHandle = new UserHandle(mManagedProfileUserId);
|
||||
final UserInfo managedProfile =
|
||||
new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE);
|
||||
new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE);
|
||||
|
||||
// Without a profile
|
||||
when(mDevicePolicyManager.getOwnerInstalledCaCerts(managedProfileUserHandle))
|
||||
@@ -345,15 +351,15 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
@Test
|
||||
public void testGetNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile() {
|
||||
when(mDevicePolicyManager.getActiveAdminsAsUser(MY_USER_ID))
|
||||
.thenReturn(Arrays.asList(ADMIN_1, ADMIN_2));
|
||||
when(mDevicePolicyManager.getActiveAdminsAsUser(MANAGED_PROFILE_USER_ID))
|
||||
.thenReturn(Arrays.asList(ADMIN_1));
|
||||
when(mDevicePolicyManager.getActiveAdminsAsUser(mUserId))
|
||||
.thenReturn(Arrays.asList(mAdmin1, mAdmin2));
|
||||
when(mDevicePolicyManager.getActiveAdminsAsUser(mManagedProfileUserId))
|
||||
.thenReturn(Arrays.asList(mAdmin1));
|
||||
|
||||
assertThat(mProvider.getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile())
|
||||
.isEqualTo(2);
|
||||
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
assertThat(mProvider.getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile())
|
||||
.isEqualTo(3);
|
||||
}
|
||||
@@ -362,7 +368,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
public void workPolicyInfo_unmanagedDevice_shouldDoNothing() {
|
||||
// Even if we have the intent resolved, don't show it if there's no DO or PO
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
|
||||
addWorkPolicyInfoIntent(OWNER.getPackageName(), true, false);
|
||||
addWorkPolicyInfoIntent(mOwner.getPackageName(), true, false);
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
|
||||
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isFalse();
|
||||
@@ -372,12 +378,12 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
@Test
|
||||
public void workPolicyInfo_deviceOwner_shouldResolveIntent() {
|
||||
// If the intent is not resolved, then there's no info to show for DO
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(mOwner);
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isFalse();
|
||||
|
||||
// If the intent is resolved, then we can use it to launch the activity
|
||||
Intent intent = addWorkPolicyInfoIntent(OWNER.getPackageName(), true, false);
|
||||
Intent intent = addWorkPolicyInfoIntent(mOwner.getPackageName(), true, false);
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isTrue();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isTrue();
|
||||
verify(mContext).startActivity(intentEquals(intent));
|
||||
@@ -386,35 +392,35 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
@Test
|
||||
public void workPolicyInfo_profileOwner_shouldResolveIntent() {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MANAGED_PROFILE_USER_ID)).thenReturn(OWNER);
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mManagedProfileUserId)).thenReturn(mOwner);
|
||||
|
||||
// If the intent is not resolved, then there's no info to show for PO
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isFalse();
|
||||
|
||||
// If the intent is resolved, then we can use it to launch the activity in managed profile
|
||||
Intent intent = addWorkPolicyInfoIntent(OWNER.getPackageName(), false, true);
|
||||
Intent intent = addWorkPolicyInfoIntent(mOwner.getPackageName(), false, true);
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isTrue();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isTrue();
|
||||
verify(mContext)
|
||||
.startActivityAsUser(
|
||||
intentEquals(intent),
|
||||
argThat(handle -> handle.getIdentifier() == MANAGED_PROFILE_USER_ID));
|
||||
argThat(handle -> handle.getIdentifier() == mManagedProfileUserId));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workPolicyInfo_comp_shouldUseDeviceOwnerIntent() {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(OWNER);
|
||||
mProfiles.add(new UserInfo(MANAGED_PROFILE_USER_ID, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(MY_USER_ID)).thenReturn(OWNER);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(mOwner);
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mUserId)).thenReturn(mOwner);
|
||||
|
||||
// If the intent is not resolved, then there's no info to show for COMP
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isFalse();
|
||||
|
||||
// If the intent is resolved, then we can use it to launch the activity for device owner
|
||||
Intent intent = addWorkPolicyInfoIntent(OWNER.getPackageName(), true, true);
|
||||
Intent intent = addWorkPolicyInfoIntent(mOwner.getPackageName(), true, true);
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isTrue();
|
||||
assertThat(mProvider.showWorkPolicyInfo()).isTrue();
|
||||
verify(mContext).startActivity(intentEquals(intent));
|
||||
@@ -437,7 +443,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
}
|
||||
if (profileOwner) {
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(
|
||||
intentEquals(intent), anyInt(), eq(MANAGED_PROFILE_USER_ID)))
|
||||
intentEquals(intent), anyInt(), eq(mManagedProfileUserId)))
|
||||
.thenReturn(activities);
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,7 @@ public class BatteryInfoTest {
|
||||
"1 min left until charged";
|
||||
private static final String TEST_BATTERY_LEVEL_10 = "10%";
|
||||
private static final String FIFTEEN_MIN_FORMATTED = "15 min";
|
||||
private static final Estimate DUMMY_ESTIMATE = new Estimate(
|
||||
private static final Estimate MOCK_ESTIMATE = new Estimate(
|
||||
1000, /* estimateMillis */
|
||||
false, /* isBasedOnUsage */
|
||||
1000 /* averageDischargeTime */);
|
||||
@@ -211,10 +211,10 @@ public class BatteryInfoTest {
|
||||
@Test
|
||||
public void testGetBatteryInfo_basedOnUsageFalse_usesDefaultString() {
|
||||
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
|
||||
mBatteryStats, DUMMY_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
mBatteryStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
false /* shortString */);
|
||||
BatteryInfo info2 = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
|
||||
mBatteryStats, DUMMY_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
mBatteryStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
true /* shortString */);
|
||||
|
||||
assertThat(info.remainingLabel.toString()).doesNotContain(ENHANCED_STRING_SUFFIX);
|
||||
@@ -228,7 +228,7 @@ public class BatteryInfoTest {
|
||||
.computeChargeTimeRemaining(anyLong());
|
||||
|
||||
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mChargingBatteryBroadcast,
|
||||
mBatteryStats, DUMMY_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
mBatteryStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
false /* shortString */);
|
||||
assertThat(info.remainingTimeUs).isEqualTo(TEST_CHARGE_TIME_REMAINING);
|
||||
assertThat(info.remainingLabel.toString())
|
||||
@@ -240,7 +240,7 @@ public class BatteryInfoTest {
|
||||
mChargingBatteryBroadcast.putExtra(BatteryManager.EXTRA_LEVEL, 100);
|
||||
|
||||
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mChargingBatteryBroadcast,
|
||||
mBatteryStats, DUMMY_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
mBatteryStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
|
||||
false /* shortString */);
|
||||
|
||||
assertThat(info.chargeLabel).isEqualTo("100%");
|
||||
|
@@ -44,7 +44,7 @@ public class CarrierSettingsVersionPreferenceControllerTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
mController = new CarrierSettingsVersionPreferenceController(context, "dummy_key");
|
||||
mController = new CarrierSettingsVersionPreferenceController(context, "mock_key");
|
||||
mController.init(mSubscriptionId);
|
||||
mCarrierConfigManager = Shadows.shadowOf(
|
||||
context.getSystemService(CarrierConfigManager.class));
|
||||
|
@@ -93,7 +93,7 @@ public class CreateShortcutPreferenceControllerTest {
|
||||
final Intent intent = new Intent(CreateShortcutPreferenceController.SHORTCUT_PROBE)
|
||||
.setClass(mContext, Settings.ManageApplicationsActivity.class);
|
||||
final ResolveInfo ri = mContext.getPackageManager().resolveActivity(intent, 0);
|
||||
final Intent result = mController.createResultIntent(intent, ri, "dummy");
|
||||
final Intent result = mController.createResultIntent(intent, ri, "mock");
|
||||
|
||||
assertThat(result.getStringExtra("d1")).isEqualTo("d2");
|
||||
assertThat((Object) result.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)).isNotNull();
|
||||
|
@@ -215,7 +215,7 @@ public class SettingsSliceProviderTest {
|
||||
|
||||
@Test
|
||||
public void testLoadSlice_cachedEntryRemovedOnBuild() {
|
||||
SliceData data = getDummyData();
|
||||
SliceData data = getMockData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
SliceTestUtils.insertSliceToDb(mContext, data.getKey());
|
||||
@@ -229,7 +229,7 @@ public class SettingsSliceProviderTest {
|
||||
public void onBindSlice_mainThread_shouldNotOverrideStrictMode() {
|
||||
ShadowThreadUtils.setIsMainThread(true);
|
||||
final StrictMode.ThreadPolicy oldThreadPolicy = StrictMode.getThreadPolicy();
|
||||
SliceData data = getDummyData();
|
||||
SliceData data = getMockData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
@@ -243,7 +243,7 @@ public class SettingsSliceProviderTest {
|
||||
public void onBindSlice_backgroundThread_shouldOverrideStrictMode() {
|
||||
ShadowThreadUtils.setIsMainThread(false);
|
||||
|
||||
SliceData data = getDummyData();
|
||||
SliceData data = getMockData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
@@ -271,7 +271,7 @@ public class SettingsSliceProviderTest {
|
||||
@Test
|
||||
public void onBindSlice_nightModeChanged_shouldReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
final SliceData data = getDummyData();
|
||||
final SliceData data = getMockData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
@@ -284,7 +284,7 @@ public class SettingsSliceProviderTest {
|
||||
@Test
|
||||
public void onBindSlice_nightModeNotChanged_shouldNotReloadTheme() {
|
||||
mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
|
||||
SliceData data = getDummyData();
|
||||
SliceData data = getMockData();
|
||||
mProvider.mSliceWeakDataCache.put(data.getUri(), data);
|
||||
mProvider.onBindSlice(data.getUri());
|
||||
|
||||
@@ -696,7 +696,7 @@ public class SettingsSliceProviderTest {
|
||||
assertThat(mProvider.isPrivateSlicesNeeded(uri)).isFalse();
|
||||
}
|
||||
|
||||
private static SliceData getDummyData() {
|
||||
private static SliceData getMockData() {
|
||||
return new SliceData.Builder()
|
||||
.setKey(KEY)
|
||||
.setUri(URI)
|
||||
|
@@ -87,7 +87,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void buildIntentSlice_returnsMatchingSlice() {
|
||||
final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT);
|
||||
final SliceData sliceData = getMockData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT);
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
|
||||
|
||||
SliceTester.testSettingsIntentSlice(mContext, slice, sliceData);
|
||||
@@ -95,21 +95,21 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void buildToggleSlice_returnsMatchingSlice() {
|
||||
final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH);
|
||||
final SliceData mockData = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, dummyData);
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, mockData);
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsEvent.ACTION_SETTINGS_SLICE_REQUESTED,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
dummyData.getKey(),
|
||||
mockData.getKey(),
|
||||
0);
|
||||
SliceTester.testSettingsToggleSlice(mContext, slice, dummyData);
|
||||
SliceTester.testSettingsToggleSlice(mContext, slice, mockData);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildSliderSlice_returnsMatchingSlice() {
|
||||
final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER);
|
||||
final SliceData data = getMockData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
@@ -123,22 +123,22 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void buildCopyableSlice_returnsMatchingSlice() {
|
||||
final SliceData dummyData = getDummyData(COPYABLE_CONTROLLER, -1);
|
||||
final SliceData mockData = getMockData(COPYABLE_CONTROLLER, -1);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, dummyData);
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, mockData);
|
||||
verify(mFeatureFactory.metricsFeatureProvider)
|
||||
.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsEvent.ACTION_SETTINGS_SLICE_REQUESTED,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
dummyData.getKey(),
|
||||
mockData.getKey(),
|
||||
0);
|
||||
SliceTester.testSettingsCopyableSlice(mContext, slice, dummyData);
|
||||
SliceTester.testSettingsCopyableSlice(mContext, slice, mockData);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPreferenceController_buildsMatchingController() {
|
||||
final BasePreferenceController controller =
|
||||
SliceBuilderUtils.getPreferenceController(mContext, getDummyData());
|
||||
SliceBuilderUtils.getPreferenceController(mContext, getMockData());
|
||||
|
||||
assertThat(controller).isInstanceOf(FakeToggleController.class);
|
||||
}
|
||||
@@ -147,14 +147,14 @@ public class SliceBuilderUtilsTest {
|
||||
public void testGetPreferenceController_contextOnly_buildsMatchingController() {
|
||||
final BasePreferenceController controller =
|
||||
SliceBuilderUtils.getPreferenceController(mContext,
|
||||
getDummyData(CONTEXT_CONTROLLER, 0));
|
||||
getMockData(CONTEXT_CONTROLLER, 0));
|
||||
|
||||
assertThat(controller).isInstanceOf(FakeContextOnlyPreferenceController.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDynamicSummary_allowDynamicSummary_returnsControllerSummary() {
|
||||
final SliceData data = getDummyData();
|
||||
final SliceData data = getMockData();
|
||||
final FakePreferenceController controller = spy(
|
||||
new FakePreferenceController(mContext, KEY));
|
||||
final String controllerSummary = "new_Summary";
|
||||
@@ -167,7 +167,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getDynamicSummary_allowDynamicSummary_nullSummary_returnsNull() {
|
||||
final SliceData data = getDummyData();
|
||||
final SliceData data = getMockData();
|
||||
final FakePreferenceController controller = spy(
|
||||
new FakePreferenceController(mContext, KEY));
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getDynamicSummary_noScreenTitle_returnsPrefControllerSummary() {
|
||||
final SliceData data = getDummyData("", "");
|
||||
final SliceData data = getMockData("", "");
|
||||
final FakePreferenceController controller = spy(
|
||||
new FakePreferenceController(mContext, KEY));
|
||||
final String controllerSummary = "new_Summary";
|
||||
@@ -193,7 +193,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getDynamicSummary_screenTitleMatchesTitle_returnsPrefControllerSummary() {
|
||||
final SliceData data = getDummyData("", TITLE);
|
||||
final SliceData data = getMockData("", TITLE);
|
||||
final FakePreferenceController controller = spy(
|
||||
new FakePreferenceController(mContext, KEY));
|
||||
final String controllerSummary = "new_Summary";
|
||||
@@ -206,7 +206,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getDynamicSummary_emptyScreenTitle_emptyControllerSummary_returnsEmptyString() {
|
||||
final SliceData data = getDummyData(null, null);
|
||||
final SliceData data = getMockData(null, null);
|
||||
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
|
||||
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class SliceBuilderUtilsTest {
|
||||
@Test
|
||||
public void getDynamicSummary_screenTitleAndControllerPlaceholder_returnsSliceEmptyString() {
|
||||
final String summaryPlaceholder = mContext.getString(R.string.summary_placeholder);
|
||||
final SliceData data = getDummyData(summaryPlaceholder, summaryPlaceholder);
|
||||
final SliceData data = getMockData(summaryPlaceholder, summaryPlaceholder);
|
||||
final FakePreferenceController controller = spy(
|
||||
new FakePreferenceController(mContext, KEY));
|
||||
doReturn(summaryPlaceholder).when(controller).getSummary();
|
||||
@@ -283,7 +283,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testUnsupportedSlice_validTitleSummary() {
|
||||
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
|
||||
final SliceData data = getMockData(FakeUnavailablePreferenceController.class,
|
||||
SliceData.SliceType.SWITCH);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
|
||||
@@ -296,7 +296,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testDisabledForUserSlice_validTitleSummary() {
|
||||
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
|
||||
final SliceData data = getMockData(FakeUnavailablePreferenceController.class,
|
||||
SliceData.SliceType.SWITCH);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
|
||||
@@ -309,7 +309,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testDisabledDependentSettingSlice_validTitleSummary() {
|
||||
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
|
||||
final SliceData data = getMockData(FakeUnavailablePreferenceController.class,
|
||||
SliceData.SliceType.INTENT);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
|
||||
@@ -329,7 +329,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testConditionallyUnavailableSlice_validTitleSummary() {
|
||||
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
|
||||
final SliceData data = getMockData(FakeUnavailablePreferenceController.class,
|
||||
SliceData.SliceType.SWITCH);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
|
||||
@@ -347,7 +347,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testContentIntent_includesUniqueData() {
|
||||
final SliceData sliceData = getDummyData();
|
||||
final SliceData sliceData = getMockData();
|
||||
final Uri expectedUri = new Uri.Builder().appendPath(sliceData.getKey()).build();
|
||||
|
||||
final Intent intent = SliceBuilderUtils.getContentIntent(mContext, sliceData);
|
||||
@@ -360,7 +360,7 @@ public class SliceBuilderUtilsTest {
|
||||
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
|
||||
final int expectedIconResource = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_settings_accent).toIcon().getResId();
|
||||
final SliceData sliceData = getDummyData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT,
|
||||
final SliceData sliceData = getMockData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT,
|
||||
0x0);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
|
||||
@@ -375,7 +375,7 @@ public class SliceBuilderUtilsTest {
|
||||
public void buildDisabledDependentSlice_noIconPassed_returnsSliceWithIcon() {
|
||||
final int expectedIconResource = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_settings_accent).toIcon().getResId();
|
||||
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
|
||||
final SliceData data = getMockData(FakeUnavailablePreferenceController.class,
|
||||
SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
|
||||
null /* unavailableSliceSubtitle */);
|
||||
Settings.Global.putInt(mContext.getContentResolver(),
|
||||
@@ -394,10 +394,10 @@ public class SliceBuilderUtilsTest {
|
||||
public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
|
||||
final int expectedIconResource = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_settings_accent).toIcon().getResId();
|
||||
final SliceData dummyData = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
final SliceData mockData = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
0x0);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, dummyData);
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, mockData);
|
||||
|
||||
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
|
||||
final SliceAction primaryAction = metadata.getPrimaryAction();
|
||||
@@ -409,7 +409,7 @@ public class SliceBuilderUtilsTest {
|
||||
public void buildSliderSlice_noIconPassed_returnsSliceWithIcon() {
|
||||
final int expectedIconResource = IconCompat.createWithResource(mContext,
|
||||
R.drawable.ic_settings_accent).toIcon().getResId();
|
||||
final SliceData data = getDummyData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
|
||||
final SliceData data = getMockData(SLIDER_CONTROLLER, SliceData.SliceType.SLIDER, 0x0);
|
||||
|
||||
final Slice slice = SliceBuilderUtils.buildSlice(mContext, data);
|
||||
|
||||
@@ -421,7 +421,7 @@ public class SliceBuilderUtilsTest {
|
||||
|
||||
@Test
|
||||
public void buildSliderSlice_invalidSlider_returnNull() {
|
||||
final SliceData data = getDummyData(INVALID_SLIDER_CONTROLLER, SliceData.SliceType.SLIDER,
|
||||
final SliceData data = getMockData(INVALID_SLIDER_CONTROLLER, SliceData.SliceType.SLIDER,
|
||||
0x0 /* icon */);
|
||||
|
||||
assertThat(SliceBuilderUtils.buildSlice(mContext, data)).isNull();
|
||||
@@ -431,7 +431,7 @@ public class SliceBuilderUtilsTest {
|
||||
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
|
||||
final int settingsIcon = R.drawable.ic_settings_accent;
|
||||
final int zeroIcon = 0x0;
|
||||
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
final SliceData data = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
zeroIcon);
|
||||
|
||||
final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
|
||||
@@ -445,7 +445,7 @@ public class SliceBuilderUtilsTest {
|
||||
public void getSafeIcon_invalidResource_shouldFallbackToSettingsIcon() {
|
||||
final int settingsIcon = R.drawable.ic_settings_accent;
|
||||
final int badIcon = 0x12345678;
|
||||
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
final SliceData data = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH,
|
||||
badIcon);
|
||||
|
||||
final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
|
||||
@@ -454,27 +454,27 @@ public class SliceBuilderUtilsTest {
|
||||
assertThat(actualIconResource).isEqualTo(settingsIcon);
|
||||
}
|
||||
|
||||
private SliceData getDummyData() {
|
||||
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
|
||||
private SliceData getMockData() {
|
||||
return getMockData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
|
||||
ICON, null /* unavailableSliceSubtitle */);
|
||||
}
|
||||
|
||||
private SliceData getDummyData(Class prefController, int sliceType, int icon) {
|
||||
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE,
|
||||
private SliceData getMockData(Class prefController, int sliceType, int icon) {
|
||||
return getMockData(prefController, SUMMARY, sliceType, SCREEN_TITLE,
|
||||
icon, null /* unavailableSliceSubtitle */);
|
||||
}
|
||||
|
||||
private SliceData getDummyData(String summary, String screenTitle) {
|
||||
return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle,
|
||||
private SliceData getMockData(String summary, String screenTitle) {
|
||||
return getMockData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle,
|
||||
ICON, null /* unavailableSliceSubtitle */);
|
||||
}
|
||||
|
||||
private SliceData getDummyData(Class prefController, int sliceType) {
|
||||
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE, ICON,
|
||||
private SliceData getMockData(Class prefController, int sliceType) {
|
||||
return getMockData(prefController, SUMMARY, sliceType, SCREEN_TITLE, ICON,
|
||||
null /* unavailableSliceSubtitle */);
|
||||
}
|
||||
|
||||
private SliceData getDummyData(Class prefController, String summary, int sliceType,
|
||||
private SliceData getMockData(Class prefController, String summary, int sliceType,
|
||||
String screenTitle, int icon, String unavailableSliceSubtitle) {
|
||||
return new SliceData.Builder()
|
||||
.setKey(KEY)
|
||||
|
@@ -83,9 +83,9 @@ public class SlicesDatabaseHelperTest {
|
||||
|
||||
@Test
|
||||
public void testUpgrade_dropsOldData() {
|
||||
ContentValues dummyValues = getDummyRow();
|
||||
ContentValues mockValues = getMockRow();
|
||||
|
||||
mDatabase.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, dummyValues);
|
||||
mDatabase.replaceOrThrow(SlicesDatabaseHelper.Tables.TABLE_SLICES_INDEX, null, mockValues);
|
||||
Cursor baseline = mDatabase.rawQuery("SELECT * FROM slices_index", null);
|
||||
assertThat(baseline.getCount()).isEqualTo(1);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class SlicesDatabaseHelperTest {
|
||||
assertThat(mSlicesDatabaseHelper.isSliceDataIndexed()).isFalse();
|
||||
}
|
||||
|
||||
private ContentValues getDummyRow() {
|
||||
private ContentValues getMockRow() {
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(IndexColumns.KEY, "key");
|
||||
values.put(IndexColumns.TITLE, "title");
|
||||
|
@@ -106,7 +106,7 @@ public class SlicesIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testInsertSliceData_nonPublicSlice_mockDataInserted() {
|
||||
final List<SliceData> sliceData = getDummyIndexableData(false);
|
||||
final List<SliceData> sliceData = getMockIndexableData(false);
|
||||
doReturn(sliceData).when(mManager).getSliceData();
|
||||
|
||||
mManager.run();
|
||||
@@ -151,7 +151,7 @@ public class SlicesIndexerTest {
|
||||
|
||||
@Test
|
||||
public void insertSliceData_publicSlice_mockDataInserted() {
|
||||
final List<SliceData> sliceData = getDummyIndexableData(true);
|
||||
final List<SliceData> sliceData = getMockIndexableData(true);
|
||||
doReturn(sliceData).when(mManager).getSliceData();
|
||||
|
||||
mManager.run();
|
||||
@@ -209,7 +209,7 @@ public class SlicesIndexerTest {
|
||||
db.close();
|
||||
}
|
||||
|
||||
private List<SliceData> getDummyIndexableData(boolean isPublicSlice) {
|
||||
private List<SliceData> getMockIndexableData(boolean isPublicSlice) {
|
||||
final List<SliceData> sliceData = new ArrayList<>();
|
||||
final SliceData.Builder builder = new SliceData.Builder()
|
||||
.setSummary(SUMMARY)
|
||||
|
Reference in New Issue
Block a user