Launch DO/PO sepecific settings when parental are enabled.
Test: make RunSettingsRoboTests && manual Bug: 161861348 Change-Id: I73ce27d0aa740f47e6ed3e4be9bee4d5eaf039ad
This commit is contained in:
@@ -63,6 +63,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
|
||||
@@ -426,6 +427,17 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
verify(mContext).startActivity(intentEquals(intent));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowParentalControls() {
|
||||
when(mDevicePolicyManager.getProfileOwnerOrDeviceOwnerSupervisionComponent(any()))
|
||||
.thenReturn(mOwner);
|
||||
|
||||
// If the intent is resolved, then we can use it to launch the activity
|
||||
Intent intent = addParentalControlsIntent(mOwner.getPackageName());
|
||||
assertThat(mProvider.showParentalControls()).isTrue();
|
||||
verify(mContext).startActivity(intentEquals(intent));
|
||||
}
|
||||
|
||||
private Intent addWorkPolicyInfoIntent(
|
||||
String packageName, boolean deviceOwner, boolean profileOwner) {
|
||||
Intent intent = new Intent(Settings.ACTION_SHOW_WORK_POLICY_INFO);
|
||||
@@ -450,6 +462,23 @@ public class EnterprisePrivacyFeatureProviderImplTest {
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent addParentalControlsIntent(String packageName) {
|
||||
Intent intent = new Intent(EnterprisePrivacyFeatureProviderImpl.ACTION_PARENTAL_CONTROLS);
|
||||
intent.setPackage(packageName);
|
||||
ResolveInfo resolveInfo = new ResolveInfo();
|
||||
resolveInfo.resolvePackageName = packageName;
|
||||
resolveInfo.activityInfo = new ActivityInfo();
|
||||
resolveInfo.activityInfo.name = "activityName";
|
||||
resolveInfo.activityInfo.packageName = packageName;
|
||||
|
||||
List<ResolveInfo> activities = ImmutableList.of(resolveInfo);
|
||||
when(mPackageManager.queryIntentActivities(intentEquals(intent), anyInt()))
|
||||
.thenReturn(activities);
|
||||
when(mPackageManager.queryIntentActivitiesAsUser(intentEquals(intent), anyInt(), anyInt()))
|
||||
.thenReturn(activities);
|
||||
return intent;
|
||||
}
|
||||
|
||||
private static class IntentMatcher implements ArgumentMatcher<Intent> {
|
||||
private final Intent mExpectedIntent;
|
||||
|
||||
|
Reference in New Issue
Block a user