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