Commit bdfedd5a authored by maxbogue's avatar maxbogue Committed by Commit bot

[Sync] Improve test to use content resolver

This more accurately simulates a user making changes through the Android
sync settings in an end-to-end way.

BUG=480604

Review URL: https://codereview.chromium.org/1137073002

Cr-Commit-Position: refs/heads/master@{#329905}
parent 5171d853
...@@ -130,17 +130,20 @@ public class SyncTest extends SyncTestBase { ...@@ -130,17 +130,20 @@ public class SyncTest extends SyncTestBase {
@LargeTest @LargeTest
@Feature({"Sync"}) @Feature({"Sync"})
public void testDisableAndEnableSync() throws InterruptedException { public void testDisableAndEnableSyncThroughAndroid() throws InterruptedException {
setupTestAccountAndSignInToSync(CLIENT_ID); setupTestAccountAndSignInToSync(CLIENT_ID);
SyncTestUtil.ensureSyncInitialized(mContext);
Account account = Account account =
AccountManagerHelper.createAccountFromName(SyncTestUtil.DEFAULT_TEST_ACCOUNT); AccountManagerHelper.createAccountFromName(SyncTestUtil.DEFAULT_TEST_ACCOUNT);
String authority = AndroidSyncSettings.get(mContext).getContractAuthority();
// Disabling Android sync should turn Chrome sync engine off. // Disabling Android sync should turn Chrome sync engine off.
AndroidSyncSettings.get(mContext).disableChromeSync(); mSyncContentResolver.setSyncAutomatically(account, authority, false);
SyncTestUtil.verifySyncIsDisabled(mContext, account); SyncTestUtil.verifySyncIsDisabled(mContext, account);
// Enabling Android sync should turn Chrome sync engine on. // Enabling Android sync should turn Chrome sync engine on.
AndroidSyncSettings.get(mContext).enableChromeSync(); mSyncContentResolver.setSyncAutomatically(account, authority, true);
SyncTestUtil.ensureSyncInitialized(mContext); SyncTestUtil.ensureSyncInitialized(mContext);
SyncTestUtil.verifySignedInWithAccount(mContext, account); SyncTestUtil.verifySignedInWithAccount(mContext, account);
} }
......
...@@ -38,6 +38,7 @@ public class SyncTestBase extends ChromeShellTestBase { ...@@ -38,6 +38,7 @@ public class SyncTestBase extends ChromeShellTestBase {
protected SyncController mSyncController; protected SyncController mSyncController;
protected FakeServerHelper mFakeServerHelper; protected FakeServerHelper mFakeServerHelper;
protected ProfileSyncService mProfileSyncService; protected ProfileSyncService mProfileSyncService;
protected MockSyncContentResolverDelegate mSyncContentResolver;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
...@@ -109,10 +110,9 @@ public class SyncTestBase extends ChromeShellTestBase { ...@@ -109,10 +110,9 @@ public class SyncTestBase extends ChromeShellTestBase {
} }
private void setUpMockAndroidSyncSettings() { private void setUpMockAndroidSyncSettings() {
MockSyncContentResolverDelegate syncContentResolverDelegate = mSyncContentResolver = new MockSyncContentResolverDelegate();
new MockSyncContentResolverDelegate(); mSyncContentResolver.setMasterSyncAutomatically(true);
syncContentResolverDelegate.setMasterSyncAutomatically(true); AndroidSyncSettings.overrideForTests(mContext, mSyncContentResolver);
AndroidSyncSettings.overrideForTests(mContext, syncContentResolverDelegate);
} }
protected void setupTestAccountAndSignInToSync( protected void setupTestAccountAndSignInToSync(
......
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