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