toolkit/mozapps/update/tests/unit_service_updater/marAppInUseSuccessCompleteSvc.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/marAppInUseSuccessCompleteSvc.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     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 +/* Application in use 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, false);
    1.19 +
    1.20 +  // Launch the callback helper application so it is in use during the update.
    1.21 +  let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
    1.22 +  callbackApp.permissions = PERMS_DIRECTORY;
    1.23 +  let args = [getApplyDirPath() + "a/b/", "input", "output", "-s",
    1.24 +              HELPER_SLEEP_TIMEOUT];
    1.25 +  let callbackAppProcess = AUS_Cc["@mozilla.org/process/util;1"].
    1.26 +                           createInstance(AUS_Ci.nsIProcess);
    1.27 +  callbackAppProcess.init(callbackApp);
    1.28 +  callbackAppProcess.run(false, args, args.length);
    1.29 +
    1.30 +  setupAppFilesAsync();
    1.31 +}
    1.32 +
    1.33 +function setupAppFilesFinished() {
    1.34 +  do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep);
    1.35 +}
    1.36 +
    1.37 +function doUpdate() {
    1.38 +  // For Mac OS X set the last modified time for the root directory to a date in
    1.39 +  // the past to test that the last modified time is updated on a successful
    1.40 +  // update (bug 600098).
    1.41 +  if (IS_MACOSX) {
    1.42 +    let applyToDir = getApplyDirFile();
    1.43 +    let now = Date.now();
    1.44 +    let yesterday = now - (1000 * 60 * 60 * 24);
    1.45 +    applyToDir.lastModifiedTime = yesterday;
    1.46 +  }
    1.47 +
    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 +  if (IS_MACOSX) {
    1.57 +    logTestInfo("testing last modified time on the apply to directory has " +
    1.58 +                "changed after a successful update (bug 600098)");
    1.59 +    let now = Date.now();
    1.60 +    let applyToDir = getApplyDirFile();
    1.61 +    let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
    1.62 +    do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
    1.63 +  }
    1.64 +
    1.65 +  checkFilesAfterUpdateSuccess();
    1.66 +  // Sorting on Linux is different so skip this check for now.
    1.67 +  if (!IS_UNIX) {
    1.68 +    checkUpdateLogContents(LOG_COMPLETE_SUCCESS);
    1.69 +  }
    1.70 +
    1.71 +  checkCallbackServiceLog();
    1.72 +}

mercurial