mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 584241 - Disable trackers when client isn't configured [r=mconnor]
Tests and test fixes. --HG-- rename : services/sync/tests/unit/test_engines_forms_store.js => services/sync/tests/unit/test_forms_store.js
This commit is contained in:
parent
57c4f23de7
commit
9f3ccbe46f
48
services/sync/tests/unit/test_bookmark_tracker.js
Normal file
48
services/sync/tests/unit/test_bookmark_tracker.js
Normal file
@ -0,0 +1,48 @@
|
||||
Cu.import("resource://services-sync/engines/bookmarks.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
function run_test() {
|
||||
_("Verify we've got an empty tracker to work with.");
|
||||
let tracker = new BookmarksEngine()._tracker;
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
let folder = Svc.Bookmark.createFolder(Svc.Bookmark.bookmarksMenuFolder,
|
||||
"Test Folder",
|
||||
Svc.Bookmark.DEFAULT_INDEX);
|
||||
function createBmk() {
|
||||
Svc.Bookmark.insertBookmark(folder,
|
||||
Utils.makeURI("http://getfirefox.com"),
|
||||
Svc.Bookmark.DEFAULT_INDEX,
|
||||
"Get Firefox!");
|
||||
}
|
||||
|
||||
try {
|
||||
_("Create bookmark. Won't show because we haven't started tracking yet");
|
||||
createBmk();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Tell the tracker to start tracking changes.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
createBmk();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 1);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
createBmk();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 2);
|
||||
|
||||
_("Let's stop tracking again.");
|
||||
tracker.clearChangedIDs();
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
createBmk();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
createBmk();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
Svc.Bookmark.removeItem(folder);
|
||||
}
|
||||
}
|
39
services/sync/tests/unit/test_forms_tracker.js
Normal file
39
services/sync/tests/unit/test_forms_tracker.js
Normal file
@ -0,0 +1,39 @@
|
||||
Cu.import("resource://services-sync/engines/forms.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
function run_test() {
|
||||
_("Verify we've got an empty tracker to work with.");
|
||||
let tracker = new FormEngine()._tracker;
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
try {
|
||||
_("Create an entry. Won't show because we haven't started tracking yet");
|
||||
Svc.Form.addEntry("name", "John Doe");
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Tell the tracker to start tracking changes.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
Svc.Form.removeEntry("name", "John Doe");
|
||||
Svc.Form.addEntry("email", "john@doe.com");
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 2);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
Svc.Form.addEntry("address", "Memory Lane");
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 3);
|
||||
|
||||
_("Let's stop tracking again.");
|
||||
tracker.clearChangedIDs();
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
Svc.Form.removeEntry("address", "Memory Lane");
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
Svc.Form.removeEntry("email", "john@doe.com");
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
Svc.Form.removeAllEntries();
|
||||
}
|
||||
}
|
45
services/sync/tests/unit/test_history_tracker.js
Normal file
45
services/sync/tests/unit/test_history_tracker.js
Normal file
@ -0,0 +1,45 @@
|
||||
Cu.import("resource://services-sync/engines/history.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
function run_test() {
|
||||
_("Verify we've got an empty tracker to work with.");
|
||||
let tracker = new HistoryEngine()._tracker;
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
let _counter = 0;
|
||||
function addVisit() {
|
||||
Svc.History.addVisit(Utils.makeURI("http://getfirefox.com/" + _counter),
|
||||
Date.now() * 1000, null, 1, false, 0);
|
||||
_counter += 1;
|
||||
}
|
||||
|
||||
try {
|
||||
_("Create bookmark. Won't show because we haven't started tracking yet");
|
||||
addVisit();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Tell the tracker to start tracking changes.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
addVisit();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 1);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:start-tracking");
|
||||
addVisit();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 2);
|
||||
|
||||
_("Let's stop tracking again.");
|
||||
tracker.clearChangedIDs();
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
addVisit();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
|
||||
_("Notifying twice won't do any harm.");
|
||||
Svc.Obs.notify("weave:engine:stop-tracking");
|
||||
addVisit();
|
||||
do_check_eq([id for (id in tracker.changedIDs)].length, 0);
|
||||
} finally {
|
||||
_("Clean up.");
|
||||
Svc.History.removeAllPages();
|
||||
}
|
||||
}
|
@ -35,7 +35,8 @@ function run_test() {
|
||||
Weave.Service.clusterURL = "http://localhost:8080/";
|
||||
Svc.Prefs.set("autoconnect", false);
|
||||
|
||||
_("Initial state is ok.");
|
||||
_("Force the initial state.");
|
||||
Status.service = STATUS_OK;
|
||||
do_check_eq(Status.service, STATUS_OK);
|
||||
|
||||
_("Try logging in. It wont' work because we're not configured yet.");
|
||||
|
@ -31,7 +31,8 @@ function run_test() {
|
||||
Weave.Service.serverURL = "http://localhost:8080/";
|
||||
Weave.Service.clusterURL = "http://localhost:8080/";
|
||||
|
||||
_("Initial state is ok.");
|
||||
_("Force the initial state.");
|
||||
Status.service = STATUS_OK;
|
||||
do_check_eq(Status.service, STATUS_OK);
|
||||
|
||||
_("Credentials won't check out because we're not configured yet.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user