summaryrefslogtreecommitdiff
path: root/test/web-snapshots/touch.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'test/web-snapshots/touch.mjs')
-rw-r--r--test/web-snapshots/touch.mjs30
1 files changed, 18 insertions, 12 deletions
diff --git a/test/web-snapshots/touch.mjs b/test/web-snapshots/touch.mjs
index 69f8a4a5..6ced7a29 100644
--- a/test/web-snapshots/touch.mjs
+++ b/test/web-snapshots/touch.mjs
@@ -1,8 +1,9 @@
import assert from "node:assert/strict";
function tags(frame) {
- // This fixture has workspace and column bars in its first two rows.
- return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{3}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []);
+ // This fixture has workspace and column bars in its first two rows; a
+ // pane's tag text starts after the two-cell marker gutter.
+ return frame.styleRows.flatMap((cells, y) => y > 1 && /^\s{2}\S/.test(frame.lines[y]) && cells.some((cell) => cell[2] & 128) ? [y] : []);
}
function pane(frame, name) {
@@ -13,14 +14,17 @@ function pane(frame, name) {
return { top, bottom, lines: frame.lines.slice(top + 1, bottom) };
}
+// helix's keyword and string/number colours (src/themes/helix.zig).
+const KW = 0xd776f9, STR = 0xf3cd7a;
+
function styled(frame) {
const source = pane(frame, "touch-fixture.zig");
for (const [line, word, fg, bold] of [
- ["pub fn choose", "fn", 0xcf87e8, false],
+ ["pub fn choose", "fn", KW, false],
["pub fn choose", "choose", 0xbdbdbd, false],
- ["if (value", "if", 0xcf87e8, false],
- ["if (value", "42", 0xe3c78a, false],
- ["if (value", '"touch fixture"', 0xe3c78a, false],
+ ["if (value", "if", KW, false],
+ ["if (value", "42", STR, false],
+ ["if (value", '"touch fixture"', STR, false],
]) {
const row = source.lines.findIndex((text) => text.includes(line));
assert(row >= 0, `missing source line ${line}`);
@@ -35,7 +39,7 @@ function styled(frame) {
const number = /\b(\d+),/.exec(line);
if (!number) continue;
for (let x = number.index; x < number.index + number[1].length; x++) {
- assert.equal(frame.styleRows[source.top + 1 + row][x][0], 0xe3c78a, `row ${row} number foreground`);
+ assert.equal(frame.styleRows[source.top + 1 + row][x][0], STR, `row ${row} number foreground`);
}
}
}
@@ -79,7 +83,8 @@ export default async function ({ grid, touch, wait, stable, delay, evaluate, mou
renderer.render();
result.closedGapBorders=borders();
result.borderChangeInvalidates=renderer.layerRoot.firstChild!==withGap;
- const tagValues=[2,2,0,42,1,0,1,1,1,1,0x334455];
+ // The 13 fields of a tag layer: a one-line tag, its caret on line 0.
+ const tagValues=[2,2,0,42,1,0,1,1,1,1,0x334455,1,0];
wasm.pardes_tag_layer_limit=()=>1;
wasm.pardes_tag_layer_value=(_,field)=>tagValues[field];
wasm.pardes_tag_layer_cells=()=>1024;
@@ -187,14 +192,15 @@ export default async function ({ grid, touch, wait, stable, delay, evaluate, mou
assert.deepEqual(reflected.lines.slice(0, sharedRows), original.lines.slice(0, sharedRows), "Look must read the source pane body");
const center = Math.floor(frame.cols / 2);
- const separator = Math.max(original.top, reflected.top) - 1;
+ // No rule between panes: the lower one's grip, its tag's gutter, moves it.
+ const separator = Math.max(original.top, reflected.top);
const distance = original.top < reflected.top ? 4 : -4;
- finger = await touch("down", 2, center, separator, null);
+ finger = await touch("down", 2, 0, separator, null);
for (let step = 1; step <= 8; step++) {
- finger = await touch("move", 2, center, separator + distance * step / 8, finger);
+ finger = await touch("move", 2, 0, separator + distance * step / 8, finger);
await delay(20);
}
- await touch("up", 2, center, separator + distance, finger);
+ await touch("up", 2, 0, separator + distance, finger);
await stable(100, 5000);
frame = await grid();
assert.equal(tags(frame).length, 2);