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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/tests/unit_service_updater/marFileLockedFailureCompleteSvc_win.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     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 locked complete MAR file patch apply failure 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 +  setTestFilesAndDirsForFailure();
    1.19 +  setupUpdaterTest(FILE_COMPLETE_MAR, false, false);
    1.20 +
    1.21 +  // Exclusively lock an existing file so it is in use during the update.
    1.22 +  let helperBin = getTestDirFile(FILE_HELPER_BIN);
    1.23 +  let helperDestDir = getApplyDirFile("a/b/");
    1.24 +  helperBin.copyTo(helperDestDir, FILE_HELPER_BIN);
    1.25 +  helperBin = getApplyDirFile("a/b/" + FILE_HELPER_BIN);
    1.26 +  // Strip off the first two directories so the path has to be from the helper's
    1.27 +  // working directory.
    1.28 +  let lockFileRelPath = gTestFiles[3].relPathDir.split("/");
    1.29 +  lockFileRelPath = lockFileRelPath.slice(2);
    1.30 +  lockFileRelPath = lockFileRelPath.join("/") + "/" + gTestFiles[3].fileName;
    1.31 +  let args = [getApplyDirPath() + "a/b/", "input", "output", "-s",
    1.32 +              HELPER_SLEEP_TIMEOUT, lockFileRelPath];
    1.33 +  let lockFileProcess = AUS_Cc["@mozilla.org/process/util;1"].
    1.34 +                     createInstance(AUS_Ci.nsIProcess);
    1.35 +  lockFileProcess.init(helperBin);
    1.36 +  lockFileProcess.run(false, args, args.length);
    1.37 +
    1.38 +  setupAppFilesAsync();
    1.39 +}
    1.40 +
    1.41 +function setupAppFilesFinished() {
    1.42 +  do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
    1.43 +}
    1.44 +
    1.45 +function doUpdate() {
    1.46 +  runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED);
    1.47 +}
    1.48 +
    1.49 +function checkUpdateFinished() {
    1.50 +  setupHelperFinish();
    1.51 +}
    1.52 +
    1.53 +function checkUpdate() {
    1.54 +  checkFilesAfterUpdateFailure();
    1.55 +  checkUpdateLogContains(ERR_RENAME_FILE);
    1.56 +  checkCallbackServiceLog();
    1.57 +}

mercurial