1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/status.js");
function run_test() {
// Check initial states
do_check_false(Status.enforceBackoff);
do_check_eq(Status.backoffInterval, 0);
do_check_eq(Status.minimumNextSync, 0);
do_check_eq(Status.service, STATUS_OK);
do_check_eq(Status.sync, SYNC_SUCCEEDED);
do_check_eq(Status.login, LOGIN_SUCCEEDED);
for (let name in Status.engines) {
do_throw('Status.engines should be empty.');
}
do_check_eq(Status.partial, false);
// Check login status
for (let code of [LOGIN_FAILED_NO_USERNAME,
LOGIN_FAILED_NO_PASSWORD,
LOGIN_FAILED_NO_PASSPHRASE]) {
Status.login = code;
do_check_eq(Status.login, code);
do_check_eq(Status.service, CLIENT_NOT_CONFIGURED);
Status.resetSync();
}
Status.login = LOGIN_FAILED;
do_check_eq(Status.login, LOGIN_FAILED);
do_check_eq(Status.service, LOGIN_FAILED);
Status.resetSync();
Status.login = LOGIN_SUCCEEDED;
do_check_eq(Status.login, LOGIN_SUCCEEDED);
do_check_eq(Status.service, STATUS_OK);
Status.resetSync();
// Check sync status
Status.sync = SYNC_FAILED;
do_check_eq(Status.sync, SYNC_FAILED);
do_check_eq(Status.service, SYNC_FAILED);
Status.sync = SYNC_SUCCEEDED;
do_check_eq(Status.sync, SYNC_SUCCEEDED);
do_check_eq(Status.service, STATUS_OK);
Status.resetSync();
// Check engine status
Status.engines = ["testEng1", ENGINE_SUCCEEDED];
do_check_eq(Status.engines["testEng1"], ENGINE_SUCCEEDED);
do_check_eq(Status.service, STATUS_OK);
Status.engines = ["testEng2", ENGINE_DOWNLOAD_FAIL];
do_check_eq(Status.engines["testEng1"], ENGINE_SUCCEEDED);
do_check_eq(Status.engines["testEng2"], ENGINE_DOWNLOAD_FAIL);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
Status.engines = ["testEng3", ENGINE_SUCCEEDED];
do_check_eq(Status.engines["testEng1"], ENGINE_SUCCEEDED);
do_check_eq(Status.engines["testEng2"], ENGINE_DOWNLOAD_FAIL);
do_check_eq(Status.engines["testEng3"], ENGINE_SUCCEEDED);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
// Check resetSync
Status.sync = SYNC_FAILED;
Status.resetSync();
do_check_eq(Status.service, STATUS_OK);
do_check_eq(Status.sync, SYNC_SUCCEEDED);
for (name in Status.engines) {
do_throw('Status.engines should be empty.');
}
// Check resetBackoff
Status.enforceBackoff = true;
Status.backOffInterval = 4815162342;
Status.backOffInterval = 42;
Status.resetBackoff();
do_check_false(Status.enforceBackoff);
do_check_eq(Status.backoffInterval, 0);
do_check_eq(Status.minimumNextSync, 0);
}
|