Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | Cu.import("resource://services-common/observers.js"); |
michael@0 | 5 | Cu.import("resource://services-sync/engines.js"); |
michael@0 | 6 | Cu.import("resource://services-sync/util.js"); |
michael@0 | 7 | Cu.import("resource://testing-common/services/sync/utils.js"); |
michael@0 | 8 | |
michael@0 | 9 | Svc.Prefs.set("registerEngines", "Tab,Bookmarks,Form,History"); |
michael@0 | 10 | Cu.import("resource://services-sync/service.js"); |
michael@0 | 11 | |
michael@0 | 12 | function run_test() { |
michael@0 | 13 | _("When imported, Service.onStartup is called"); |
michael@0 | 14 | initTestLogging("Trace"); |
michael@0 | 15 | |
michael@0 | 16 | let xps = Cc["@mozilla.org/weave/service;1"] |
michael@0 | 17 | .getService(Ci.nsISupports) |
michael@0 | 18 | .wrappedJSObject; |
michael@0 | 19 | do_check_false(xps.enabled); |
michael@0 | 20 | |
michael@0 | 21 | // Test fixtures |
michael@0 | 22 | Service.identity.username = "johndoe"; |
michael@0 | 23 | do_check_false(xps.enabled); |
michael@0 | 24 | |
michael@0 | 25 | Cu.import("resource://services-sync/service.js"); |
michael@0 | 26 | |
michael@0 | 27 | _("Service is enabled."); |
michael@0 | 28 | do_check_eq(Service.enabled, true); |
michael@0 | 29 | |
michael@0 | 30 | _("Engines are registered."); |
michael@0 | 31 | let engines = Service.engineManager.getAll(); |
michael@0 | 32 | do_check_true(Utils.deepEquals([engine.name for each (engine in engines)], |
michael@0 | 33 | ['tabs', 'bookmarks', 'forms', 'history'])); |
michael@0 | 34 | |
michael@0 | 35 | _("Observers are notified of startup"); |
michael@0 | 36 | do_test_pending(); |
michael@0 | 37 | |
michael@0 | 38 | do_check_false(Service.status.ready); |
michael@0 | 39 | do_check_false(xps.ready); |
michael@0 | 40 | Observers.add("weave:service:ready", function (subject, data) { |
michael@0 | 41 | do_check_true(Service.status.ready); |
michael@0 | 42 | do_check_true(xps.ready); |
michael@0 | 43 | |
michael@0 | 44 | // Clean up. |
michael@0 | 45 | Svc.Prefs.resetBranch(""); |
michael@0 | 46 | do_test_finished(); |
michael@0 | 47 | }); |
michael@0 | 48 | |
michael@0 | 49 | do_check_false(xps.enabled); |
michael@0 | 50 | |
michael@0 | 51 | Service.identity.account = "johndoe"; |
michael@0 | 52 | Service.clusterURL = "http://localhost/"; |
michael@0 | 53 | do_check_true(xps.enabled); |
michael@0 | 54 | } |