EvenHub compativility fixes: Z-order changes, different text color distribution, text containers scroll

This commit is contained in:
James Babcock committed 2026-11-07 22:28:49 -08:00
1 parent c713815694
commit 10a9c85f27
22 files changed
+1545 -610

No files matched your search

+47 -106
View File
@@ -1,18 +1,10 @@
// The EvenHub layout debug log: the stock container-order rules it compares
// our paint order against (from the evenRealities-openCFW reconstruction of
// evenhub_ui_containers.c), and the stock notes it attaches to updates.
// The EvenHub layout debug log (app/apps/evenhub/layout-debug.ts): page notes
// and the per-update lines it writes to logcat.
const test = require("node:test");
const assert = require("node:assert/strict");
const { parsePage, paintOrder } = require("../.test-build/app/apps/evenhub/containers.js");
const {
describeImageUpdate,
describePage,
stockDifferences,
stockPaintOrder,
} = require("../.test-build/app/apps/evenhub/layout-debug.js");
const names = (containers) => containers.map((c) => c.name);
const { parsePage } = require("../.test-build/app/apps/evenhub/containers.js");
const { describeImageUpdate, describePage, pageNotes } = require("../.test-build/app/apps/evenhub/layout-debug.js");
const iconOverBody = (extra = {}) =>
parsePage({
@@ -21,102 +13,51 @@ const iconOverBody = (extra = {}) =>
imageObject: [{ containerID: 2, containerName: "icon", xPosition: 8, yPosition: 8, width: 24, height: 24, ...extra.image }],
});
test("without zOrderIndex, stock orders lists, then texts, then images", () => {
const page = parsePage({
imageObject: [{ containerID: 1, containerName: "img" }],
textObject: [{ containerID: 2, containerName: "txt" }],
listObject: [{ containerID: 3, containerName: "lst" }],
});
assert.deepEqual(names(stockPaintOrder(page.containers)), ["lst", "txt", "img"]);
// ...where we put images at the bottom.
assert.deepEqual(names(paintOrder(page.containers)), ["img", "lst", "txt"]);
});
test("stock sorts by zOrderIndex only when every container has one", () => {
const all = iconOverBody({ text: { zOrderIndex: 2 }, image: { zOrderIndex: 1 } });
assert.deepEqual(names(stockPaintOrder(all.containers)), ["icon", "body"]);
assert.deepEqual(names(paintOrder(all.containers)), ["icon", "body"]);
const some = iconOverBody({ text: { zOrderIndex: 2 } });
assert.deepEqual(names(stockPaintOrder(some.containers)), ["body", "icon"]);
assert.deepEqual(names(paintOrder(some.containers)), ["icon", "body"]);
assert.ok(stockDifferences(some).some((note) => note.includes("zOrderIndex is set on 1 of 2")));
});
test("an image overlapping text is flagged when the two orders disagree", () => {
const notes = stockDifferences(iconOverBody());
assert.ok(notes.some((note) => note.startsWith("paint order differs")));
assert.ok(notes.includes('image#2 "icon" overlaps text#1 "body": we draw text#1 "body" on top, stock draws image#2 "icon" on top'));
});
test("non-overlapping containers in a different order raise no overlap note", () => {
const notes = stockDifferences(iconOverBody({ text: { yPosition: 100, height: 100 } }));
assert.ok(!notes.some((note) => note.includes("overlaps")));
});
test("image containers outside stock's size limits are flagged", () => {
const notes = stockDifferences(iconOverBody({ image: { width: 16, height: 16 } }));
assert.ok(notes.some((note) => note.includes("16x16") && note.includes("fails the whole page")));
});
test("a shared container id resolves to the first container in stock order", () => {
const page = iconOverBody({ image: { containerID: 1 } });
assert.ok(stockDifferences(page).includes('id 1 is shared by text#1 "body", image#1 "icon"; stock resolves it to text#1 "body" only'));
const lines = describeImageUpdate({
page,
sentId: 1,
sentName: "",
container: page.containers.find((c) => c.kind === "image"),
raw: [],
bytes: null,
decoded: null,
result: 1,
});
assert.ok(lines.some((line) => line.includes("stock drops this update")));
});
test("image updates note base64 payloads, size mismatches and blank images", () => {
const page = iconOverBody();
const icon = page.containers.find((c) => c.kind === "image");
const lines = describeImageUpdate({
page,
sentId: 2,
sentName: "icon",
container: icon,
raw: "AAAA",
bytes: new Uint8Array(3),
decoded: { pixels: new Uint8Array(4), width: 2, height: 2 },
result: 0,
});
assert.match(lines[0], /payload=string\(4 chars\)/);
assert.match(lines[0], /decoded=2x2 blank/);
assert.ok(lines.some((line) => line.includes("base64-string")));
assert.ok(lines.some((line) => line.includes("exactly the container's size (24x24)")));
});
test("lit pixels are summarized with a bounding box", () => {
const page = iconOverBody();
const icon = page.containers.find((c) => c.kind === "image");
const pixels = new Uint8Array(24 * 24);
pixels[24 * 3 + 5] = 200;
pixels[24 * 10 + 7] = 255;
const [first] = describeImageUpdate({
page,
sentId: 2,
sentName: "",
container: icon,
raw: Array.from(pixels),
bytes: pixels,
decoded: { pixels, width: 24, height: 24 },
result: 0,
});
assert.match(first, /format=raw8 decoded=24x24 lit=2px max=255 bbox=5,3-7,10 result=0$/);
});
test("describePage lists containers bottom to top and ends with the raw payload", () => {
const lines = describePage("rebuildPageContainer", iconOverBody(), { containerTotalNum: 2 });
assert.match(lines[0], /^rebuildPageContainer: 2 containers \(0 list, 1 text, 1 image\), containerTotalNum=2/);
assert.match(lines[1], /^ {2}0: image#2 "icon" @8,8 24x24 no pixels yet$/);
assert.match(lines[2], /^ {2}1: text#1 "body" @0,0 576x288 capture len=0 ""$/);
assert.match(lines[1], /^ {2}0: text#1 "body" @0,0 576x288 capture len=0 ""$/);
assert.match(lines[2], /^ {2}1: image#2 "icon" @8,8 24x24 no pixels yet$/);
assert.equal(lines.at(-1), ' raw: {"containerTotalNum":2}');
});
test("a shared container id is noted with the container it resolves to", () => {
assert.ok(pageNotes(iconOverBody({ image: { containerID: 1 } })).includes(
'id 1 is shared by text#1 "body", image#1 "icon"; updates and events resolve to text#1 "body" only',
));
});
test("capture-container problems and a wrong containerTotalNum are noted", () => {
assert.ok(pageNotes(iconOverBody({ text: { isEventCapture: 0 } })).some((n) => n.startsWith("no event-capture container")));
assert.ok(pageNotes(iconOverBody(), 3).some((n) => n.startsWith("containerTotalNum is 3 but 2")));
assert.deepEqual(pageNotes(iconOverBody(), 2), []);
});
const prepared = (over = {}) => ({ result: 0, levels: null, width: 0, height: 0, format: "raw", reason: "", ...over });
test("an update lists payload, size, lit pixels and outcome", () => {
const page = iconOverBody();
const levels = new Uint8Array(24 * 24);
levels[24 * 3 + 5] = 9;
levels[24 * 10 + 7] = 15;
const [line] = describeImageUpdate({
sentId: 2, sentName: "icon", raw: Array.from(levels), target: page.containers[1],
prepared: prepared({ levels, width: 24, height: 24 }), shown: true, result: 0,
});
assert.equal(line, 'updateImageRawData id=2 "icon" -> image#2 "icon" payload=number[576] format=raw 24x24 lit=2px max=15/15 bbox=5,3-7,10 result=0 shown');
});
test("an update says why it wasn't shown", () => {
const page = iconOverBody({ image: { containerID: 1 } });
const toText = describeImageUpdate({
sentId: 1, sentName: "", raw: [], target: page.containers[0],
prepared: prepared({ levels: new Uint8Array(1), width: 1, height: 1 }), shown: false, result: 4,
});
assert.ok(toText.some((line) => line.includes('resolves to text#1 "body", so the glasses refuse')));
const failed = describeImageUpdate({
sentId: 2, sentName: "", raw: "AAAA", target: undefined,
prepared: prepared({ result: 4, format: null, reason: "imageData is not an array of integers" }), shown: false, result: 4,
});
assert.match(failed[0], /payload=string\(4 chars\) result=4 not shown$/);
assert.equal(failed[1], " imageData is not an array of integers");
});