Search in sources :

Example 16 with ShadowUserManager

use of com.android.settings.testutils.shadow.ShadowUserManager in project android_packages_apps_Settings by omnirom.

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 = createAdminSupportTextView(view, mActivity);
    dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
    dpmShadow.setIsAdminActiveAsUser(true);
    createShadowWorkProfile(userManagerShadow);
    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) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) TextView(android.widget.TextView) Test(org.junit.Test)

Example 17 with ShadowUserManager

use of com.android.settings.testutils.shadow.ShadowUserManager in project android_packages_apps_Settings by omnirom.

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 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 = createAdminSupportTextView(view, mActivity);
    dpmShadow.setShortSupportMessageForUser(component, 123, "some message");
    dpmShadow.setIsAdminActiveAsUser(false);
    userManagerShadow.addProfile(new UserInfo(123, null, 0));
    mHelper.setAdminSupportDetails(mActivity, textView, admin);
    assertNull(admin.component);
    assertEquals(mActivity.getString(R.string.default_admin_support_msg), 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) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) TextView(android.widget.TextView) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 18 with ShadowUserManager

use of com.android.settings.testutils.shadow.ShadowUserManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountDetailDashboardFragmentTest method onResume_accountPresentOneProfile_shouldNotFinish.

@Test
public void onResume_accountPresentOneProfile_shouldNotFinish() {
    ShadowUserManager userManager = Shadow.extract(mContext.getSystemService(UserManager.class));
    userManager.addUserProfile(new UserHandle(1));
    ShadowAccountManager.addAccountForUser(1, mFragment.mAccount);
    mFragment.finishIfAccountMissing();
    verify(mFragment, never()).finish();
}
Also used : ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserManager(android.os.UserManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserHandle(android.os.UserHandle) Test(org.junit.Test)

Example 19 with ShadowUserManager

use of com.android.settings.testutils.shadow.ShadowUserManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccountDetailDashboardFragmentTest method onResume_accountPresentTwoProfiles_shouldNotFinish.

@Test
public void onResume_accountPresentTwoProfiles_shouldNotFinish() {
    ShadowUserManager userManager = Shadow.extract(mContext.getSystemService(UserManager.class));
    userManager.addUserProfile(new UserHandle(1));
    userManager.addUserProfile(new UserHandle(2));
    ShadowAccountManager.addAccountForUser(1, new Account("test@test.com", "com.test"));
    ShadowAccountManager.addAccountForUser(2, mFragment.mAccount);
    mFragment.finishIfAccountMissing();
    verify(mFragment, never()).finish();
}
Also used : ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) Account(android.accounts.Account) UserManager(android.os.UserManager) ShadowUserManager(com.android.settings.testutils.shadow.ShadowUserManager) UserHandle(android.os.UserHandle) Test(org.junit.Test)

Example 20 with ShadowUserManager

use of com.android.settings.testutils.shadow.ShadowUserManager in project android_packages_apps_Settings by omnirom.

the class ActionDisabledByAdminDialogHelperTest method testSetAdminSupportDetails_shortSupportMessageIsNull.

@Test
public void testSetAdminSupportDetails_shortSupportMessageIsNull() {
    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 = createAdminSupportTextView(view, mActivity);
    dpmShadow.setShortSupportMessageForUser(component, 123, null);
    dpmShadow.setIsAdminActiveAsUser(true);
    createShadowWorkProfile(userManagerShadow);
    mHelper.setAdminSupportDetails(mActivity, view, admin);
    assertNotNull(admin.component);
    assertEquals(mActivity.getString(R.string.default_admin_support_msg), 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) ComponentName(android.content.ComponentName) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) TextView(android.widget.TextView) Test(org.junit.Test)

Aggregations

UserManager (android.os.UserManager)22 ShadowUserManager (com.android.settings.testutils.shadow.ShadowUserManager)22 Test (org.junit.Test)21 UserHandle (android.os.UserHandle)7 ComponentName (android.content.ComponentName)6 ContextWrapper (android.content.ContextWrapper)6 ApplicationInfo (android.content.pm.ApplicationInfo)6 AppStateInstallAppsBridge (com.android.settings.applications.AppStateInstallAppsBridge)6 InstallAppsState (com.android.settings.applications.AppStateInstallAppsBridge.InstallAppsState)6 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)6 ShadowDevicePolicyManager (com.android.settings.testutils.shadow.ShadowDevicePolicyManager)5 Account (android.accounts.Account)4 UserInfo (android.content.pm.UserInfo)4 ViewGroup (android.view.ViewGroup)4 FrameLayout (android.widget.FrameLayout)4 TextView (android.widget.TextView)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ConnectivityManager (android.net.ConnectivityManager)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 ShadowConnectivityManager (com.android.settings.testutils.shadow.ShadowConnectivityManager)2