toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:92d197c4ffe7
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 /* Application in use complete MAR file patch apply success test */
6
7 function run_test() {
8 if (!shouldRunServiceTest()) {
9 return;
10 }
11
12 setupTestCommon();
13 gTestFiles = gTestFilesCompleteSuccess;
14 gTestDirs = gTestDirsCompleteSuccess;
15 setupUpdaterTest(FILE_COMPLETE_MAR, false, false);
16
17 // Launch the callback helper application so it is in use during the update.
18 let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
19 callbackApp.permissions = PERMS_DIRECTORY;
20 let args = [getApplyDirPath() + "a/b/", "input", "output", "-s",
21 HELPER_SLEEP_TIMEOUT];
22 let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
23 createInstance(AUS_Ci.nsIProcess);
24 callbackAppProcess.init(callbackApp);
25 callbackAppProcess.run(false, args, args.length);
26
27 setupAppFilesAsync();
28 }
29
30 function setupAppFilesFinished() {
31 do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
32 }
33
34 function doUpdate() {
35 // For Mac OS X set the last modified time for the root directory to a date in
36 // the past to test that the last modified time is updated on a successful
37 // update (bug 600098).
38 if (IS_MACOSX) {
39 let applyToDir = getApplyDirFile();
40 let now = Date.now();
41 let yesterday = now - (1000 * 60 * 60 * 24);
42 applyToDir.lastModifiedTime = yesterday;
43 }
44
45 runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED);
46 }
47
48 function checkUpdateFinished() {
49 setupHelperFinish();
50 }
51
52 function checkUpdate() {
53 if (IS_MACOSX) {
54 logTestInfo("testing last modified time on the apply to directory has " +
55 "changed after a successful update (bug 600098)");
56 let now = Date.now();
57 let applyToDir = getApplyDirFile();
58 let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
59 do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
60 }
61
62 checkFilesAfterUpdateSuccess();
63 // Sorting on Linux is different so skip this check for now.
64 if (!IS_UNIX) {
65 checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
66 }
67
68 checkCallbackServiceLog();
69 }

mercurial