1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/tests/unit_service_updater/marSuccessCompleteSvc.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + */ 1.8 + 1.9 +/* General Complete MAR File Patch Apply Test */ 1.10 + 1.11 +function run_test() { 1.12 + if (!shouldRunServiceTest()) { 1.13 + return; 1.14 + } 1.15 + 1.16 + setupTestCommon(); 1.17 + gTestFiles = gTestFilesCompleteSuccess; 1.18 + gTestDirs = gTestDirsCompleteSuccess; 1.19 + setupUpdaterTest(FILE_COMPLETE_MAR, false, false); 1.20 + 1.21 + // For Mac OS X set the last modified time for the root directory to a date in 1.22 + // the past to test that the last modified time is updated on a successful 1.23 + // update (bug 600098). 1.24 + if (IS_MACOSX) { 1.25 + let now = Date.now(); 1.26 + let yesterday = now - (1000 * 60 * 60 * 24); 1.27 + let applyToDir = getApplyDirFile(); 1.28 + applyToDir.lastModifiedTime = yesterday; 1.29 + } 1.30 + 1.31 + setupAppFilesAsync(); 1.32 +} 1.33 + 1.34 +function setupAppFilesFinished() { 1.35 + runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED); 1.36 +} 1.37 + 1.38 +function checkUpdateFinished() { 1.39 + if (IS_MACOSX) { 1.40 + logTestInfo("testing last modified time on the apply to directory has " + 1.41 + "changed after a successful update (bug 600098)"); 1.42 + let now = Date.now(); 1.43 + let applyToDir = getApplyDirFile(); 1.44 + let timeDiff = Math.abs(applyToDir.lastModifiedTime - now); 1.45 + do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE); 1.46 + } 1.47 + 1.48 + checkFilesAfterUpdateSuccess(); 1.49 + // Sorting on Linux is different so skip this check for now. 1.50 + if (!IS_UNIX) { 1.51 + checkUpdateLogContents(LOG_COMPLETE_SUCCESS); 1.52 + } 1.53 + 1.54 + checkCallbackServiceLog(); 1.55 +}