toolkit/mozapps/update/tests/marionette/update_smoketest_ota_simple.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/tests/marionette/update_smoketest_ota_simple.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function testForceCheck() {
     1.8 +  addChromeEventListener("update-available", function(evt) {
     1.9 +    isFinishUpdate(evt.detail);
    1.10 +    statusSettingIs("check-complete", testDownload);
    1.11 +    return true;
    1.12 +  });
    1.13 +  sendContentEvent("force-update-check");
    1.14 +}
    1.15 +
    1.16 +function testDownload() {
    1.17 +  let gotStarted = false, gotProgress = false, gotStopped = false;
    1.18 +  let progress = 0, total = 0;
    1.19 +
    1.20 +  addChromeEventListener("update-download-started", function(evt) {
    1.21 +    gotStarted = true;
    1.22 +    return true;
    1.23 +  });
    1.24 +  addChromeEventListener("update-download-progress", function(evt) {
    1.25 +    progress = evt.detail.progress;
    1.26 +    total = evt.detail.total;
    1.27 +    gotProgress = true;
    1.28 +    if (total == progress) {
    1.29 +      ok(gotStarted);
    1.30 +      return true;
    1.31 +    }
    1.32 +    return false;
    1.33 +  });
    1.34 +  addChromeEventListener("update-download-stopped", function(evt) {
    1.35 +    is(evt.detail.paused, false);
    1.36 +    gotStopped = true;
    1.37 +    ok(gotStarted);
    1.38 +    ok(gotProgress);
    1.39 +    return true;
    1.40 +  });
    1.41 +  addChromeEventListener("update-downloaded", function(evt) {
    1.42 +    ok(gotStarted);
    1.43 +    ok(gotProgress);
    1.44 +    ok(gotStopped);
    1.45 +    is(progress, total);
    1.46 +    return true;
    1.47 +  });
    1.48 +  addChromeEventListener("update-prompt-apply", function(evt) {
    1.49 +    isStartToFinishUpdate(evt.detail);
    1.50 +    cleanUp();
    1.51 +  });
    1.52 +  sendContentEvent("update-available-result", {
    1.53 +    result: "download"
    1.54 +  });
    1.55 +}
    1.56 +
    1.57 +function testApplied() {
    1.58 +  let finish = getFinishBuild();
    1.59 +  is(Services.appinfo.version, finish.app_version,
    1.60 +     "Services.appinfo.version should be " + finish.app_version);
    1.61 +  is(Services.appinfo.platformVersion, finish.platform_milestone,
    1.62 +     "Services.appinfo.platformVersion should be " + finish.platform_milestone);
    1.63 +  is(Services.appinfo.appBuildID, finish.app_build_id,
    1.64 +     "Services.appinfo.appBuildID should be " + finish.app_build_id);
    1.65 +  cleanUp();
    1.66 +}
    1.67 +
    1.68 +// Update lifecycle callbacks
    1.69 +function preUpdate() {
    1.70 +  testForceCheck();
    1.71 +}
    1.72 +
    1.73 +function postUpdate() {
    1.74 +  testApplied();
    1.75 +}

mercurial