Use settingslib util methods for work policy info
Bug: b/229889270 Test: make ROBOTEST_FILTER=EnterprisePrivacyFeatureProviderImplTest RunSettingsRoboTests -j40 Change-Id: I0d968732a4dd601955e18b2ebb2af365638b450f
This commit is contained in:
@@ -377,10 +377,22 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workPolicyInfo_profileOwner_shouldResolveIntent() {
|
||||
public void workPolicyInfo_profileOwner_shouldResolveIntent()
|
||||
throws PackageManager.NameNotFoundException {
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn(null);
|
||||
mProfiles.add(new UserInfo(mManagedProfileUserId, "", "", UserInfo.FLAG_MANAGED_PROFILE));
|
||||
when(mDevicePolicyManager.getProfileOwnerAsUser(mManagedProfileUserId)).thenReturn(mOwner);
|
||||
List<UserHandle> mAllProfiles = new ArrayList<>();
|
||||
mAllProfiles.add(new UserHandle(mManagedProfileUserId));
|
||||
when(mUserManager.getAllProfiles()).thenReturn(mAllProfiles);
|
||||
when(mUserManager.isManagedProfile(mManagedProfileUserId)).thenReturn(true);
|
||||
when(mContext.getPackageName()).thenReturn("somePackageName");
|
||||
when(mContext.createPackageContextAsUser(
|
||||
eq(mContext.getPackageName()),
|
||||
anyInt(),
|
||||
any(UserHandle.class))
|
||||
).thenReturn(mContext);
|
||||
when(mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||
.thenReturn(mDevicePolicyManager);
|
||||
when(mDevicePolicyManager.getProfileOwner()).thenReturn(mOwner);
|
||||
|
||||
// If the intent is not resolved, then there's no info to show for PO
|
||||
assertThat(mProvider.hasWorkPolicyInfo()).isFalse();
|
||||
@@ -441,7 +453,7 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
}
|
||||
if (profileOwner) {
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(
|
||||
intentEquals(intent), anyInt(), eq(mManagedProfileUserId)))
|
||||
intentEquals(intent), anyInt(), eq(UserHandle.of(mManagedProfileUserId))))
|
||||
.thenReturn(activities);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user