toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     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 +function run_test() {
    1.10 +  setupTestCommon();
    1.11 +
    1.12 +  logTestInfo("testing resuming an update download in progress for the same " +
    1.13 +              "version of the application on startup (Bug 485624)");
    1.14 +
    1.15 +  var patches, updates;
    1.16 +
    1.17 +  patches = getLocalPatchString(null, null, null, null, null, null,
    1.18 +                                STATE_DOWNLOADING);
    1.19 +  updates = getLocalUpdateString(patches, null, null, "1.0", "1.0");
    1.20 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(updates), true);
    1.21 +  writeStatusFile(STATE_DOWNLOADING);
    1.22 +
    1.23 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
    1.24 +
    1.25 +  standardInit();
    1.26 +
    1.27 +  if (IS_TOOLKIT_GONK) {
    1.28 +    // GONK doesn't resume downloads at boot time, so the updateCount will
    1.29 +    // always be zero.
    1.30 +    do_check_eq(gUpdateManager.updateCount, 0);
    1.31 +  } else {
    1.32 +    do_check_eq(gUpdateManager.updateCount, 1);
    1.33 +  }
    1.34 +  do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING);
    1.35 +
    1.36 +  // Pause the download and reload the Update Manager with an empty update so
    1.37 +  // the Application Update Service doesn't write the update xml files during
    1.38 +  // xpcom-shutdown which will leave behind the test directory.
    1.39 +  gAUS.pauseDownload();
    1.40 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), true);
    1.41 +  writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);
    1.42 +  reloadUpdateManagerData();
    1.43 +
    1.44 +  do_timeout(TEST_CHECK_TIMEOUT, doTestFinish);
    1.45 +}

mercurial