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