diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/shared/test/browser_graphs-03.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/shared/test/browser_graphs-03.js')
-rw-r--r-- | devtools/client/shared/test/browser_graphs-03.js | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/devtools/client/shared/test/browser_graphs-03.js b/devtools/client/shared/test/browser_graphs-03.js new file mode 100644 index 000000000..b44d4620a --- /dev/null +++ b/devtools/client/shared/test/browser_graphs-03.js @@ -0,0 +1,111 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that graph widgets can handle clients getting/setting the +// selection or cursor. + +const LineGraphWidget = require("devtools/client/shared/widgets/LineGraphWidget"); + +add_task(function* () { + yield addTab("about:blank"); + yield performTest(); + gBrowser.removeCurrentTab(); +}); + +function* performTest() { + let [host,, doc] = yield createHost(); + let graph = new LineGraphWidget(doc.body, "fps"); + yield graph.once("ready"); + + yield testSelection(graph); + yield testCursor(graph); + + yield graph.destroy(); + host.destroy(); +} + +function* testSelection(graph) { + ok(graph.getSelection().start === null, + "The graph's selection should initially have a null start value."); + ok(graph.getSelection().end === null, + "The graph's selection should initially have a null end value."); + ok(!graph.hasSelection(), + "There shouldn't initially be any selection."); + + let selected = graph.once("selecting"); + graph.setSelection({ start: 100, end: 200 }); + + yield selected; + ok(true, "A 'selecting' event has been fired."); + + ok(graph.hasSelection(), + "There should now be a selection."); + is(graph.getSelection().start, 100, + "The graph's selection now has an updated start value."); + is(graph.getSelection().end, 200, + "The graph's selection now has an updated end value."); + + let thrown; + try { + graph.setSelection({ start: null, end: null }); + } catch (e) { + thrown = true; + } + ok(thrown, "Setting a null selection shouldn't work."); + + ok(graph.hasSelection(), + "There should still be a selection."); + + let deselected = graph.once("deselecting"); + graph.dropSelection(); + + yield deselected; + ok(true, "A 'deselecting' event has been fired."); + + ok(!graph.hasSelection(), + "There shouldn't be any selection anymore."); + ok(graph.getSelection().start === null, + "The graph's selection now has a null start value."); + ok(graph.getSelection().end === null, + "The graph's selection now has a null end value."); +} + +function* testCursor(graph) { + ok(graph.getCursor().x === null, + "The graph's cursor should initially have a null X value."); + ok(graph.getCursor().y === null, + "The graph's cursor should initially have a null Y value."); + ok(!graph.hasCursor(), + "There shouldn't initially be any cursor."); + + graph.setCursor({ x: 100, y: 50 }); + + ok(graph.hasCursor(), + "There should now be a cursor."); + is(graph.getCursor().x, 100, + "The graph's cursor now has an updated start value."); + is(graph.getCursor().y, 50, + "The graph's cursor now has an updated end value."); + + let thrown; + try { + graph.setCursor({ x: null, y: null }); + } catch (e) { + thrown = true; + } + ok(thrown, "Setting a null cursor shouldn't work."); + + ok(graph.hasCursor(), + "There should still be a cursor."); + + graph.dropCursor(); + + ok(!graph.hasCursor(), + "There shouldn't be any cursor anymore."); + ok(graph.getCursor().x === null, + "The graph's cursor now has a null start value."); + ok(graph.getCursor().y === null, + "The graph's cursor now has a null end value."); +} |