1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_charts-06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 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 Charts correctly handle empty source data. 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 pie = Chart.Pie(document, { 1.19 + data: [], 1.20 + width: 100, 1.21 + height: 100 1.22 + }); 1.23 + 1.24 + let node = pie.node; 1.25 + let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob"); 1.26 + let labels = node.querySelectorAll(".pie-chart-label"); 1.27 + 1.28 + is(slices.length, 1, 1.29 + "There should be 1 pie chart slice created."); 1.30 + 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/), 1.31 + "The slice has the correct data."); 1.32 + 1.33 + ok(slices[0].hasAttribute("largest"), 1.34 + "The slice should be the largest one."); 1.35 + ok(slices[0].hasAttribute("smallest"), 1.36 + "The slice should also be the smallest one."); 1.37 + ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.unavailable"), 1.38 + "The slice's name is correct."); 1.39 + 1.40 + is(labels.length, 1, 1.41 + "There should be 1 pie chart label created."); 1.42 + is(labels[0].textContent, "Empty", 1.43 + "The label's text is correct."); 1.44 + 1.45 + teardown(aMonitor).then(finish); 1.46 + }); 1.47 +}