Index: chrome/android/javatests_shell/src/org/chromium/chrome/browser/sync/DelayedSyncControllerTest.java |
diff --git a/chrome/android/javatests_shell/src/org/chromium/chrome/browser/sync/DelayedSyncControllerTest.java b/chrome/android/javatests_shell/src/org/chromium/chrome/browser/sync/DelayedSyncControllerTest.java |
index d08621a29cfb1f41c233fd3b369ae924c17e1ce3..037a334a648898e09e47a392629aa37eb0235de3 100644 |
--- a/chrome/android/javatests_shell/src/org/chromium/chrome/browser/sync/DelayedSyncControllerTest.java |
+++ b/chrome/android/javatests_shell/src/org/chromium/chrome/browser/sync/DelayedSyncControllerTest.java |
@@ -18,25 +18,30 @@ import org.chromium.base.ApplicationStatus; |
import org.chromium.base.VisibleForTesting; |
import org.chromium.base.test.util.Feature; |
import org.chromium.chrome.shell.ChromeShellTestBase; |
+import org.chromium.components.invalidation.PendingInvalidation; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
-import org.chromium.sync.signin.AccountManagerHelper; |
+import java.util.List; |
+ |
+/** |
+ * Tests for DelayedSyncController. |
+ */ |
public class DelayedSyncControllerTest extends ChromeShellTestBase { |
- private static final Account TEST_ACCOUNT = |
- AccountManagerHelper.createAccountFromName("something@gmail.com"); |
+ private static final String TEST_ACCOUNT = "something@gmail.com"; |
private static final long WAIT_FOR_LAUNCHER_MS = scaleTimeout(10 * 1000); |
private static final long POLL_INTERVAL_MS = 100; |
private TestDelayedSyncController mController; |
private static class TestDelayedSyncController extends DelayedSyncController { |
- private boolean mSyncRequested; |
+ private boolean mInvalidated; |
private TestDelayedSyncController() {} |
@Override |
- void requestSyncOnBackgroundThread(Context context, Account account) { |
- mSyncRequested = true; |
+ void notifyInvalidationsOnBackgroundThread( |
+ Context context, Account account, List<Bundle> bundles) { |
+ mInvalidated = true; |
} |
} |
@@ -54,20 +59,19 @@ public class DelayedSyncControllerTest extends ChromeShellTestBase { |
assertTrue(isActivityResumed()); |
Bundle extras = new Bundle(); |
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); |
- assertTrue(mController.shouldPerformSync(getActivity(), extras, TEST_ACCOUNT)); |
+ assertTrue(mController.shouldNotifyInvalidation(extras)); |
// Sync should trigger for manual requests when Chrome is in the background. |
sendChromeToBackground(getActivity()); |
extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); |
- assertTrue(mController.shouldPerformSync(getActivity(), extras, TEST_ACCOUNT)); |
+ assertTrue(mController.shouldNotifyInvalidation(extras)); |
} |
@SmallTest |
@Feature({"Sync"}) |
public void testSyncRequestsShouldTriggerSyncWhenChromeIsInForeground() { |
assertTrue(isActivityResumed()); |
- Bundle extras = new Bundle(); |
- assertTrue(mController.shouldPerformSync(getActivity(), extras, TEST_ACCOUNT)); |
+ assertTrue(mController.shouldNotifyInvalidation(new Bundle())); |
} |
@SmallTest |
@@ -75,26 +79,29 @@ public class DelayedSyncControllerTest extends ChromeShellTestBase { |
public void testSyncRequestsWhenChromeIsInBackgroundShouldBeDelayed() |
throws InterruptedException { |
sendChromeToBackground(getActivity()); |
- Bundle extras = new Bundle(); |
- assertFalse(mController.shouldPerformSync(getActivity(), extras, TEST_ACCOUNT)); |
+ assertFalse(mController.shouldNotifyInvalidation(new Bundle())); |
} |
@SmallTest |
@Feature({"Sync"}) |
public void testDelayedSyncRequestsShouldBeTriggeredOnResume() throws InterruptedException { |
- // First make sure there are no delayed syncs. |
- mController.clearDelayedSyncs(getActivity()); |
- assertFalse(mController.resumeDelayedSyncs(getActivity())); |
- assertFalse(mController.mSyncRequested); |
+ // First make sure there are no pending invalidations. |
+ mController.clearPendingInvalidations(getActivity()); |
+ assertFalse(mController.notifyPendingInvalidations(getActivity())); |
+ assertFalse(mController.mInvalidated); |
- // Trying to perform sync when Chrome is in the background should create a delayed sync. |
+ // Can't invalidate while Chrome is in the background. |
sendChromeToBackground(getActivity()); |
- Bundle extras = new Bundle(); |
- assertFalse(mController.shouldPerformSync(getActivity(), extras, TEST_ACCOUNT)); |
+ Bundle bundle = new Bundle(); |
+ assertFalse(mController.shouldNotifyInvalidation(bundle)); |
+ |
+ // Add a pending invalidation. |
+ mController.addPendingInvalidation( |
+ getActivity(), TEST_ACCOUNT, new PendingInvalidation(bundle)); |
- // Make sure the delayed sync can be resumed. |
- assertTrue(mController.resumeDelayedSyncs(getActivity())); |
- assertTrue(mController.mSyncRequested); |
+ // Make sure the pending invalidation can be notified. |
+ assertTrue(mController.notifyPendingInvalidations(getActivity())); |
+ assertTrue(mController.mInvalidated); |
} |
@VisibleForTesting |