gecko/services/sync/tests/unit/test_service_startup.js
Edward Lee 4e55362a90 Bug 570636 - Decide how to co-exist as a sync add-on and built-in sync [r=mconnor]
Map the modules directory to services-sync instead of weave and update imports.
2010-06-16 14:30:08 -07:00

41 lines
1.3 KiB
JavaScript

Cu.import("resource://services-sync/ext/Observers.js");
Cu.import("resource://services-sync/ext/Sync.js");
Cu.import("resource://services-sync/identity.js");
Cu.import("resource://services-sync/util.js");
function run_test() {
_("When imported, Weave.Service.onStartup is called");
// Test fixtures
let observerCalled = false;
Observers.add("weave:service:ready", function (subject, data) {
observerCalled = true;
});
Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
Svc.Prefs.set("username", "johndoe");
try {
Cu.import("resource://services-sync/service.js");
_("Service is enabled.");
do_check_eq(Weave.Service.enabled, true);
_("Engines are registered.");
let engines = Weave.Engines.getAll();
do_check_true(Utils.deepEquals([engine.name for each (engine in engines)],
['tabs', 'bookmarks', 'forms', 'history']));
_("Identities are registered.");
do_check_eq(ID.get('WeaveID').username, "johndoe");
do_check_eq(ID.get('WeaveCryptoID').username, "johndoe");
_("Observers are notified of startup");
// Synchronize with Weave.Service.onStartup's async notification
Sync.sleep(0);
do_check_true(observerCalled);
} finally {
Svc.Prefs.resetBranch("");
}
}