|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Makes sure Pie Charts have the right internal structure when |
|
6 * initialized with empty data. |
|
7 */ |
|
8 |
|
9 function test() { |
|
10 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
11 info("Starting test... "); |
|
12 |
|
13 let { document, L10N, Chart } = aMonitor.panelWin; |
|
14 let container = document.createElement("box"); |
|
15 |
|
16 let pie = Chart.Pie(document, { |
|
17 data: null, |
|
18 width: 100, |
|
19 height: 100 |
|
20 }); |
|
21 |
|
22 let node = pie.node; |
|
23 let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); |
|
24 let labels = node.querySelectorAll(".pie-chart-label"); |
|
25 |
|
26 ok(node.classList.contains("pie-chart-container") && |
|
27 node.classList.contains("generic-chart-container"), |
|
28 "A pie chart container was created successfully."); |
|
29 |
|
30 is(slices.length, 1, |
|
31 "There should be 1 pie chart slice created."); |
|
32 ok(slices[0].getAttribute("d").match(/\s*M 50,50 L 50\.\d+,2\.5\d* A 47\.5,47\.5 0 1 1 49\.\d+,2\.5\d* Z/), |
|
33 "The first slice has the correct data."); |
|
34 |
|
35 ok(slices[0].hasAttribute("largest"), |
|
36 "The first slice should be the largest one."); |
|
37 ok(slices[0].hasAttribute("smallest"), |
|
38 "The first slice should also be the smallest one."); |
|
39 ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"), |
|
40 "The first slice's name is correct."); |
|
41 |
|
42 is(labels.length, 1, |
|
43 "There should be 1 pie chart label created."); |
|
44 is(labels[0].textContent, "Loading", |
|
45 "The first label's text is correct."); |
|
46 |
|
47 teardown(aMonitor).then(finish); |
|
48 }); |
|
49 } |