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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:8d3b2301eda9
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 */
5
6 /* General Partial MAR File Patch Apply Test */
7
8 function run_test() {
9 if (!shouldRunServiceTest()) {
10 return;
11 }
12
13 setupTestCommon();
14 gTestFiles = gTestFilesPartialSuccess;
15 gTestFiles[gTestFiles.length - 1].originalContents = null;
16 gTestFiles[gTestFiles.length - 1].compareContents = "FromPartial\n";
17 gTestFiles[gTestFiles.length - 1].comparePerms = 0o644;
18 gTestFiles[gTestFiles.length - 2].originalContents = null;
19 gTestFiles[gTestFiles.length - 2].compareContents = "FromPartial\n";
20 gTestFiles[gTestFiles.length - 2].comparePerms = 0o644;
21 gTestDirs = gTestDirsPartialSuccess;
22 setupUpdaterTest(FILE_PARTIAL_MAR, false, false);
23
24 // For Mac OS X set the last modified time for the root directory to a date in
25 // the past to test that the last modified time is updated on all updates since
26 // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
27 if (IS_MACOSX) {
28 let now = Date.now();
29 let yesterday = now - (1000 * 60 * 60 * 24);
30 let applyToDir = getApplyDirFile();
31 applyToDir.lastModifiedTime = yesterday;
32 }
33
34 setupAppFilesAsync();
35 }
36
37 function setupAppFilesFinished() {
38 runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED);
39 }
40
41 function checkUpdateFinished() {
42 if (IS_MACOSX) {
43 logTestInfo("testing last modified time on the apply to directory has " +
44 "changed after a successful update (bug 600098)");
45 let now = Date.now();
46 let applyToDir = getApplyDirFile();
47 let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
48 do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
49 }
50
51 checkFilesAfterUpdateSuccess();
52 // Sorting on Linux is different so skip this check for now.
53 if (!IS_UNIX) {
54 checkUpdateLogContents(LOG_PARTIAL_SUCCESS);
55 }
56
57 checkCallbackServiceLog();
58 }

mercurial