Commit 27c45df0 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Test] Rename the sign-in methods in AccountManagerTestRule

This CL renames the sign-in methods in AccountManagerTestRule to
signinAndEnableSync to be consistent with the new sign-in API.

Bug: 1131936
Change-Id: I6507712ad38b37c987507bea549b4c9371946a2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429065
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810531}
parent 49e1a683
......@@ -136,7 +136,7 @@ public class ClearBrowsingDataFragmentBasicTest {
@Test
@SmallTest
public void testCheckBoxTextSigned() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setSyncable(false);
mSettingsActivityTestRule.startSettingsActivity();
......@@ -165,7 +165,7 @@ public class ClearBrowsingDataFragmentBasicTest {
@Test
@SmallTest
public void testCheckBoxTextSignedAndSynced() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setSyncable(true);
mSettingsActivityTestRule.startSettingsActivity();
......
......@@ -336,7 +336,7 @@ public class ClearBrowsingDataFragmentTest {
@LargeTest
public void testDialogAboutOtherFormsOfBrowsingHistory() {
// Sign in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
OtherFormsOfHistoryDialogFragment.clearShownPreferenceForTesting();
// History is not selected. We still need to select some other datatype, otherwise the
......@@ -472,7 +472,7 @@ public class ClearBrowsingDataFragmentTest {
@Feature({"SiteEngagement"})
public void testImportantSitesDialogNoFiltering() throws Exception {
// Sign in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
final String[] importantOrigins = {"http://www.facebook.com", "https://www.google.com"};
// First mark our origins as important.
......@@ -505,7 +505,7 @@ public class ClearBrowsingDataFragmentTest {
@Feature({"SiteEngagement"})
public void testImportantSitesDialogNoopOnCancel() throws Exception {
// Sign in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
final String[] importantOrigins = {"http://www.facebook.com", "http://www.google.com"};
// First mark our origins as important.
......@@ -537,7 +537,7 @@ public class ClearBrowsingDataFragmentTest {
@Feature({"SiteEngagement"})
public void testImportantSitesDialog() throws Exception {
// Sign in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
final String kKeepDomain = "https://www.chrome.com";
final String kClearDomain = "https://www.google.com";
......
......@@ -178,7 +178,7 @@ public class HistoryActivityTest {
@Test
@SmallTest
public void testPrivacyDisclaimers_SignedIn() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setHasOtherFormsOfBrowsingData(false);
......@@ -188,7 +188,7 @@ public class HistoryActivityTest {
@Test
@SmallTest
public void testPrivacyDisclaimers_SignedInSynced() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setHasOtherFormsOfBrowsingData(false);
......@@ -198,7 +198,7 @@ public class HistoryActivityTest {
@Test
@SmallTest
public void testPrivacyDisclaimers_SignedInSyncedAndOtherForms() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setHasOtherFormsOfBrowsingData(true);
......@@ -385,7 +385,7 @@ public class HistoryActivityTest {
Assert.assertEquals(1, headerGroup.size());
// Signed in but not synced and history has items. The info button should be hidden.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setHasOtherFormsOfBrowsingData(false);
TestThreadUtils.runOnUiThreadBlocking(() -> toolbar.onSignInStateChange());
Assert.assertFalse(infoMenuItem.isVisible());
......@@ -442,7 +442,7 @@ public class HistoryActivityTest {
// Sign in and set has other forms of browsing data to true.
int callCount = mTestObserver.onSelectionCallback.getCallCount();
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
setHasOtherFormsOfBrowsingData(true);
TestThreadUtils.runOnUiThreadBlocking(() -> {
toolbar.onSignInStateChange();
......
......@@ -74,7 +74,7 @@ public class IdentityDiscControllerTest {
@MediumTest
public void testIdentityDiscWithNavigation() {
// User is signed in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
waitForView(allOf(withId(R.id.optional_toolbar_button), isDisplayed()));
// Identity Disc should be hidden on navigation away from NTP.
......@@ -97,7 +97,7 @@ public class IdentityDiscControllerTest {
});
// Identity Disc should be shown on sign-in state change without NTP refresh.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
waitForView(allOf(withId(R.id.optional_toolbar_button), isDisplayed()));
onView(withId(R.id.optional_toolbar_button))
......@@ -112,7 +112,7 @@ public class IdentityDiscControllerTest {
@Test
@MediumTest
public void testIdentityDiscWithSwitchToIncognito() {
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
waitForView(allOf(withId(R.id.optional_toolbar_button), isDisplayed()));
// Identity Disc should not be visible, when switched from sign in state to incognito NTP.
......
......@@ -129,7 +129,7 @@ public final class ShareButtonControllerTest {
public void
testShareButtonInToolbarNotAffectedByOverview() {
// Sign in.
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(
()
......
......@@ -45,7 +45,7 @@ public class AccountManagementFragmentTest {
@Before
public void setUp() {
mActivityTestRule.startMainActivityOnBlankPage();
mAccountManagerTestRule.addAndSignInTestAccount();
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
mSettingsActivityTestRule.startSettingsActivity();
}
......
......@@ -199,7 +199,8 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
* @return the test account that is signed in.
*/
public Account setUpAccountAndSignInForTesting() {
Account account = mAccountManagerTestRule.addAndSignInTestAccount(mProfileSyncService);
Account account =
mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync(mProfileSyncService);
enableUKM();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.triggerSyncAndWaitForCompletion();
......@@ -211,8 +212,8 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
* @return the test account that is signed in.
*/
public Account setUpTestAccountAndSignInWithSyncSetupAsIncomplete() {
Account account =
mAccountManagerTestRule.addAndSignInTestAccount(/* profileSyncService= */ null);
Account account = mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync(
/* profileSyncService= */ null);
enableUKM();
SyncTestUtil.waitForSyncTransportActive();
return account;
......@@ -233,7 +234,7 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
}
public void signinAndEnableSync(final Account account) {
SigninTestUtil.signIn(account, mProfileSyncService);
SigninTestUtil.signinAndEnableSync(account, mProfileSyncService);
enableUKM();
SyncTestUtil.waitForSyncActive();
SyncTestUtil.triggerSyncAndWaitForCompletion();
......
......@@ -24,7 +24,7 @@ public final class SyncTestSigninUtils {
@CalledByNative
private static Account setUpAccountAndSignInForTesting() {
sAccountManagerTestRule.waitForSeeding();
return sAccountManagerTestRule.addAndSignInTestAccount();
return sAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
}
/**
......
......@@ -47,6 +47,6 @@ public class ChromeBrowserTestRule implements TestRule {
* Add and sign in an account with the default name.
*/
public Account addAndSignInTestAccount() {
return mAccountManagerTestRule.addAndSignInTestAccount();
return mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
}
}
......@@ -147,8 +147,8 @@ public class AccountManagerTestRule implements TestRule {
*
* This method invokes native code. It shouldn't be called in a Robolectric test.
*/
public Account addAndSignInTestAccount() {
return addAndSignInTestAccount(
public Account addTestAccountThenSigninAndEnableSync() {
return addTestAccountThenSigninAndEnableSync(
TestThreadUtils.runOnUiThreadBlockingNoException(ProfileSyncService::get));
}
......@@ -160,10 +160,11 @@ public class AccountManagerTestRule implements TestRule {
* @param profileSyncService ProfileSyncService object to set up sync, if null, sync won't
* start.
*/
public Account addAndSignInTestAccount(@Nullable ProfileSyncService profileSyncService) {
public Account addTestAccountThenSigninAndEnableSync(
@Nullable ProfileSyncService profileSyncService) {
assert !mIsSignedIn : "An account is already signed in!";
Account account = addAccountAndWaitForSeeding(TEST_ACCOUNT_EMAIL);
SigninTestUtil.signIn(account, profileSyncService);
SigninTestUtil.signinAndEnableSync(account, profileSyncService);
mIsSignedIn = true;
return account;
}
......
......@@ -47,7 +47,8 @@ public final class SigninTestUtil {
*
* @param profileSyncService Enable the sync with it if it is not null.
*/
public static void signIn(Account account, @Nullable ProfileSyncService profileSyncService) {
public static void signinAndEnableSync(
Account account, @Nullable ProfileSyncService profileSyncService) {
CallbackHelper callbackHelper = new CallbackHelper();
TestThreadUtils.runOnUiThreadBlocking(() -> {
SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
......
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