From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- devtools/client/shared/test/browser_graphs-11a.js | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 devtools/client/shared/test/browser_graphs-11a.js (limited to 'devtools/client/shared/test/browser_graphs-11a.js') diff --git a/devtools/client/shared/test/browser_graphs-11a.js b/devtools/client/shared/test/browser_graphs-11a.js new file mode 100644 index 000000000..27e5b292c --- /dev/null +++ b/devtools/client/shared/test/browser_graphs-11a.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that bar graph create a legend as expected. + +const BarGraphWidget = require("devtools/client/shared/widgets/BarGraphWidget"); + +const CATEGORIES = [ + { color: "#46afe3", label: "Foo" }, + { color: "#eb5368", label: "Bar" }, + { color: "#70bf53", label: "Baz" } +]; + +add_task(function* () { + yield addTab("about:blank"); + yield performTest(); + gBrowser.removeCurrentTab(); +}); + +function* performTest() { + let [host,, doc] = yield createHost(); + let graph = new BarGraphWidget(doc.body); + yield graph.once("ready"); + + testGraph(graph); + + yield graph.destroy(); + host.destroy(); +} + +function testGraph(graph) { + graph.format = CATEGORIES; + graph.setData([{ delta: 0, values: [] }]); + + let legendContainer = graph._document.querySelector(".bar-graph-widget-legend"); + ok(legendContainer, + "A legend container should be available."); + is(legendContainer.childNodes.length, 3, + "Three legend items should have been created."); + + let legendItems = graph._document.querySelectorAll(".bar-graph-widget-legend-item"); + is(legendItems.length, 3, + "Three legend items should exist in the entire graph."); + + is(legendItems[0].querySelector("[view=color]").style.backgroundColor, + "rgb(70, 175, 227)", "The first legend item has the correct color."); + is(legendItems[1].querySelector("[view=color]").style.backgroundColor, + "rgb(235, 83, 104)", "The second legend item has the correct color."); + is(legendItems[2].querySelector("[view=color]").style.backgroundColor, + "rgb(112, 191, 83)", "The third legend item has the correct color."); + + is(legendItems[0].querySelector("[view=label]").textContent, "Foo", + "The first legend item has the correct label."); + is(legendItems[1].querySelector("[view=label]").textContent, "Bar", + "The second legend item has the correct label."); + is(legendItems[2].querySelector("[view=label]").textContent, "Baz", + "The third legend item has the correct label."); +} -- cgit v1.2.3