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