Add image buttons and exclusive launcher actions
This commit is contained in:
1 parent
8d604a5807
commit
74c725e8d7
23 files changed
+871
-107
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { runInNewContext } from "node:vm";
|
||||
import { alignmentGuide, arrangeIconRow, builtInLayout, deviceMapper, normalizeLayout, resizedIconBounds, validate } from "./src/layout.ts";
|
||||
import { alignmentGuide, arrangeIconRow, builtInLayout, deviceMapper, itemLaunchMode, normalizeLayout, resizedIconBounds, validate } from "./src/layout.ts";
|
||||
|
||||
const fixtures = JSON.parse(readFileSync(new URL("../docs/layout-cases.json", import.meta.url), "utf8"));
|
||||
const offline = readFileSync(new URL("./canvas.html", import.meta.url), "utf8");
|
||||
@@ -83,3 +83,24 @@ assert.deepEqual(resizedIconBounds(icon, icon.w + 16, icon.h + 20, canvas),
|
||||
assert.deepEqual(resizedIconBounds({ ...icon, x: 0, y: 0 }, 200, 220, canvas),
|
||||
{ x: 0, y: 0, w: 200, h: 220 });
|
||||
console.log("Icon resize centering and canvas bounds passed");
|
||||
|
||||
const settingsButton = normalizeLayout({ pages: [{ items: [{
|
||||
id: "wifi", type: "image", x: 0, y: 200, w: 100, h: 100,
|
||||
payload: { imageId: "a".repeat(64), settingsAction: "ACTION_WIFI_SETTINGS",
|
||||
extras: [{ key: "example", type: "long", value: "9223372036854775807" }] },
|
||||
}] }] });
|
||||
assert.equal(validate(settingsButton).filter(issue => issue.level === "error").length, 0);
|
||||
settingsButton.pages[0].items[0].payload.extras[0].value = "9223372036854775808";
|
||||
assert.ok(validate(settingsButton).some(issue => issue.level === "error" && issue.message.includes("Intent")));
|
||||
console.log("Settings actions and typed extras passed");
|
||||
|
||||
const picture = settingsButton.pages[0].items[0];
|
||||
picture.payload.extras = [];
|
||||
assert.equal(itemLaunchMode(picture), "settings");
|
||||
picture.payload.launchMode = "component";
|
||||
picture.payload.componentName = "com.example.app/.MainActivity";
|
||||
assert.equal(itemLaunchMode(picture), "component");
|
||||
assert.ok(!validate(settingsButton).some(issue => issue.level === "error"));
|
||||
picture.payload.componentName = "com.example.app";
|
||||
assert.ok(validate(settingsButton).some(issue => issue.message.includes("ComponentName")));
|
||||
console.log("Exclusive action mode and ComponentName validation passed");
|
||||
Reference in new issue
Block a user