Search in sources :

Example 1 with ShadowDevicePolicyManager

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);
}
Also used : ShadowDevicePolicyManager(com.android.settings.testutils.shadow.ShadowDevicePolicyManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserManager(android.os.UserManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 2 with ShadowDevicePolicyManager

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());
}
Also used : ShadowDevicePolicyManager(com.android.settings.testutils.shadow.ShadowDevicePolicyManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserManager(android.os.UserManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) TextView(android.widget.TextView) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Aggregations

ComponentName (android.content.ComponentName)2 UserInfo (android.content.pm.UserInfo)2 UserManager (android.os.UserManager)2 ShadowDevicePolicyManager (com.android.settings.testutils.shadow.ShadowDevicePolicyManager)2 ShadowUserManager (com.android.settings.testutils.shadow.ShadowUserManager)2 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)2 Test (org.junit.Test)2 UserHandle (android.os.UserHandle)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1