1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_charts-05.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Makes sure Pie+Table Charts have the right internal structure. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + let { document, L10N, Chart } = aMonitor.panelWin; 1.16 + let container = document.createElement("box"); 1.17 + 1.18 + let chart = Chart.PieTable(document, { 1.19 + title: "Table title", 1.20 + data: [{ 1.21 + size: 1, 1.22 + label: 11.1 1.23 + }, { 1.24 + size: 2, 1.25 + label: 12.2 1.26 + }, { 1.27 + size: 3, 1.28 + label: 13.3 1.29 + }], 1.30 + strings: { 1.31 + label2: (value, index) => value + ["foo", "bar", "baz"][index] 1.32 + }, 1.33 + totals: { 1.34 + size: value => "Hello " + L10N.numberWithDecimals(value, 2), 1.35 + label: value => "World " + L10N.numberWithDecimals(value, 2) 1.36 + } 1.37 + }); 1.38 + 1.39 + ok(chart.pie, "The pie chart proxy is accessible."); 1.40 + ok(chart.table, "The table chart proxy is accessible."); 1.41 + 1.42 + let node = chart.node; 1.43 + let slices = node.querySelectorAll(".pie-chart-slice"); 1.44 + let rows = node.querySelectorAll(".table-chart-row"); 1.45 + let sums = node.querySelectorAll(".table-chart-summary-label"); 1.46 + 1.47 + ok(node.classList.contains("pie-table-chart-container"), 1.48 + "A pie+table chart container was created successfully."); 1.49 + 1.50 + ok(node.querySelector(".table-chart-title"), 1.51 + "A title node was created successfully."); 1.52 + ok(node.querySelector(".pie-chart-container"), 1.53 + "A pie chart was created successfully."); 1.54 + ok(node.querySelector(".table-chart-container"), 1.55 + "A table chart was created successfully."); 1.56 + 1.57 + is(rows.length, 3, 1.58 + "There should be 3 pie chart slices created."); 1.59 + is(rows.length, 3, 1.60 + "There should be 3 table chart rows created."); 1.61 + is(sums.length, 2, 1.62 + "There should be 2 total summaries created."); 1.63 + 1.64 + teardown(aMonitor).then(finish); 1.65 + }); 1.66 +}