Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9656)

Unified Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java

Issue 2025653002: [Sync] Clean up Android test code a bit, take 2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unused variable. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/signin/SigninTestUtil.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java
diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java
index 54932da3f750614cfd0618f2360a28b71b893398..75fba1c62c5d10d0482a3a7211073af050d10b0a 100644
--- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java
+++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/sync/SyncTestUtil.java
@@ -6,7 +6,6 @@ package org.chromium.chrome.test.util.browser.sync;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
-import android.accounts.Account;
import android.content.Context;
import android.util.Pair;
@@ -18,7 +17,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.chromium.sync.signin.ChromeSigninController;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -42,6 +40,18 @@ public final class SyncTestUtil {
private SyncTestUtil() {}
/**
+ * Returns whether sync is requested.
+ */
+ public static boolean isSyncRequested() {
+ return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return ProfileSyncService.get().isSyncRequested();
+ }
+ });
+ }
+
+ /**
* Returns whether sync is active.
*/
public static boolean isSyncActive() {
@@ -54,6 +64,18 @@ public final class SyncTestUtil {
}
/**
+ * Waits for sync to become active.
+ */
+ public static void waitForSyncActive() throws InterruptedException {
+ CriteriaHelper.pollUiThread(new Criteria("Timed out waiting for sync to become active.") {
+ @Override
+ public boolean isSatisfied() {
+ return ProfileSyncService.get().isSyncActive();
+ }
+ }, TIMEOUT_MS, INTERVAL_MS);
+ }
+
+ /**
* Waits for sync's backend to be initialized.
*/
public static void waitForBackendInitialized() throws InterruptedException {
@@ -68,13 +90,6 @@ public final class SyncTestUtil {
}
/**
- * Verifies that sync is signed out.
- */
- public static void verifySyncIsSignedOut() {
- Assert.assertTrue(isSyncOff());
- }
-
- /**
* Triggers a sync cycle.
*/
public static void triggerSync() {
@@ -116,54 +131,6 @@ public final class SyncTestUtil {
}
/**
- * Waits for sync to become active.
- */
- public static void waitForSyncActive() throws InterruptedException {
- CriteriaHelper.pollUiThread(new Criteria(
- "Timed out waiting for sync to become active.") {
- @Override
- public boolean isSatisfied() {
- return ProfileSyncService.get().isSyncActive();
- }
- }, TIMEOUT_MS, INTERVAL_MS);
- }
-
- /**
- * Verifies that the sync is active and signed in with the given account.
- */
- public static void verifySyncIsActiveForAccount(Context context, Account account)
- throws InterruptedException {
- waitForSyncActive();
- triggerSyncAndWaitForCompletion();
- verifySignedInWithAccount(context, account);
- }
-
- /**
- * Makes sure that sync is enabled with the correct account.
- */
- public static void verifySignedInWithAccount(Context context, Account account) {
- Assert.assertEquals(account, ChromeSigninController.get(context).getSignedInUser());
- }
-
- /**
- * Verifies that the sync is off but signed in with the account.
- */
- public static void verifySyncIsDisabled(Context context, Account account) {
- Assert.assertTrue("Expected sync to be disabled.", isSyncOff());
- verifySignedInWithAccount(context, account);
- }
-
- private static boolean isSyncOff() {
- return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
- @Override
- public Boolean call() {
- ProfileSyncService syncService = ProfileSyncService.get();
- return !syncService.isBackendInitialized() && !syncService.isSyncRequested();
- }
- });
- }
-
- /**
* Retrieves the local Sync data as a JSONArray via ProfileSyncService.
*
* This method blocks until the data is available or until it times out.
« no previous file with comments | « chrome/test/android/javatests/src/org/chromium/chrome/test/util/browser/signin/SigninTestUtil.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698