1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/tests/marionette/update_test_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 + let update = evt.detail; 1.10 + is(update.displayVersion, "99.0"); 1.11 + is(update.isOSUpdate, false); 1.12 + statusSettingIs("check-complete", testDownload); 1.13 + return true; 1.14 + }); 1.15 + sendContentEvent("force-update-check"); 1.16 +} 1.17 + 1.18 +function testDownload() { 1.19 + let gotStarted = false, gotProgress = false, gotStopped = false; 1.20 + let progress = 0, total = 0; 1.21 + 1.22 + addChromeEventListener("update-download-started", function(evt) { 1.23 + gotStarted = true; 1.24 + return true; 1.25 + }); 1.26 + addChromeEventListener("update-download-progress", function(evt) { 1.27 + progress = evt.detail.progress; 1.28 + total = evt.detail.total; 1.29 + gotProgress = true; 1.30 + if (total == progress) { 1.31 + ok(gotStarted); 1.32 + return true; 1.33 + } 1.34 + return false; 1.35 + }); 1.36 + addChromeEventListener("update-download-stopped", function(evt) { 1.37 + is(evt.detail.paused, false); 1.38 + gotStopped = true; 1.39 + ok(gotStarted); 1.40 + ok(gotProgress); 1.41 + return true; 1.42 + }); 1.43 + addChromeEventListener("update-downloaded", function(evt) { 1.44 + ok(gotStarted); 1.45 + ok(gotProgress); 1.46 + ok(gotStopped); 1.47 + is(progress, total); 1.48 + return true; 1.49 + }); 1.50 + addChromeEventListener("update-prompt-apply", function(evt) { 1.51 + let update = evt.detail; 1.52 + is(update.displayVersion, "99.0"); 1.53 + is(update.isOSUpdate, false); 1.54 + cleanUp(); 1.55 + }); 1.56 + sendContentEvent("update-available-result", { 1.57 + result: "download" 1.58 + }); 1.59 +} 1.60 + 1.61 +function testApplied() { 1.62 + let updateFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); 1.63 + updateFile.initWithPath("/system/b2g/update_test/UpdateTestAddFile"); 1.64 + ok(updateFile.exists()); 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 +}