From 8bcdb781ffad87f8c5c098e43ffe92ffb2b67ae6 Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Sat, 23 Jan 2016 19:46:10 -0500 Subject: [PATCH 1/2] Bug 1242125 - Fix eslint errors in /browser/components/uitour. r=mattn --HG-- extra : commitid : 9YOFmXUhUj9 --- .eslintignore | 1 - browser/components/uitour/UITour.jsm | 4 +++- .../components/uitour/test/browser_UITour_heartbeat.js | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.eslintignore b/.eslintignore index 91da567ba6d3..91ace4b7a4c4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -76,7 +76,6 @@ browser/components/sessionstore/** browser/components/shell/** browser/components/tabview/** browser/components/translation/** -browser/components/uitour/** browser/extensions/pdfjs/** browser/extensions/pocket/content/panels/js/vendor/** browser/extensions/shumway/** diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index fe4e9c359ad0..a51b4d05d28f 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -2014,10 +2014,12 @@ this.UITour = { for (let engine of engines) { if (engine.identifier == aID) { Services.search.defaultEngine = engine; - return resolve(); + resolve(); + return; } } reject("selectSearchEngine could not find engine with given ID"); + return; }); }); }, diff --git a/browser/components/uitour/test/browser_UITour_heartbeat.js b/browser/components/uitour/test/browser_UITour_heartbeat.js index 03c0504e6ad3..adfd690198fb 100644 --- a/browser/components/uitour/test/browser_UITour_heartbeat.js +++ b/browser/components/uitour/test/browser_UITour_heartbeat.js @@ -345,7 +345,7 @@ var tests = [ "What is this?", dummyURL); }, - taskify(function test_invalidEngagementButtonLabel(done) { + taskify(function* test_invalidEngagementButtonLabel(done) { let engagementURL = "http://example.com"; let flowId = "invalidEngagementButtonLabel-" + Math.random(); @@ -362,7 +362,7 @@ var tests = [ }), - taskify(function test_privateWindowsOnly_noneOpen(done) { + taskify(function* test_privateWindowsOnly_noneOpen(done) { let engagementURL = "http://example.com"; let flowId = "privateWindowsOnly_noneOpen-" + Math.random(); @@ -379,7 +379,7 @@ var tests = [ "If there are no private windows opened, tour init should be prevented"); }), - taskify(function test_privateWindowsOnly_notMostRecent(done) { + taskify(function* test_privateWindowsOnly_notMostRecent(done) { let engagementURL = "http://example.com"; let flowId = "notMostRecent-" + Math.random(); @@ -406,7 +406,7 @@ var tests = [ yield BrowserTestUtils.closeWindow(privateWin); }), - taskify(function test_privateWindowsOnly() { + taskify(function* test_privateWindowsOnly() { let engagementURL = "http://example.com"; let learnMoreURL = "http://example.org/learnmore/"; let flowId = "ui-privateWindowsOnly-" + Math.random(); From 5a5448da6dfb45ea5e0669193c1d8daa3f9d8620 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Fri, 22 Jan 2016 12:22:54 -0800 Subject: [PATCH 2/2] Bug 1182206 - Remove SYNC_EXTRAS_MANUAL entirely. r=nalexander This patch removes the bespoke SyncHints type in favour of using Android's own flags to ignore backoff and request an expedited sync. It also unifies a simpler request{Immediate,Eventual}Sync API for sync-requesting consumers. --HG-- extra : commitid : 8oerw1PEWuH extra : rebase_source : ec5bcc03f5d78439ab8455a9c486326f1651947a --- .../gecko/home/RemoteTabsBaseFragment.java | 2 +- .../service/sharemethods/SendTab.java | 3 +- .../mozilla/gecko/fxa/FirefoxAccounts.java | 103 +++--------------- .../activities/FxAccountStatusFragment.java | 10 +- .../fxa/authenticator/AndroidFxAccount.java | 77 ++++++------- .../gecko/fxa/sync/FxAccountSyncAdapter.java | 14 +-- .../junit3/background_junit3_sources.mozbuild | 1 - .../background/fxa/TestFirefoxAccounts.java | 52 --------- 8 files changed, 63 insertions(+), 199 deletions(-) delete mode 100644 mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/fxa/TestFirefoxAccounts.java diff --git a/mobile/android/base/java/org/mozilla/gecko/home/RemoteTabsBaseFragment.java b/mobile/android/base/java/org/mozilla/gecko/home/RemoteTabsBaseFragment.java index b5ba0f2f5699..28f1a6c53040 100644 --- a/mobile/android/base/java/org/mozilla/gecko/home/RemoteTabsBaseFragment.java +++ b/mobile/android/base/java/org/mozilla/gecko/home/RemoteTabsBaseFragment.java @@ -257,7 +257,7 @@ public abstract class RemoteTabsBaseFragment extends HomeFragment implements Rem public void onRefresh() { if (FirefoxAccounts.firefoxAccountsExist(getActivity())) { final Account account = FirefoxAccounts.getFirefoxAccount(getActivity()); - FirefoxAccounts.requestSync(account, FirefoxAccounts.FORCE, STAGES_TO_SYNC_ON_REFRESH, null); + FirefoxAccounts.requestImmediateSync(account, STAGES_TO_SYNC_ON_REFRESH, null); } else { Log.wtf(LOGTAG, "No Firefox Account found; this should never happen. Ignoring."); mRefreshLayout.setRefreshing(false); diff --git a/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java b/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java index c5ef25c90a2b..16e5752fa184 100644 --- a/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java +++ b/mobile/android/base/java/org/mozilla/gecko/overlays/service/sharemethods/SendTab.java @@ -19,7 +19,6 @@ import org.mozilla.gecko.GeckoProfile; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.RemoteClient; import org.mozilla.gecko.db.TabsAccessor; -import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; import org.mozilla.gecko.fxa.login.State; @@ -291,7 +290,7 @@ public class SendTab extends ShareMethod { @Override public void sync() { - fxAccount.requestSync(FirefoxAccounts.FORCE, STAGES_TO_SYNC, null); + fxAccount.requestImmediateSync(STAGES_TO_SYNC, null); } } } diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java index 4dddd6d78cb4..ea9e0ca9fbc0 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/FirefoxAccounts.java @@ -33,40 +33,6 @@ import android.os.Bundle; public class FirefoxAccounts { private static final String LOG_TAG = FirefoxAccounts.class.getSimpleName(); - public enum SyncHint { - /** - * Hint that a requested sync is preferred immediately. - *

- * On many devices, not including SCHEDULE_NOW means a delay of - * at least 30 seconds. - */ - SCHEDULE_NOW, - - /** - * Hint that a requested sync may ignore local rate limiting. - *

- * This is just a hint; the actual requested sync may not obey the hint. - */ - IGNORE_LOCAL_RATE_LIMIT, - - /** - * Hint that a requested sync may ignore remote server backoffs. - *

- * This is just a hint; the actual requested sync may not obey the hint. - */ - IGNORE_REMOTE_SERVER_BACKOFF, - } - - public static final EnumSet SOON = EnumSet.noneOf(SyncHint.class); - - public static final EnumSet NOW = EnumSet.of( - SyncHint.SCHEDULE_NOW); - - public static final EnumSet FORCE = EnumSet.of( - SyncHint.SCHEDULE_NOW, - SyncHint.IGNORE_LOCAL_RATE_LIMIT, - SyncHint.IGNORE_REMOTE_SERVER_BACKOFF); - /** * Returns true if a FirefoxAccount exists, false otherwise. * @@ -182,54 +148,21 @@ public class FirefoxAccounts { return account.name; } - protected static void putHintsToSync(final Bundle extras, EnumSet syncHints) { - // stagesToSync and stagesToSkip are allowed to be null. - if (syncHints == null) { - throw new IllegalArgumentException("syncHints must not be null"); - } + public static void logSyncOptions(Bundle syncOptions) { + final boolean scheduleNow = syncOptions.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false); - final boolean scheduleNow = syncHints.contains(SyncHint.SCHEDULE_NOW); - final boolean ignoreLocalRateLimit = syncHints.contains(SyncHint.IGNORE_LOCAL_RATE_LIMIT); - final boolean ignoreRemoteServerBackoff = syncHints.contains(SyncHint.IGNORE_REMOTE_SERVER_BACKOFF); - - extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, scheduleNow); - // The default when manually syncing is to ignore the local rate limit and - // any remote server backoff requests. Since we can't add flags to a manual - // sync instigated by the user, we have to reverse the natural conditionals. - // See also the FORCE EnumSet. - extras.putBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_LOCAL_RATE_LIMIT, !ignoreLocalRateLimit); - extras.putBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_REMOTE_SERVER_BACKOFF, !ignoreRemoteServerBackoff); + Logger.info(LOG_TAG, "Sync options -- scheduling now: " + scheduleNow); } - public static EnumSet getHintsToSyncFromBundle(final Bundle extras) { - final EnumSet syncHints = EnumSet.noneOf(SyncHint.class); - - final boolean scheduleNow = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false); - final boolean ignoreLocalRateLimit = !extras.getBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_LOCAL_RATE_LIMIT, false); - final boolean ignoreRemoteServerBackoff = !extras.getBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_REMOTE_SERVER_BACKOFF, false); - - if (scheduleNow) { - syncHints.add(SyncHint.SCHEDULE_NOW); - } - if (ignoreLocalRateLimit) { - syncHints.add(SyncHint.IGNORE_LOCAL_RATE_LIMIT); - } - if (ignoreRemoteServerBackoff) { - syncHints.add(SyncHint.IGNORE_REMOTE_SERVER_BACKOFF); - } - - return syncHints; + public static void requestImmediateSync(final Account account, String[] stagesToSync, String[] stagesToSkip) { + final Bundle syncOptions = new Bundle(); + syncOptions.putBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, true); + syncOptions.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); + requestSync(account, syncOptions, stagesToSync, stagesToSkip); } - public static void logSyncHints(EnumSet syncHints) { - final boolean scheduleNow = syncHints.contains(SyncHint.SCHEDULE_NOW); - final boolean ignoreLocalRateLimit = syncHints.contains(SyncHint.IGNORE_LOCAL_RATE_LIMIT); - final boolean ignoreRemoteServerBackoff = syncHints.contains(SyncHint.IGNORE_REMOTE_SERVER_BACKOFF); - - Logger.info(LOG_TAG, "Sync hints" + - "; scheduling now: " + scheduleNow + - "; ignoring local rate limit: " + ignoreLocalRateLimit + - "; ignoring remote server backoff: " + ignoreRemoteServerBackoff + "."); + public static void requestEventualSync(final Account account, String[] stagesToSync, String[] stagesToSkip) { + requestSync(account, Bundle.EMPTY, stagesToSync, stagesToSkip); } /** @@ -242,24 +175,22 @@ public class FirefoxAccounts { * It is safe to call this method from any thread. * * @param account to sync. - * @param syncHints to pass to sync. + * @param syncOptions to pass to sync. * @param stagesToSync stage names to sync. * @param stagesToSkip stage names to skip. */ - public static void requestSync(final Account account, EnumSet syncHints, String[] stagesToSync, String[] stagesToSkip) { + protected static void requestSync(final Account account, final Bundle syncOptions, String[] stagesToSync, String[] stagesToSkip) { if (account == null) { throw new IllegalArgumentException("account must not be null"); } - if (syncHints == null) { - throw new IllegalArgumentException("syncHints must not be null"); + if (syncOptions == null) { + throw new IllegalArgumentException("syncOptions must not be null"); } - final Bundle extras = new Bundle(); - putHintsToSync(extras, syncHints); - Utils.putStageNamesToSync(extras, stagesToSync, stagesToSkip); + Utils.putStageNamesToSync(syncOptions, stagesToSync, stagesToSkip); Logger.info(LOG_TAG, "Requesting sync."); - logSyncHints(syncHints); + logSyncOptions(syncOptions); // We get strict mode warnings on some devices, so make the request on a // background thread. @@ -267,7 +198,7 @@ public class FirefoxAccounts { @Override public void run() { for (String authority : AndroidFxAccount.DEFAULT_AUTHORITIES_TO_SYNC_AUTOMATICALLY_MAP.keySet()) { - ContentResolver.requestSync(account, authority, extras); + ContentResolver.requestSync(account, authority, syncOptions); } } }); diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java index 65520265b24d..87505470d48b 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/activities/FxAccountStatusFragment.java @@ -11,7 +11,6 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.preference.CheckBoxPreference; @@ -24,14 +23,15 @@ import android.preference.PreferenceScreen; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; import android.text.format.DateUtils; + import com.squareup.picasso.Picasso; import com.squareup.picasso.Target; + import org.mozilla.gecko.AppConstants; import org.mozilla.gecko.R; import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.fxa.FxAccountUtils; import org.mozilla.gecko.background.preferences.PreferenceFragment; -import org.mozilla.gecko.fxa.FirefoxAccounts; import org.mozilla.gecko.fxa.FxAccountConstants; import org.mozilla.gecko.fxa.SyncStatusListener; import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; @@ -289,7 +289,7 @@ public class FxAccountStatusFragment if (preference == syncNowPreference) { if (fxAccount != null) { - FirefoxAccounts.requestSync(fxAccount.getAndroidAccount(), FirefoxAccounts.FORCE, null, null); + fxAccount.requestImmediateSync(null, null); } return true; } @@ -794,7 +794,7 @@ public class FxAccountStatusFragment return; } Logger.info(LOG_TAG, "Requesting a sync sometime soon."); - fxAccount.requestSync(); + fxAccount.requestEventualSync(null, null); } } @@ -843,7 +843,7 @@ public class FxAccountStatusFragment fxAccount.dump(); } else if ("debug_force_sync".equals(key)) { Logger.info(LOG_TAG, "Force syncing."); - fxAccount.requestSync(FirefoxAccounts.FORCE); + fxAccount.requestImmediateSync(null, null); // No sense refreshing, since the sync will complete in the future. } else if ("debug_forget_certificate".equals(key)) { State state = fxAccount.getState(); diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java index 35606e7e4ee9..f85b9af7a061 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java @@ -4,20 +4,19 @@ package org.mozilla.gecko.fxa.authenticator; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import java.security.GeneralSecurityException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Semaphore; +import android.accounts.Account; +import android.accounts.AccountManager; +import android.app.Activity; +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.os.Handler; +import android.os.ResultReceiver; +import android.support.v4.content.LocalBroadcastManager; +import android.util.Log; -import org.mozilla.gecko.AppConstants; -import org.mozilla.gecko.background.ReadingListConstants; import org.mozilla.gecko.background.common.GlobalConstants; import org.mozilla.gecko.background.common.log.Logger; import org.mozilla.gecko.background.fxa.FxAccountUtils; @@ -33,18 +32,16 @@ import org.mozilla.gecko.sync.Utils; import org.mozilla.gecko.sync.setup.Constants; import org.mozilla.gecko.util.ThreadUtils; -import android.accounts.Account; -import android.accounts.AccountManager; -import android.app.Activity; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Bundle; -import android.os.Handler; -import android.os.ResultReceiver; -import android.util.Log; -import android.support.v4.content.LocalBroadcastManager; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Semaphore; /** * A Firefox Account that stores its details and state as user data attached to @@ -525,30 +522,24 @@ public class AndroidFxAccount { } /** - * Request a sync. See {@link FirefoxAccounts#requestSync(Account, EnumSet, String[], String[])}. + * Request an immediate sync. Use this to sync as soon as possible in response to user action. + * + * @param stagesToSync stage names to sync; can be null to sync all known stages. + * @param stagesToSkip stage names to skip; can be null to skip no known stages. */ - public void requestSync() { - requestSync(FirefoxAccounts.SOON, null, null); + public void requestImmediateSync(String[] stagesToSync, String[] stagesToSkip) { + FirefoxAccounts.requestImmediateSync(getAndroidAccount(), stagesToSync, stagesToSkip); } /** - * Request a sync. See {@link FirefoxAccounts#requestSync(Account, EnumSet, String[], String[])}. + * Request an eventual sync. Use this to request the system queue a sync for some time in the + * future. * - * @param syncHints to pass to sync. + * @param stagesToSync stage names to sync; can be null to sync all known stages. + * @param stagesToSkip stage names to skip; can be null to skip no known stages. */ - public void requestSync(EnumSet syncHints) { - requestSync(syncHints, null, null); - } - - /** - * Request a sync. See {@link FirefoxAccounts#requestSync(Account, EnumSet, String[], String[])}. - * - * @param syncHints to pass to sync. - * @param stagesToSync stage names to sync. - * @param stagesToSkip stage names to skip. - */ - public void requestSync(EnumSet syncHints, String[] stagesToSync, String[] stagesToSkip) { - FirefoxAccounts.requestSync(getAndroidAccount(), syncHints, stagesToSync, stagesToSkip); + public void requestEventualSync(String[] stagesToSync, String[] stagesToSkip) { + FirefoxAccounts.requestEventualSync(getAndroidAccount(), stagesToSync, stagesToSkip); } public synchronized void setState(State state) { diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java index 62863bcff63b..5fc1e7b8ce8f 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java @@ -62,9 +62,6 @@ import java.util.concurrent.LinkedBlockingQueue; public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter { private static final String LOG_TAG = FxAccountSyncAdapter.class.getSimpleName(); - public static final String SYNC_EXTRAS_RESPECT_LOCAL_RATE_LIMIT = "respect_local_rate_limit"; - public static final String SYNC_EXTRAS_RESPECT_REMOTE_SERVER_BACKOFF = "respect_remote_server_backoff"; - public static final int NOTIFICATION_ID = LOG_TAG.hashCode(); // Tracks the last seen storage hostname for backoff purposes. @@ -223,7 +220,7 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter { return false; } - final boolean forced = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false); + final boolean forced = extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false); if (forced) { Logger.info(LOG_TAG, "Forced sync (" + kind + "): overruling remaining backoff of " + delay + "ms."); } else { @@ -398,12 +395,11 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter { fxAccount.dump(); } - final EnumSet syncHints = FirefoxAccounts.getHintsToSyncFromBundle(extras); - FirefoxAccounts.logSyncHints(syncHints); + FirefoxAccounts.logSyncOptions(extras); - // This applies even to forced syncs, but only on success. if (this.lastSyncRealtimeMillis > 0L && - (this.lastSyncRealtimeMillis + MINIMUM_SYNC_DELAY_MILLIS) > SystemClock.elapsedRealtime()) { + (this.lastSyncRealtimeMillis + MINIMUM_SYNC_DELAY_MILLIS) > SystemClock.elapsedRealtime() && + !extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false)) { Logger.info(LOG_TAG, "Not syncing FxAccount " + Utils.obfuscateEmail(account.name) + ": minimum interval not met."); TelemetryWrapper.addToHistogram(TelemetryContract.SYNC_FAILED_BACKOFF, 1); @@ -440,7 +436,7 @@ public class FxAccountSyncAdapter extends AbstractThreadedSyncAdapter { // If this sync was triggered by user action, this will be true. final boolean isImmediate = (extras != null) && (extras.getBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, false) || - extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false)); + extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false)); // If it's not an immediate sync, it must be either periodic or tickled. // Check our background rate limiter. diff --git a/mobile/android/tests/background/junit3/background_junit3_sources.mozbuild b/mobile/android/tests/background/junit3/background_junit3_sources.mozbuild index 160fd9c344de..e4a087b4b325 100644 --- a/mobile/android/tests/background/junit3/background_junit3_sources.mozbuild +++ b/mobile/android/tests/background/junit3/background_junit3_sources.mozbuild @@ -24,7 +24,6 @@ background_junit3_sources = [ 'src/org/mozilla/gecko/background/fxa/authenticator/TestAccountPickler.java', 'src/org/mozilla/gecko/background/fxa/TestAccountLoader.java', 'src/org/mozilla/gecko/background/fxa/TestBrowserIDKeyPairGeneration.java', - 'src/org/mozilla/gecko/background/fxa/TestFirefoxAccounts.java', 'src/org/mozilla/gecko/background/helpers/AndroidSyncTestCase.java', 'src/org/mozilla/gecko/background/helpers/BackgroundServiceTestCase.java', 'src/org/mozilla/gecko/background/helpers/DBHelpers.java', diff --git a/mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/fxa/TestFirefoxAccounts.java b/mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/fxa/TestFirefoxAccounts.java deleted file mode 100644 index dedee920f77a..000000000000 --- a/mobile/android/tests/background/junit3/src/org/mozilla/gecko/background/fxa/TestFirefoxAccounts.java +++ /dev/null @@ -1,52 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -package org.mozilla.gecko.background.fxa; - -import java.util.EnumSet; - -import junit.framework.Assert; - -import org.mozilla.gecko.background.helpers.AndroidSyncTestCase; -import org.mozilla.gecko.fxa.FirefoxAccounts; -import org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter; -import org.mozilla.gecko.sync.Utils; -import org.mozilla.gecko.sync.setup.Constants; - -import android.content.ContentResolver; -import android.os.Bundle; - -public class TestFirefoxAccounts extends AndroidSyncTestCase { - private static class InnerFirefoxAccounts extends FirefoxAccounts { - // For testing, since putHintsToSync is not public. - public static Bundle makeTestBundle(EnumSet syncHints, String[] stagesToSync, String[] stagesToSkip) { - final Bundle bundle = new Bundle(); - FirefoxAccounts.putHintsToSync(bundle, syncHints); - Utils.putStageNamesToSync(bundle, stagesToSync, stagesToSkip); - return bundle; - } - } - - protected void assertBundle(Bundle bundle, boolean manual, boolean respectLocal, boolean respectRemote, String stagesToSync, String stagesToSkip) { - Assert.assertEquals(manual, bundle.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL)); - Assert.assertEquals(respectLocal, bundle.getBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_LOCAL_RATE_LIMIT)); - Assert.assertEquals(respectRemote, bundle.getBoolean(FxAccountSyncAdapter.SYNC_EXTRAS_RESPECT_REMOTE_SERVER_BACKOFF)); - Assert.assertEquals(stagesToSync, bundle.getString(Constants.EXTRAS_KEY_STAGES_TO_SYNC)); - Assert.assertEquals(stagesToSkip, bundle.getString(Constants.EXTRAS_KEY_STAGES_TO_SKIP)); - } - - public void testMakeTestBundle() { - Bundle bundle; - bundle = InnerFirefoxAccounts.makeTestBundle(FirefoxAccounts.FORCE, new String[] { "clients" }, null); - assertBundle(bundle, true, false, false, "{\"clients\":0}", null); - assertEquals(FirefoxAccounts.FORCE, FirefoxAccounts.getHintsToSyncFromBundle(bundle)); - - bundle = InnerFirefoxAccounts.makeTestBundle(FirefoxAccounts.NOW, null, new String[] { "bookmarks" }); - assertBundle(bundle, true, true, true, null, "{\"bookmarks\":0}"); - assertEquals(FirefoxAccounts.NOW, FirefoxAccounts.getHintsToSyncFromBundle(bundle)); - - bundle = InnerFirefoxAccounts.makeTestBundle(FirefoxAccounts.SOON, null, null); - assertBundle(bundle, false, true, true, null, null); - assertEquals(FirefoxAccounts.SOON, FirefoxAccounts.getHintsToSyncFromBundle(bundle)); - } -}