1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/tests/unit_service_updater/marRMRFDirFileInUseSuccessCompleteSvc_win.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +/* File in use inside removed dir complete MAR file patch apply success test */ 1.9 + 1.10 +function run_test() { 1.11 + if (!shouldRunServiceTest()) { 1.12 + return; 1.13 + } 1.14 + 1.15 + setupTestCommon(); 1.16 + gTestFiles = gTestFilesCompleteSuccess; 1.17 + gTestDirs = gTestDirsCompleteSuccess; 1.18 + setupUpdaterTest(FILE_COMPLETE_MAR, false, true); 1.19 + 1.20 + let fileInUseBin = getApplyDirFile(gTestDirs[4].relPathDir + 1.21 + gTestDirs[4].subDirs[0] + 1.22 + gTestDirs[4].subDirFiles[0]); 1.23 + // Remove the empty file created for the test so the helper application can 1.24 + // replace it. 1.25 + fileInUseBin.remove(false); 1.26 + 1.27 + let helperBin = getTestDirFile(FILE_HELPER_BIN); 1.28 + let fileInUseDir = getApplyDirFile(gTestDirs[4].relPathDir + 1.29 + gTestDirs[4].subDirs[0]); 1.30 + helperBin.copyTo(fileInUseDir, gTestDirs[4].subDirFiles[0]); 1.31 + 1.32 + // Launch an existing file so it is in use during the update. 1.33 + let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", 1.34 + HELPER_SLEEP_TIMEOUT]; 1.35 + let fileInUseProcess = AUS_Cc["@mozilla.org/process/util;1"]. 1.36 + createInstance(AUS_Ci.nsIProcess); 1.37 + fileInUseProcess.init(fileInUseBin); 1.38 + fileInUseProcess.run(false, args, args.length); 1.39 + 1.40 + setupAppFilesAsync(); 1.41 +} 1.42 + 1.43 +function setupAppFilesFinished() { 1.44 + do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep); 1.45 +} 1.46 + 1.47 +function doUpdate() { 1.48 + runUpdateUsingService(STATE_PENDING_SVC, STATE_SUCCEEDED); 1.49 +} 1.50 + 1.51 +function checkUpdateFinished() { 1.52 + setupHelperFinish(); 1.53 +} 1.54 + 1.55 +function checkUpdate() { 1.56 + checkFilesAfterUpdateSuccess(); 1.57 + checkUpdateLogContains(ERR_BACKUP_DISCARD); 1.58 + checkCallbackServiceLog(); 1.59 +}