browser/devtools/netmonitor/test/browser_net_charts-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/netmonitor/test/browser_net_charts-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     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 have the right internal structure when
     1.9 + * initialized with empty data.
    1.10 + */
    1.11 +
    1.12 +function test() {
    1.13 +  initNetMonitor(SIMPLE_URL).then(([aTab, aDebuggee, aMonitor]) => {
    1.14 +    info("Starting test... ");
    1.15 +
    1.16 +    let { document, L10N, Chart } = aMonitor.panelWin;
    1.17 +    let container = document.createElement("box");
    1.18 +
    1.19 +    let pie = Chart.Pie(document, {
    1.20 +      data: null,
    1.21 +      width: 100,
    1.22 +      height: 100
    1.23 +    });
    1.24 +
    1.25 +    let node = pie.node;
    1.26 +    let slices = node.querySelectorAll(".pie-chart-slice.chart-colored-blob");
    1.27 +    let labels = node.querySelectorAll(".pie-chart-label");
    1.28 +
    1.29 +    ok(node.classList.contains("pie-chart-container") &&
    1.30 +       node.classList.contains("generic-chart-container"),
    1.31 +      "A pie chart container was created successfully.");
    1.32 +
    1.33 +    is(slices.length, 1,
    1.34 +      "There should be 1 pie chart slice created.");
    1.35 +    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.36 +      "The first slice has the correct data.");
    1.37 +
    1.38 +    ok(slices[0].hasAttribute("largest"),
    1.39 +      "The first slice should be the largest one.");
    1.40 +    ok(slices[0].hasAttribute("smallest"),
    1.41 +      "The first slice should also be the smallest one.");
    1.42 +    ok(slices[0].getAttribute("name"), L10N.getStr("pieChart.loading"),
    1.43 +      "The first slice's name is correct.");
    1.44 +
    1.45 +    is(labels.length, 1,
    1.46 +      "There should be 1 pie chart label created.");
    1.47 +    is(labels[0].textContent, "Loading",
    1.48 +      "The first label's text is correct.");
    1.49 +
    1.50 +    teardown(aMonitor).then(finish);
    1.51 +  });
    1.52 +}

mercurial