tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_tree-map-01.js (1872B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const {
      7  drawBox,
      8 } = require("resource://devtools/client/memory/components/tree-map/draw.js");
      9 
     10 add_task(async function () {
     11  let fillRectValues, strokeRectValues;
     12  const ctx = {
     13    fillRect: (...args) => {
     14      fillRectValues = args;
     15    },
     16    strokeRect: (...args) => {
     17      strokeRectValues = args;
     18    },
     19  };
     20  const node = {
     21    x: 20,
     22    y: 30,
     23    dx: 50,
     24    dy: 70,
     25    type: "other",
     26    depth: 2,
     27  };
     28  const padding = [10, 10];
     29  const borderWidth = () => 1;
     30  const dragZoom = {
     31    offsetX: 0,
     32    offsetY: 0,
     33    zoom: 0,
     34  };
     35  drawBox(ctx, node, borderWidth, dragZoom, padding);
     36  ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues]));
     37  equal(ctx.fillStyle, "hsl(204,60%,70%)", "The fillStyle is set");
     38  equal(ctx.strokeStyle, "hsl(204,60%,35%)", "The strokeStyle is set");
     39  equal(ctx.lineWidth, 1, "The lineWidth is set");
     40  deepEqual(fillRectValues, [10.5, 20.5, 49, 69], "Draws a filled rectangle");
     41  deepEqual(
     42    strokeRectValues,
     43    [10.5, 20.5, 49, 69],
     44    "Draws a stroked rectangle"
     45  );
     46 
     47  dragZoom.zoom = 0.5;
     48 
     49  drawBox(ctx, node, borderWidth, dragZoom, padding);
     50  ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues]));
     51  deepEqual(
     52    fillRectValues,
     53    [15.5, 30.5, 74, 104],
     54    "Draws a zoomed filled rectangle"
     55  );
     56  deepEqual(
     57    strokeRectValues,
     58    [15.5, 30.5, 74, 104],
     59    "Draws a zoomed stroked rectangle"
     60  );
     61 
     62  dragZoom.offsetX = 110;
     63  dragZoom.offsetY = 130;
     64 
     65  drawBox(ctx, node, borderWidth, dragZoom, padding);
     66  deepEqual(
     67    fillRectValues,
     68    [-94.5, -99.5, 74, 104],
     69    "Draws a zoomed and offset filled rectangle"
     70  );
     71  deepEqual(
     72    strokeRectValues,
     73    [-94.5, -99.5, 74, 104],
     74    "Draws a zoomed and offset stroked rectangle"
     75  );
     76 });