use of com.android.settings.testutils.shadow.ShadowDevicePolicyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ActionDisabledByAdminDialogHelperTest method testSetAdminSupportDetailsNotAdmin.
@Test
public void testSetAdminSupportDetailsNotAdmin() {
final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
final UserManager userManager = RuntimeEnvironment.application.getSystemService(UserManager.class);
final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
final ComponentName component = new ComponentName("some.package.name", "some.package.name.SomeClass");
final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
dpmShadow.setIsAdminActiveAsUser(false);
userManagerShadow.addProfile(new UserInfo(123, null, 0));
mHelper.setAdminSupportDetails(mActivity, null, admin);
assertNull(admin.component);
}
use of com.android.settings.testutils.shadow.ShadowDevicePolicyManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ActionDisabledByAdminDialogHelperTest method testSetAdminSupportDetails.
@Test
public void testSetAdminSupportDetails() {
final ShadowDevicePolicyManager dpmShadow = ShadowDevicePolicyManager.getShadow();
final UserManager userManager = RuntimeEnvironment.application.getSystemService(UserManager.class);
final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
final ViewGroup view = new FrameLayout(mActivity);
final ComponentName component = new ComponentName("some.package.name", "some.package.name.SomeClass");
final EnforcedAdmin admin = new EnforcedAdmin(component, UserHandle.of(123));
final TextView textView = new TextView(mActivity);
textView.setId(R.id.admin_support_msg);
view.addView(textView);
dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
dpmShadow.setIsAdminActiveAsUser(true);
userManagerShadow.addProfile(new UserInfo(123, null, 0));
userManagerShadow.addUserProfile(new UserHandle(123));
ShadowProcess.setUid(Process.SYSTEM_UID);
mHelper.setAdminSupportDetails(mActivity, view, admin);
assertNotNull(admin.component);
assertEquals("some message", Shadows.shadowOf(textView).innerText());
}
Aggregations