Commit 4f2f5ec9 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Signin][Android] Clean up SigninTestUtil

This CL cleans up some unused methods and method return values in
SigninTestUtil and IdentityManagerIntegrationTest.

Bug: 1004418
Change-Id: I09c3126d2b954304defffa4a7eefc64bb2423cba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2054093
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742090}
parent 259eb917
......@@ -59,7 +59,6 @@ public class IdentityManagerIntegrationTest {
private IdentityMutator mIdentityMutator;
private IdentityManager mIdentityManager;
private ChromeSigninController mChromeSigninController;
@Before
public void setUp() {
......@@ -69,8 +68,7 @@ public class IdentityManagerIntegrationTest {
mActivityTestRule.loadNativeLibraryAndInitBrowserProcess();
// Make sure there is no account signed in yet.
mChromeSigninController = ChromeSigninController.get();
mChromeSigninController.setSignedInAccountName(null);
ChromeSigninController.get().setSignedInAccountName(null);
TestThreadUtils.runOnUiThreadBlocking(() -> {
seedAccountTrackerService();
......@@ -190,9 +188,8 @@ public class IdentityManagerIntegrationTest {
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("Signed in and two accounts available",
new HashSet<CoreAccountInfo>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<CoreAccountInfo>(
Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
new HashSet<>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<>(Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
});
}
......@@ -208,9 +205,8 @@ public class IdentityManagerIntegrationTest {
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("Signed in and two accounts available",
new HashSet<CoreAccountInfo>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<CoreAccountInfo>(
Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
new HashSet<>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<>(Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
});
removeAccount(TEST_ACCOUNT_HOLDER_2);
......@@ -236,9 +232,8 @@ public class IdentityManagerIntegrationTest {
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("Signed in and two accounts available",
new HashSet<CoreAccountInfo>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<CoreAccountInfo>(
Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
new HashSet<>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<>(Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
});
// Remove all.
......@@ -266,9 +261,8 @@ public class IdentityManagerIntegrationTest {
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("Signed in and two accounts available",
new HashSet<CoreAccountInfo>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<CoreAccountInfo>(
Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
new HashSet<>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<>(Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
});
removeAccount(TEST_ACCOUNT_HOLDER_1);
......@@ -278,8 +272,8 @@ public class IdentityManagerIntegrationTest {
// Re-validate and run checks.
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(null);
Assert.assertEquals("Not signed in and no accounts available", new CoreAccountInfo[] {},
mIdentityManager.getAccountsWithRefreshTokens());
Assert.assertArrayEquals("Not signed in and no accounts available",
new CoreAccountInfo[] {}, mIdentityManager.getAccountsWithRefreshTokens());
});
}
......@@ -295,9 +289,8 @@ public class IdentityManagerIntegrationTest {
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("Signed in and two accounts available",
new HashSet<CoreAccountInfo>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<CoreAccountInfo>(
Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
new HashSet<>(Arrays.asList(mTestAccount1, mTestAccount2)),
new HashSet<>(Arrays.asList(mIdentityManager.getAccountsWithRefreshTokens())));
});
}
......@@ -308,7 +301,7 @@ public class IdentityManagerIntegrationTest {
// Run test.
mIdentityMutator.reloadAllAccountsFromSystemWithPrimaryAccount(mTestAccount1.getId());
Assert.assertEquals("No accounts available", new CoreAccountInfo[] {},
Assert.assertArrayEquals("No accounts available", new CoreAccountInfo[] {},
mIdentityManager.getAccountsWithRefreshTokens());
});
}
......
......@@ -24,8 +24,6 @@ import java.util.List;
* Utility class for test signin functionality.
*/
public final class SigninTestUtil {
private static final String TAG = "Signin";
private static final String DEFAULT_ACCOUNT = "test@gmail.com";
@SuppressLint("StaticFieldLeak")
......@@ -80,7 +78,7 @@ public final class SigninTestUtil {
AccountHolder accountHolder = AccountHolder.builder(account).alwaysAccept(true).build();
sAccountManager.addAccountHolderBlocking(accountHolder);
sAddedAccounts.add(accountHolder);
TestThreadUtils.runOnUiThreadBlocking(SigninTestUtil::seedAccounts);
seedAccounts();
return account;
}
......@@ -88,18 +86,9 @@ public final class SigninTestUtil {
* Add and sign in an account with the default name.
*/
public static Account addAndSignInTestAccount() {
return addAndSignInTestAccount(DEFAULT_ACCOUNT);
}
/**
* Add and sign in an account with a given name.
*/
public static Account addAndSignInTestAccount(String name) {
Account account = addTestAccount(name);
TestThreadUtils.runOnUiThreadBlocking(() -> {
ChromeSigninController.get().setSignedInAccountName(name);
seedAccounts();
});
Account account = addTestAccount(DEFAULT_ACCOUNT);
ChromeSigninController.get().setSignedInAccountName(DEFAULT_ACCOUNT);
seedAccounts();
return account;
}
......@@ -111,8 +100,10 @@ public final class SigninTestUtil {
accountNames[i] = accounts[i].name;
accountIds[i] = sAccountManager.getAccountGaiaId(accounts[i].name);
}
IdentityServicesProvider.get().getAccountTrackerService().syncForceRefreshForTest(
accountIds, accountNames);
TestThreadUtils.runOnUiThreadBlocking(() -> {
IdentityServicesProvider.get().getAccountTrackerService().syncForceRefreshForTest(
accountIds, accountNames);
});
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment