~ubuntu-branches/ubuntu/trusty/enigmail/trusty-updates

« back to all changes in this revision

Viewing changes to services/sync/tests/unit/test_prefs_tracker.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2011-06-07 14:35:53 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110607143553-fbgqhhvh8g8h6j1y
Tags: 2:1.2~a2~cvs20110606t2200-0ubuntu1
* Update to latest trunk snapshot for Thunderbird beta compat

* Remove build/pgo/profileserver.py from debian/clean. The new build
  system has a target depending on this
  - update debian/clean
* Drop debian/patches/autoconf.diff, just generate this at build time
* Refresh debian/patches/build_system_dont_link_libxul.diff
* libipc seems to be renamed to libipc-pipe. Fix genxpi and chrome.manifest
  to fix this 
  - add debian/patches/ipc-pipe_rename.diff
  - update debian/patches/series
* The makefiles in extensions/enigmail/ipc have an incorrect DEPTH
  attribute. Fix this so that they can find the rest of the build system
  - add debian/patches/makefile_depth.diff
  - update debian/patches/series
* Drop debian/patches/makefile-in-empty-xpcom-fix.diff - fixed in the
  current version
* Don't register a class ID multiple times, as this breaks enigmail entirely
  - add debian/patches/dont_register_cids_multiple_times.diff
  - update debian/patches/series
* Look for the Thunderbird 5 SDK
  - update debian/rules
  - update debian/control
* Run autoconf2.13 at build time
  - update debian/rules
  - update debian/control
* Add useless mesa-common-dev build-dep, just to satisfy the build system.
  We should just patch this out entirely really, but that's for another upload
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Cu.import("resource://services-sync/engines/prefs.js");
 
2
Cu.import("resource://services-sync/util.js");
 
3
Cu.import("resource://services-sync/ext/Preferences.js");
 
4
 
 
5
function run_test() {
 
6
  let engine = new PrefsEngine();
 
7
  let tracker = engine._tracker;
 
8
  let prefs = new Preferences();
 
9
 
 
10
  try {
 
11
 
 
12
    _("tracker.modified corresponds to preference.");
 
13
    do_check_eq(Svc.Prefs.get("engine.prefs.modified"), undefined);
 
14
    do_check_false(tracker.modified);
 
15
 
 
16
    tracker.modified = true;
 
17
    do_check_eq(Svc.Prefs.get("engine.prefs.modified"), true);
 
18
    do_check_true(tracker.modified);
 
19
 
 
20
    _("Engine's getChangedID() just returns the one GUID we have.");
 
21
    let changedIDs = engine.getChangedIDs();
 
22
    let ids = [id for (id in changedIDs)];
 
23
    do_check_eq(ids.length, 1);
 
24
    do_check_eq(ids[0], Utils.encodeBase64url(Svc.AppInfo.ID));
 
25
 
 
26
    Svc.Prefs.set("engine.prefs.modified", false);
 
27
    do_check_false(tracker.modified);
 
28
 
 
29
    _("No modified state, so no changed IDs.");
 
30
    do_check_eq([id for (id in engine.getChangedIDs())].length, 0);
 
31
 
 
32
    _("Initial score is 0");
 
33
    do_check_eq(tracker.score, 0);
 
34
 
 
35
    _("Test fixtures.");
 
36
    Svc.Prefs.set("prefs.sync.testing.int", true);
 
37
 
 
38
    _("Test fixtures haven't upped the tracker score yet because it hasn't started tracking yet.");
 
39
    do_check_eq(tracker.score, 0);
 
40
 
 
41
    _("Tell the tracker to start tracking changes.");
 
42
    Svc.Obs.notify("weave:engine:start-tracking");
 
43
    prefs.set("testing.int", 23);
 
44
    do_check_eq(tracker.score, 25);
 
45
    do_check_eq(tracker.modified, true);
 
46
 
 
47
    _("Clearing changed IDs reset modified status.");
 
48
    tracker.clearChangedIDs();
 
49
    do_check_eq(tracker.modified, false);
 
50
 
 
51
    _("Resetting a pref ups the score, too.");
 
52
    prefs.reset("testing.int");
 
53
    do_check_eq(tracker.score, 50);
 
54
    do_check_eq(tracker.modified, true);
 
55
    tracker.clearChangedIDs();
 
56
 
 
57
    _("So does changing a pref sync pref.");
 
58
    Svc.Prefs.set("prefs.sync.testing.int", false);
 
59
    do_check_eq(tracker.score, 150);
 
60
    do_check_eq(tracker.modified, true);
 
61
    tracker.clearChangedIDs();
 
62
 
 
63
    _("Now that the pref sync pref has been flipped, changes to it won't be picked up.");
 
64
    prefs.set("testing.int", 42);
 
65
    do_check_eq(tracker.score, 150);
 
66
    do_check_eq(tracker.modified, false);
 
67
    tracker.clearChangedIDs();
 
68
 
 
69
    _("Changing some other random pref won't do anything.");
 
70
    prefs.set("testing.other", "blergh");
 
71
    do_check_eq(tracker.score, 150);
 
72
    do_check_eq(tracker.modified, false);
 
73
 
 
74
  } finally {
 
75
    Svc.Obs.notify("weave:engine:stop-tracking");
 
76
    prefs.resetBranch("");
 
77
  }
 
78
}