Commit d2faab6f authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Test] Migrate signin method in ChromeBrowserTestRule

This CL migrates the name and return type of the signin method in
ChromeBrowserTestRule to be consistent with new signin API.

Bug: 1135510
Change-Id: I060484a615b0e0a9f173469927724d79652f439d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450198Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814660}
parent bf2ad053
......@@ -671,7 +671,7 @@ public class PasswordSettingsTest {
// empty.
setPasswordSource(new SavedPasswordEntry("https://example.com", "test user", "password"));
overrideProfileSyncService(false, false);
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
startPasswordSettingsFromMainSettings();
PasswordSettings savedPasswordPrefs = mSettingsActivityTestRule.getFragment();
......@@ -692,7 +692,7 @@ public class PasswordSettingsTest {
// empty.
setPasswordSource(new SavedPasswordEntry("https://example.com", "test user", "password"));
overrideProfileSyncService(false, true);
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
startPasswordSettingsFromMainSettings();
PasswordSettings savedPasswordPrefs = mSettingsActivityTestRule.getFragment();
......@@ -713,7 +713,7 @@ public class PasswordSettingsTest {
// empty.
setPasswordSource(new SavedPasswordEntry("https://example.com", "test user", "password"));
overrideProfileSyncService(true, true);
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
startPasswordSettingsFromMainSettings();
PasswordSettings savedPasswordPrefs = mSettingsActivityTestRule.getFragment();
......@@ -855,7 +855,7 @@ public class PasswordSettingsTest {
@Feature({"Preferences"})
@DisableFeatures(ChromeFeatureList.PASSWORD_CHECK)
public void testCheckPasswordsDisabled() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
final SettingsActivity settingsActivity = startPasswordSettingsFromMainSettings();
TestThreadUtils.runOnUiThreadBlocking(() -> {
......@@ -2240,7 +2240,7 @@ public class PasswordSettingsTest {
@EnableFeatures({ChromeFeatureList.PASSWORD_CHECK})
@DisabledTest(message = "crbug.com/1110965")
public void testDestroysPasswordCheckIfFirstInSettingsStack() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
SettingsActivity activity = startPasswordSettingsDirectly();
activity.finish();
CriteriaHelper.pollInstrumentationThread(() -> activity.isDestroyed());
......@@ -2252,7 +2252,7 @@ public class PasswordSettingsTest {
@Feature({"Preferences"})
@EnableFeatures({ChromeFeatureList.PASSWORD_CHECK})
public void testDoesNotDestroyPasswordCheckIfNotFirstInSettingsStack() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
SettingsActivity activity = startPasswordSettingsFromMainSettings();
activity.finish();
CriteriaHelper.pollInstrumentationThread(() -> activity.isDestroyed());
......
......@@ -42,7 +42,7 @@ public class LensUtilsTest {
@Test
@SmallTest
public void getShareWithGoogleLensIntentSignedInTest() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
......@@ -267,7 +267,7 @@ public class LensUtilsTest {
@SmallTest
public void
getShareWithGoogleLensIntentSignedInTest_directIntentEnabled() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
/* isIncognito= */ false, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
......@@ -299,7 +299,7 @@ public class LensUtilsTest {
@Test
@SmallTest
public void getShareWithGoogleLensIntentIncognitoTest() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
Intent intentNoUri = getShareWithGoogleLensIntentOnUiThread(Uri.EMPTY,
/* isIncognito= */ true, 1234L, /* srcUrl */ "", /* titleOrAltText */ "",
/* intentType= */ IntentType.DEFAULT,
......@@ -331,7 +331,7 @@ public class LensUtilsTest {
@SmallTest
public void getShareWithGoogleLensIntentWithVariationsTest() {
LensUtils.setFakeVariationsForTesting(" 123 456 ");
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
final String contentUrl = "content://image-url";
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
......@@ -356,7 +356,7 @@ public class LensUtilsTest {
@SmallTest
public void getShareWithGoogleLensIntentWithVariationsIncognitoTest() {
LensUtils.setFakeVariationsForTesting(" 123 456 ");
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
final String contentUrl = "content://image-url";
Intent intentWithContentUri = getShareWithGoogleLensIntentOnUiThread(Uri.parse(contentUrl),
......
......@@ -57,7 +57,7 @@ public class PassphraseActivityTest {
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
// Override before signing in, otherwise regular ProfileSyncService will be created.
overrideProfileSyncService();
mChromeBrowserTestRule.addAndSignInTestAccount();
mChromeBrowserTestRule.addTestAccountThenSigninAndEnableSync();
// Create the activity.
final PassphraseActivity activity = launchPassphraseActivity();
......
......@@ -103,7 +103,7 @@ public class StandardProtectionSettingsFragmentTest {
@SmallTest
@Feature({"SafeBrowsing"})
public void testSwitchPasswordLeakDetectionPreference() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(() -> {
SafeBrowsingBridge.setSafeBrowsingState(SafeBrowsingState.STANDARD_PROTECTION);
});
......@@ -181,7 +181,7 @@ public class StandardProtectionSettingsFragmentTest {
@Feature({"SafeBrowsing"})
@Features.EnableFeatures(ChromeFeatureList.SAFE_BROWSING_ENHANCED_PROTECTION_ENABLED)
public void testPreferencesDisabledInEnhancedProtectionMode() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(() -> {
SafeBrowsingBridge.setSafeBrowsingState(SafeBrowsingState.ENHANCED_PROTECTION);
});
......@@ -203,7 +203,7 @@ public class StandardProtectionSettingsFragmentTest {
@SmallTest
@Feature({"SafeBrowsing"})
public void testPreferencesDisabledInNoProtectionMode() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(() -> {
SafeBrowsingBridge.setSafeBrowsingState(SafeBrowsingState.NO_SAFE_BROWSING);
});
......@@ -226,7 +226,7 @@ public class StandardProtectionSettingsFragmentTest {
@Feature({"SafeBrowsing"})
@Policies.Add({ @Policies.Item(key = "PasswordLeakDetectionEnabled", string = "true") })
public void testPasswordLeakDetectionPolicyManaged() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(() -> {
ChromeBrowserInitializer.getInstance().handleSynchronousStartup();
SafeBrowsingBridge.setSafeBrowsingState(SafeBrowsingState.STANDARD_PROTECTION);
......@@ -248,7 +248,7 @@ public class StandardProtectionSettingsFragmentTest {
@Feature({"SafeBrowsing"})
@Policies.Add({ @Policies.Item(key = "SafeBrowsingExtendedReportingEnabled", string = "true") })
public void testExtendedReportingPolicyManaged() {
mBrowserTestRule.addAndSignInTestAccount();
mBrowserTestRule.addTestAccountThenSigninAndEnableSync();
TestThreadUtils.runOnUiThreadBlocking(() -> {
ChromeBrowserInitializer.getInstance().handleSynchronousStartup();
SafeBrowsingBridge.setSafeBrowsingState(SafeBrowsingState.STANDARD_PROTECTION);
......
......@@ -11,6 +11,7 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.content_public.browser.test.NativeLibraryTestUtils;
/**
......@@ -46,7 +47,8 @@ public class ChromeBrowserTestRule implements TestRule {
/**
* Add and sign in an account with the default name.
*/
public Account addAndSignInTestAccount() {
return mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
public CoreAccountInfo addTestAccountThenSigninAndEnableSync() {
Account account = mAccountManagerTestRule.addTestAccountThenSigninAndEnableSync();
return mAccountManagerTestRule.toCoreAccountInfo(account.name);
}
}
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