Commit 3be33172 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

Change sign-in process in SyncTestRule

To enable the feature flag that will make android manual start it is
necessary to change the tests that assume android is auto start. This
signIn method is used by some sync autofill and bookmark tests that needs
to manually set setFirstSetUpComplete to start the sync process.

Bug: 1004264
Change-Id: Ie33ae3b69478794b32530dd5596af66d813ee84c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1798323
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697182}
parent b896f2da
......@@ -71,7 +71,7 @@ public class SyncTest {
Assert.assertFalse(SyncTestUtil.isSyncRequested());
// Signing back in should re-enable sync.
mSyncTestRule.signIn(account);
mSyncTestRule.signinAndEnableSync(account);
SyncTestUtil.waitForSyncActive();
}
......
......@@ -14,12 +14,15 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.SyncFirstSetupCompleteSource;
import org.chromium.chrome.browser.autofill.PersonalDataManager;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.signin.UnifiedConsentServiceBridge;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
......@@ -135,7 +138,7 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
public Account setUpTestAccountAndSignIn() {
Account account = setUpTestAccount();
signIn(account);
signinAndEnableSync(account);
return account;
}
......@@ -153,9 +156,24 @@ public class SyncTestRule extends ChromeActivityTestRule<ChromeActivity> {
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
}
public void signIn(final Account account) {
public void signinAndEnableSync(final Account account) {
TestThreadUtils.runOnUiThreadBlocking(() -> {
IdentityServicesProvider.getSigninManager().signIn(account, null, null);
IdentityServicesProvider.getSigninManager().signIn(
account, null, new SigninManager.SignInCallback() {
@Override
public void onSignInComplete() {
if (ChromeFeatureList.isEnabled(
ChromeFeatureList.SYNC_MANUAL_START_ANDROID)) {
mProfileSyncService.setFirstSetupComplete(
SyncFirstSetupCompleteSource.BASIC_FLOW);
}
}
@Override
public void onSignInAborted() {
Assert.fail("Sign-in was aborted");
}
});
// Outside of tests, URL-keyed anonymized data collection is enabled by sign-in UI.
UnifiedConsentServiceBridge.setUrlKeyedAnonymizedDataCollectionEnabled(true);
});
......
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