Fix widget resizing handles, edge anchoring, scroll sync, and axis limits
This commit is contained in:
1 parent
216c80252d
commit
bb978fd6de
13 files changed
+538
-76
No files matched your search
+99
-3
@@ -29,6 +29,7 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
await p.addInitScript((release) => {
|
||||
window.__calls = [];
|
||||
window.__recentsEnabled = true;
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true };
|
||||
const rec = (n) => (...a) => { window.__calls.push([n, ...a]); };
|
||||
const disc = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><circle cx='4' cy='4' r='4' fill='red'/></svg>");
|
||||
window.Android = {
|
||||
@@ -36,7 +37,7 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
addWidget: (prov) => { rec("addWidget")(prov); setTimeout(() => window.launcher.widgetAdded(77), 0); },
|
||||
removeWidget: rec("removeWidget"), placeWidgets: rec("placeWidgets"), coverWidgets: rec("coverWidgets"),
|
||||
excludeGestures: rec("excludeGestures"),
|
||||
widgetLimits: () => JSON.stringify({ w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }),
|
||||
widgetLimits: () => JSON.stringify(window.__widgetLimits),
|
||||
loadIcons: (json) => { rec("loadIcons")(json); const o = {}; for (const k of JSON.parse(json)) o[k] = disc; setTimeout(() => window.launcher.icons(o), 0); },
|
||||
haptic: rec("haptic"), showKeyboard: rec("showKeyboard"), hideKeyboard: rec("hideKeyboard"),
|
||||
openSettings: rec("openSettings"), pickWallpaper: rec("pickWallpaper"),
|
||||
@@ -150,13 +151,108 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
||||
// and the shell is told to keep its edge swipes off them
|
||||
await p.evaluate(() => { window.launcher.widgetMenu(77); window.launcher.widgetDrop(false); }); await settle();
|
||||
assert.ok(await p.$(".widget-slot.resizing .resize-handle"), "handles");
|
||||
assert.ok(JSON.parse((await calls("excludeGestures")).pop()[1]).length === 3, "three handles excluded from system gestures");
|
||||
assert.equal(await p.textContent(".resize-size"), "2 × 2");
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 5, "five handles excluded from system gestures");
|
||||
assert.equal(JSON.parse((await calls("placeWidgets")).pop()[1])[0][5], 1, "the shell is told which widget is being edited");
|
||||
// dragging it from the native view moves it to a cell (widgetDrag reports page px)
|
||||
await p.evaluate(() => { window.launcher.widgetGrab(77); window.launcher.widgetDrag(200, 300); window.launcher.widgetDrag(200, 420); window.launcher.widgetDrop(true); });
|
||||
const tileBox = await p.locator(".slots .tile").first().boundingBox();
|
||||
const pitchX = Math.round(tileBox.width + 8);
|
||||
const pitchY = Math.round(tileBox.height + 8);
|
||||
await p.evaluate(([dx, dy]) => {
|
||||
window.launcher.widgetGrab(77);
|
||||
window.launcher.widgetDrag(150, 200);
|
||||
window.launcher.widgetDrag(150 + dx, 200 + dy);
|
||||
window.launcher.widgetDrop(true);
|
||||
}, [pitchX, 2 * pitchY]);
|
||||
await settle();
|
||||
const moved = await p.$eval(".widget-slot", (s) => s.style.gridRow);
|
||||
assert.ok(!moved.startsWith("1 "), `moved off the first row: ${moved}`);
|
||||
|
||||
// Left and Top resize handles grow without shifting the anchored right/bottom edges
|
||||
const b0 = await p.locator(".widget-slot").boundingBox();
|
||||
const hl = await p.locator(".resize-handle[data-edge=l]").boundingBox();
|
||||
await p.mouse.move(hl.x + hl.width / 2, hl.y + hl.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(hl.x + hl.width / 2 - pitchX, hl.y + hl.height / 2, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const b1 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((b0.x + b0.width) - (b1.x + b1.width)) < 2, "left resize keeps right edge anchored");
|
||||
assert.ok(Math.abs((b1.width - b0.width) - pitchX) < 3, `left resize grew by 1 col: ${b1.width - b0.width}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "3 × 2");
|
||||
|
||||
const ht = await p.locator(".resize-handle[data-edge=t]").boundingBox();
|
||||
await p.mouse.move(ht.x + ht.width / 2, ht.y + ht.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(ht.x + ht.width / 2, ht.y + ht.height / 2 - pitchY, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const b2 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((b1.y + b1.height) - (b2.y + b2.height)) < 2, "top resize keeps bottom edge anchored");
|
||||
assert.ok(Math.abs((b2.height - b1.height) - pitchY) < 3, `top resize grew by 1 row: ${b2.height - b1.height}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "3 × 3");
|
||||
|
||||
// holding a resize handle >= 500ms does not lift widget or corrupt resize state
|
||||
const hr = await p.locator(".resize-handle[data-edge=r]").boundingBox();
|
||||
await p.mouse.move(hr.x + hr.width / 2, hr.y + hr.height / 2);
|
||||
await p.mouse.down(); await p.waitForTimeout(600);
|
||||
await p.mouse.move(hr.x + hr.width / 2 + pitchX, hr.y + hr.height / 2, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
assert.ok(await p.$(".widget-slot.resizing"), "still resizing after 600ms hold");
|
||||
assert.ok(!(await p.$(".widget-slot.lifted")), "not lifted after holding handle");
|
||||
assert.ok(!(await p.$(".sheet")), "no sheet opened after holding handle");
|
||||
assert.equal(await p.textContent(".resize-size"), "4 × 3");
|
||||
|
||||
// scrolled resize: ensure page scrolls, scroll down, then resize bottom by +1 row
|
||||
await p.evaluate(() => {
|
||||
document.querySelector(".home").style.minHeight = "1200px";
|
||||
window.scrollTo(0, 120);
|
||||
});
|
||||
await settle();
|
||||
assert.ok((await p.evaluate(() => window.scrollY)) > 50, "page scrolled for scrolled resize test");
|
||||
const bs0 = await p.locator(".widget-slot").boundingBox();
|
||||
const hb = await p.locator(".resize-handle[data-edge=b]").boundingBox();
|
||||
await p.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2);
|
||||
await p.mouse.down();
|
||||
await p.mouse.move(hb.x + hb.width / 2, hb.y + hb.height / 2 + pitchY, { steps: 6 }); await settle();
|
||||
await p.mouse.up(); await settle();
|
||||
const bs1 = await p.locator(".widget-slot").boundingBox();
|
||||
assert.ok(Math.abs((bs1.height - bs0.height) - pitchY) < 3, `scrolled bottom resize grew by 1 row: ${bs1.height - bs0.height}`);
|
||||
assert.equal(await p.textContent(".resize-size"), "4 × 4");
|
||||
await p.evaluate(() => {
|
||||
document.querySelector(".home").style.minHeight = "";
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
await settle();
|
||||
|
||||
// axis-conditional handles: h-only, v-only, and non-resizable
|
||||
const edges = () => p.$$eval(".resize-handle", (hs) => hs.map((h) => h.dataset.edge));
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: false };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), ["l", "r"]);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 2);
|
||||
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: false, v: true };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), ["t", "b"]);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 2);
|
||||
|
||||
await p.click(".resize-bar >> text=Done"); await settle();
|
||||
await p.evaluate(() => {
|
||||
window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: false, v: false };
|
||||
window.launcher.widgetMenu(77); window.launcher.widgetDrop(false);
|
||||
});
|
||||
await settle();
|
||||
assert.deepEqual(await edges(), []);
|
||||
assert.equal(JSON.parse((await calls("excludeGestures")).pop()[1]).length, 0);
|
||||
await p.evaluate(() => { window.__widgetLimits = { w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }; });
|
||||
|
||||
await p.click(".resize-bar >> text=Remove"); await settle();
|
||||
assert.equal((await calls("removeWidget"))[0][1], 77);
|
||||
|
||||
|
||||
Reference in new issue
Block a user