Prepare tests for impending robolectric merge

Some ShadowUserManager function moved into the basic shadow in
robolectric proper and has been removed from the Settings
ShadowUserManager.

Test: make -j56 RunSettingsRoboTests
Change-Id: I38647dae5d16bc79bc7925ca139c9362a2035393
This commit is contained in:
James Lemieux
2018-11-20 14:26:31 -08:00
parent f611fe8689
commit 3a55de44c5
31 changed files with 125 additions and 198 deletions

View File

@@ -166,11 +166,11 @@ public class AccountDetailDashboardFragmentTest {
public void onResume_accountMissing_shouldFinish() {
ShadowUserManager userManager = Shadow.extract(
mContext.getSystemService(UserManager.class));
ShadowAccountManager acctMgr = Shadow.extract(
ShadowAccountManager accountManager = Shadow.extract(
mContext.getSystemService(AccountManager.class));
userManager.addProfile(new UserInfo(1, null, 0));
acctMgr.addAccountForUser(1, new Account("test@test.com", "com.test"));
userManager.addUserProfile(new UserHandle(1));
accountManager.addAccountForUser(1, new Account("test@test.com", "com.test"));
mFragment.finishIfAccountMissing();
verify(mFragment).finish();
@@ -180,11 +180,11 @@ public class AccountDetailDashboardFragmentTest {
public void onResume_accountPresentOneProfile_shouldNotFinish() {
ShadowUserManager userManager = Shadow.extract(
mContext.getSystemService(UserManager.class));
ShadowAccountManager acctMgr = Shadow.extract(
ShadowAccountManager accountManager = Shadow.extract(
mContext.getSystemService(AccountManager.class));
userManager.addProfile(new UserInfo(1, null, 0));
acctMgr.addAccountForUser(1, mFragment.mAccount);
userManager.addUserProfile(new UserHandle(1));
accountManager.addAccountForUser(1, mFragment.mAccount);
mFragment.finishIfAccountMissing();
verify(mFragment, never()).finish();
@@ -194,13 +194,13 @@ public class AccountDetailDashboardFragmentTest {
public void onResume_accountPresentTwoProfiles_shouldNotFinish() {
ShadowUserManager userManager = Shadow.extract(
mContext.getSystemService(UserManager.class));
ShadowAccountManager acctMgr = Shadow.extract(
ShadowAccountManager accountManager = Shadow.extract(
mContext.getSystemService(AccountManager.class));
userManager.addProfile(new UserInfo(1, null, 0));
userManager.addProfile(new UserInfo(2, null, 0));
acctMgr.addAccountForUser(1, new Account("test@test.com", "com.test"));
acctMgr.addAccountForUser(2, mFragment.mAccount);
userManager.addUserProfile(new UserHandle(1));
userManager.addUserProfile(new UserHandle(2));
accountManager.addAccountForUser(1, new Account("test@test.com", "com.test"));
accountManager.addAccountForUser(2, mFragment.mAccount);
mFragment.finishIfAccountMissing();
verify(mFragment, never()).finish();

View File

@@ -141,8 +141,7 @@ public class AvatarViewMixinTest {
@Test
public void callWithGetAccountAvatarMethod_useDummyData_shouldReturnAccountNameAndAvatar() {
final ShadowContentResolver shadowContentResolver = Shadow.extract(
mContext.getContentResolver());
final ContentResolver contentResolver = mContext.getContentResolver();
final Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(
DUMMY_AUTHORITY).build();
final ContentProvider mockContentProvider = mock(ContentProvider.class);
@@ -156,8 +155,7 @@ public class AvatarViewMixinTest {
doReturn(bundle).when(mockContentProvider).call(anyString(), anyString(),
any(Bundle.class));
final Bundle expectBundle = shadowContentResolver.call(uri, METHOD_GET_ACCOUNT_AVATAR,
null /* arg */, null /* extras */);
contentResolver.call(uri, METHOD_GET_ACCOUNT_AVATAR, null /* arg */, null /* extras */);
final Object object = bundle.getParcelable("account_avatar");
assertThat(object instanceof Bitmap).isTrue();