|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Makes sure Pie+Table Charts have the right internal structure. |
|
6 */ |
|
7 |
|
8 function test() { |
|
9 initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { |
|
10 info("Starting test... "); |
|
11 |
|
12 let { document, L10N, Chart } = aMonitor.panelWin; |
|
13 let container = document.createElement("box"); |
|
14 |
|
15 let chart = Chart.PieTable(document, { |
|
16 title: "Table title", |
|
17 data: [{ |
|
18 size: 1, |
|
19 label: 11.1 |
|
20 }, { |
|
21 size: 2, |
|
22 label: 12.2 |
|
23 }, { |
|
24 size: 3, |
|
25 label: 13.3 |
|
26 }], |
|
27 strings: { |
|
28 label2: (value, index) => value + ["foo", "bar", "baz"][index] |
|
29 }, |
|
30 totals: { |
|
31 size: value => "Hello " + L10N.numberWithDecimals(value, 2), |
|
32 label: value => "World " + L10N.numberWithDecimals(value, 2) |
|
33 } |
|
34 }); |
|
35 |
|
36 ok(chart.pie, "The pie chart proxy is accessible."); |
|
37 ok(chart.table, "The table chart proxy is accessible."); |
|
38 |
|
39 let node = chart.node; |
|
40 let slices = node.querySelectorAll(".pie-chart-slice"); |
|
41 let rows = node.querySelectorAll(".table-chart-row"); |
|
42 let sums = node.querySelectorAll(".table-chart-summary-label"); |
|
43 |
|
44 ok(node.classList.contains("pie-table-chart-container"), |
|
45 "A pie+table chart container was created successfully."); |
|
46 |
|
47 ok(node.querySelector(".table-chart-title"), |
|
48 "A title node was created successfully."); |
|
49 ok(node.querySelector(".pie-chart-container"), |
|
50 "A pie chart was created successfully."); |
|
51 ok(node.querySelector(".table-chart-container"), |
|
52 "A table chart was created successfully."); |
|
53 |
|
54 is(rows.length, 3, |
|
55 "There should be 3 pie chart slices created."); |
|
56 is(rows.length, 3, |
|
57 "There should be 3 table chart rows created."); |
|
58 is(sums.length, 2, |
|
59 "There should be 2 total summaries created."); |
|
60 |
|
61 teardown(aMonitor).then(finish); |
|
62 }); |
|
63 } |