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/memory/test/unit/test_tree-map-02.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/memory/test/unit/test_tree-map-02.js')
-rw-r--r-- | devtools/client/memory/test/unit/test_tree-map-02.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/devtools/client/memory/test/unit/test_tree-map-02.js b/devtools/client/memory/test/unit/test_tree-map-02.js new file mode 100644 index 000000000..4f7200f0a --- /dev/null +++ b/devtools/client/memory/test/unit/test_tree-map-02.js @@ -0,0 +1,81 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { drawText } = require("devtools/client/memory/components/tree-map/draw"); + +function run_test() { + run_next_test(); +} + +add_task(function* () { + // Mock out the Canvas2dContext + let ctx = { + fillText: (...args) => fillTextValues.push(args), + measureText: (text) => { + let width = text ? text.length * 10 : 0; + return { width }; + } + }; + let node = { + x: 20, + y: 30, + dx: 500, + dy: 70, + name: "Example Node", + totalBytes: 1200, + totalCount: 100 + }; + let ratio = 0; + let borderWidth = () => 1; + let dragZoom = { + offsetX: 0, + offsetY: 0, + zoom: 0 + }; + let fillTextValues = []; + let padding = [10, 10]; + + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + deepEqual(fillTextValues[0], ["Example Node", 11.5, 21.5], + "Fills in the full node name"); + deepEqual(fillTextValues[1], ["1KiB 100 count", 141.5, 21.5], + "Includes the full byte and count information"); + + fillTextValues = []; + node.dx = 250; + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + + deepEqual(fillTextValues[0], ["Example Node", 11.5, 21.5], + "Fills in the full node name"); + deepEqual(fillTextValues[1], undefined, + "Drops off the byte and count information if not enough room"); + + fillTextValues = []; + node.dx = 100; + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + + deepEqual(fillTextValues[0], ["Exampl...", 11.5, 21.5], + "Cuts the name with ellipsis"); + deepEqual(fillTextValues[1], undefined, + "Drops off the byte and count information if not enough room"); + + fillTextValues = []; + node.dx = 40; + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + + deepEqual(fillTextValues[0], ["...", 11.5, 21.5], + "Shows only ellipsis when smaller"); + deepEqual(fillTextValues[1], undefined, + "Drops off the byte and count information if not enough room"); + + fillTextValues = []; + node.dx = 20; + drawText(ctx, node, borderWidth, ratio, dragZoom, padding); + + deepEqual(fillTextValues[0], undefined, + "Draw nothing when not enough room"); + deepEqual(fillTextValues[1], undefined, + "Drops off the byte and count information if not enough room"); +}); |