Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | let doc; |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | Task.spawn(function(){ |
michael@0 | 10 | info(chromeRoot + "browser_progress_indicator.xul"); |
michael@0 | 11 | yield addTab(chromeRoot + "browser_progress_indicator.xul"); |
michael@0 | 12 | doc = Browser.selectedTab.browser.contentWindow.document; |
michael@0 | 13 | }).then(runTests); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | gTests.push({ |
michael@0 | 17 | desc: "circular progress indicator binding is applied.", |
michael@0 | 18 | run: function() { |
michael@0 | 19 | ok(doc, "doc got defined"); |
michael@0 | 20 | |
michael@0 | 21 | let progressIndicator = doc.querySelector("#progress-indicator"); |
michael@0 | 22 | ok(progressIndicator, "progress-indicator is found"); |
michael@0 | 23 | is(typeof progressIndicator.reset, "function", "#progress-indicator has a reset() function"); |
michael@0 | 24 | is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); |
michael@0 | 25 | } |
michael@0 | 26 | }); |
michael@0 | 27 | |
michael@0 | 28 | gTests.push({ |
michael@0 | 29 | desc: "start and end angles are correct for various percents complete", |
michael@0 | 30 | run: function() { |
michael@0 | 31 | let progressIndicator = doc.querySelector("#progress-indicator"); |
michael@0 | 32 | ok(progressIndicator, "progress-indicator is found"); |
michael@0 | 33 | is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); |
michael@0 | 34 | |
michael@0 | 35 | let expectedStartAngle = 1.5 * Math.PI; |
michael@0 | 36 | |
michael@0 | 37 | let percentComplete = 0; |
michael@0 | 38 | let [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); |
michael@0 | 39 | is(startAngle, expectedStartAngle, "start angle is correct"); |
michael@0 | 40 | is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); |
michael@0 | 41 | |
michael@0 | 42 | percentComplete = 0.05; |
michael@0 | 43 | [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); |
michael@0 | 44 | is(startAngle, expectedStartAngle, "start angle is correct"); |
michael@0 | 45 | is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); |
michael@0 | 46 | |
michael@0 | 47 | percentComplete = 0.5; |
michael@0 | 48 | [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); |
michael@0 | 49 | is(startAngle, expectedStartAngle, "start angle is correct"); |
michael@0 | 50 | is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); |
michael@0 | 51 | |
michael@0 | 52 | percentComplete = 1; |
michael@0 | 53 | [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); |
michael@0 | 54 | is(startAngle, expectedStartAngle, "start angle is correct"); |
michael@0 | 55 | is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); |
michael@0 | 56 | } |
michael@0 | 57 | }); |