PageRenderTime 26ms CodeModel.GetById 18ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/services/sync/tests/unit/test_service_startup.js

http://github.com/zpao/v8monkey
JavaScript | 38 lines | 28 code | 8 blank | 2 comment | 1 complexity | 014baeb05292b71f72c932c2d2e8bf48 MD5 | raw file
 1Cu.import("resource://services-sync/ext/Observers.js");
 2Cu.import("resource://services-sync/status.js");
 3Cu.import("resource://services-sync/identity.js");
 4Cu.import("resource://services-sync/util.js");
 5Cu.import("resource://services-sync/engines.js");
 6
 7function run_test() {
 8  _("When imported, Service.onStartup is called");
 9
10  // Test fixtures
11  Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History");
12  Svc.Prefs.set("username", "johndoe");
13
14  Cu.import("resource://services-sync/service.js");
15
16  _("Service is enabled.");
17  do_check_eq(Service.enabled, true);
18
19  _("Engines are registered.");
20  let engines = Engines.getAll();
21  do_check_true(Utils.deepEquals([engine.name for each (engine in engines)],
22                                 ['tabs', 'bookmarks', 'forms', 'history']));
23
24  _("Identities are registered.");
25  do_check_eq(ID.get('WeaveID').username, "johndoe");
26  do_check_eq(ID.get('WeaveCryptoID').username, "johndoe");
27
28  _("Observers are notified of startup");
29  do_test_pending();
30  do_check_false(Status.ready);
31  Observers.add("weave:service:ready", function (subject, data) {
32    do_check_true(Status.ready);
33
34    // Clean up.
35    Svc.Prefs.resetBranch("");
36    do_test_finished();
37  });
38}