diff options
Diffstat (limited to 'window-switcher/test_expose.js')
| -rw-r--r-- | window-switcher/test_expose.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/window-switcher/test_expose.js b/window-switcher/test_expose.js index d394253..e8ef459 100644 --- a/window-switcher/test_expose.js +++ b/window-switcher/test_expose.js @@ -18,7 +18,7 @@ const assert = require("assert"); const src = fs.readFileSync(__dirname + "/Expose.js", "utf8") .replace(/^\.pragma library$/m, ""); -const { layout } = new Function(src + "\nreturn { layout };")(); +const { layout, step } = new Function(src + "\nreturn { layout, step };")(); const W = 2560, H = 1080; const wide = { w: 2556, h: 1076 }, tall = { w: 1076, h: 1916 }; @@ -56,4 +56,15 @@ const [a, b] = layout([wide, tall], W, H); assert.ok(Math.abs(a.w / b.w - wide.w / tall.w) < 1e-9); assert.ok(Math.abs(a.h / b.h - wide.h / tall.h) < 1e-9); +// Arrow selection: a 2x2 grid, plus one far off to the upper right. +const g = [{ x: 0, y: 0, w: 10, h: 10 }, { x: 20, y: 0, w: 10, h: 10 }, + { x: 0, y: 20, w: 10, h: 10 }, { x: 20, y: 20, w: 10, h: 10 }, + { x: 100, y: -60, w: 10, h: 10 }]; +assert.strictEqual(step(g, -1, 1, 0), 0); // top-left first +assert.strictEqual(step(g, 0, 1, 0), 1); // level neighbour beats the far one +assert.strictEqual(step(g, 0, 0, 1), 2); +assert.strictEqual(step(g, 3, -1, 0), 2); +assert.strictEqual(step(g, 2, -1, 0), 2); // nothing to the left: stays +assert.strictEqual(step([], -1, 1, 0), -1); + console.log("test_expose: ok"); |
