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());
}
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());
}
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();
}
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();
}
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());
}
Aggregations