1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/tests/mochitest/browser_circular_progress_indicator.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 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 +let doc; 1.9 + 1.10 +function test() { 1.11 + waitForExplicitFinish(); 1.12 + Task.spawn(function(){ 1.13 + info(chromeRoot + "browser_progress_indicator.xul"); 1.14 + yield addTab(chromeRoot + "browser_progress_indicator.xul"); 1.15 + doc = Browser.selectedTab.browser.contentWindow.document; 1.16 + }).then(runTests); 1.17 +} 1.18 + 1.19 +gTests.push({ 1.20 + desc: "circular progress indicator binding is applied.", 1.21 + run: function() { 1.22 + ok(doc, "doc got defined"); 1.23 + 1.24 + let progressIndicator = doc.querySelector("#progress-indicator"); 1.25 + ok(progressIndicator, "progress-indicator is found"); 1.26 + is(typeof progressIndicator.reset, "function", "#progress-indicator has a reset() function"); 1.27 + is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); 1.28 + } 1.29 +}); 1.30 + 1.31 +gTests.push({ 1.32 + desc: "start and end angles are correct for various percents complete", 1.33 + run: function() { 1.34 + let progressIndicator = doc.querySelector("#progress-indicator"); 1.35 + ok(progressIndicator, "progress-indicator is found"); 1.36 + is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); 1.37 + 1.38 + let expectedStartAngle = 1.5 * Math.PI; 1.39 + 1.40 + let percentComplete = 0; 1.41 + let [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); 1.42 + is(startAngle, expectedStartAngle, "start angle is correct"); 1.43 + is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); 1.44 + 1.45 + percentComplete = 0.05; 1.46 + [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); 1.47 + is(startAngle, expectedStartAngle, "start angle is correct"); 1.48 + is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); 1.49 + 1.50 + percentComplete = 0.5; 1.51 + [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); 1.52 + is(startAngle, expectedStartAngle, "start angle is correct"); 1.53 + is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); 1.54 + 1.55 + percentComplete = 1; 1.56 + [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); 1.57 + is(startAngle, expectedStartAngle, "start angle is correct"); 1.58 + is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); 1.59 + } 1.60 +}); 1.61 \ No newline at end of file