зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-i and f-t to m-c, a=merge
This commit is contained in:
Коммит
00bae8be00
|
@ -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/**
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* On many devices, not including <code>SCHEDULE_NOW</code> means a delay of
|
||||
* at least 30 seconds.
|
||||
*/
|
||||
SCHEDULE_NOW,
|
||||
|
||||
/**
|
||||
* Hint that a requested sync may ignore local rate limiting.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* This is just a hint; the actual requested sync may not obey the hint.
|
||||
*/
|
||||
IGNORE_REMOTE_SERVER_BACKOFF,
|
||||
}
|
||||
|
||||
public static final EnumSet<SyncHint> SOON = EnumSet.noneOf(SyncHint.class);
|
||||
|
||||
public static final EnumSet<SyncHint> NOW = EnumSet.of(
|
||||
SyncHint.SCHEDULE_NOW);
|
||||
|
||||
public static final EnumSet<SyncHint> 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<SyncHint> 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<SyncHint> getHintsToSyncFromBundle(final Bundle extras) {
|
||||
final EnumSet<SyncHint> 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<SyncHint> 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<SyncHint> 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 <b>all</b> known stages.
|
||||
* @param stagesToSkip stage names to skip; can be null to skip <b>no</b> 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 <b>all</b> known stages.
|
||||
* @param stagesToSkip stage names to skip; can be null to skip <b>no</b> known stages.
|
||||
*/
|
||||
public void requestSync(EnumSet<FirefoxAccounts.SyncHint> 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<FirefoxAccounts.SyncHint> 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) {
|
||||
|
|
|
@ -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<FirefoxAccounts.SyncHint> 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.
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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<SyncHint> 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));
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче