toolkit/mozapps/update/tests/unit_service_updater/marFailurePartialSvc.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/marFailurePartialSvc.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,54 @@
     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 Partial MAR File Patch Apply Failure 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 = gTestFilesPartialSuccess;
    1.18 +  gTestFiles[11].originalFile = "partial.png";
    1.19 +  gTestDirs = gTestDirsPartialSuccess;
    1.20 +  setTestFilesAndDirsForFailure();
    1.21 +  setupUpdaterTest(FILE_PARTIAL_MAR, false, false);
    1.22 +
    1.23 +  // For Mac OS X set the last modified time for the root directory to a date in
    1.24 +  // the past to test that the last modified time is updated on all updates since
    1.25 +  // the precomplete file in the root of the bundle is renamed, etc. (bug 600098).
    1.26 +  if (IS_MACOSX) {
    1.27 +    let now = Date.now();
    1.28 +    let yesterday = now - (1000 * 60 * 60 * 24);
    1.29 +    let applyToDir = getApplyDirFile();
    1.30 +    applyToDir.lastModifiedTime = yesterday;
    1.31 +  }
    1.32 +
    1.33 +  setupAppFilesAsync();
    1.34 +}
    1.35 +
    1.36 +function setupAppFilesFinished() {
    1.37 +  runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED);
    1.38 +}
    1.39 +
    1.40 +function checkUpdateFinished() {
    1.41 +  if (IS_MACOSX) {
    1.42 +    logTestInfo("testing last modified time on the apply to directory has " +
    1.43 +                "changed after a successful update (bug 600098)");
    1.44 +    let now = Date.now();
    1.45 +    let applyToDir = getApplyDirFile();
    1.46 +    let timeDiff = Math.abs(applyToDir.lastModifiedTime - now);
    1.47 +    do_check_true(timeDiff < MAC_MAX_TIME_DIFFERENCE);
    1.48 +  }
    1.49 +
    1.50 +  checkFilesAfterUpdateFailure();
    1.51 +  // Sorting on Linux is different so skip this check for now.
    1.52 +  if (!IS_UNIX) {
    1.53 +    checkUpdateLogContents(LOG_PARTIAL_FAILURE);
    1.54 +  }
    1.55 +
    1.56 +  checkCallbackServiceLog();
    1.57 +}

mercurial