feat(wasm-dom): tests for context menus + scrollbars; fix clean wx build

- Standalone wx test apps (contextmenu, scrollbar) + e2e specs proving the
  wxScrollBar control, the wxScrolledWindow gutter, and DoPopupMenu.
- KiCad in-app specs: pl_editor + pcbnew canvas right-click context menus and
  scrolled-panel scrollbar gutters, with baseline screenshots.
- build-wx-wasm.sh: serial -j1 fallback when the parallel build trips the
  intermittent clean-build race (a generated header read mid-rewrite by
  concurrent compiles; never happens at -j1). Recovery resumes from built
  objects; a genuine error still fails the serial pass.
- Bump wxwidgets submodule (context menus + draggable scrollbars).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-06-13 23:15:49 +02:00
commit 68430fa87c
19 changed files with 742 additions and 3 deletions

View file

@ -0,0 +1,94 @@
// Context-menu (DoPopupMenu) e2e — right-click pops a DOM popup, items route
// wxEVT_MENU back to the handler, and outside-click/Escape cancels.
import { test, expect, tryLoadApp, getCanvasBox } from './utils/fixtures';
import { findRenderedByType, clickMenuItem } from './utils/element-tracker';
async function rightClickCanvasCentre(page: import('@playwright/test').Page) {
const box = await getCanvasBox(page);
const x = Math.round(box.x + box.width / 2);
const y = Math.round(box.y + box.height / 2);
await page.mouse.click(x, y, { button: 'right' });
return { x, y };
}
async function popupItemCount(page: import('@playwright/test').Page): Promise<number> {
const items = await findRenderedByType(page, 'menuitem', { parentId: 'popupmenu' });
return items.length;
}
test.describe('DOM-port context menu', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/standalone/contextmenu/contextmenu_test.html');
expect(await tryLoadApp(page, 30000), 'context-menu app should load').toBe(true);
await expect
.poll(() => true, { timeout: 1000 })
.toBe(true);
});
test('right-click opens the menu with the expected items', async ({ page, testLogger }) => {
await rightClickCanvasCentre(page);
// The popup builds its rows + registers them in a requestAnimationFrame.
await expect.poll(() => popupItemCount(page), {
timeout: 8000,
message: 'context menu items should register',
}).toBeGreaterThanOrEqual(4); // Cut, Snap to grid, Paste, More (separators excluded)
const items = await findRenderedByType(page, 'menuitem', { parentId: 'popupmenu' });
const labels = items.map((i) => i.label);
expect(labels).toContain('Cut');
expect(labels).toContain('Snap to grid');
expect(labels).toContain('More');
// The disabled "Paste" item registers but is not enabled.
const paste = items.find((i) => i.label === 'Paste');
expect(paste, 'Paste should be present').toBeTruthy();
expect(paste!.enabled, 'Paste should be disabled').toBe(false);
await page.screenshot({ path: 'test-results/contextmenu-01-open.png', fullPage: true });
expect(testLogger.errors.filter((e) => !e.includes('favicon'))).toHaveLength(0);
});
test('choosing an item routes wxEVT_MENU to the handler', async ({ page, testLogger }) => {
await rightClickCanvasCentre(page);
await expect.poll(() => popupItemCount(page), { timeout: 8000 }).toBeGreaterThanOrEqual(4);
expect(await clickMenuItem(page, 'Cut'), 'Cut should be clickable').toBe(true);
await expect.poll(
() => testLogger.consoleLogs.some((l) => l.includes('[CTXMENU_EVENT] Cut chosen')),
{ timeout: 8000, message: 'the Cut handler should fire' },
).toBe(true);
// The popup is dismissed after a choice.
await expect.poll(() => popupItemCount(page), { timeout: 4000 }).toBe(0);
});
test('a checkable item toggles and reports its new state', async ({ page, testLogger }) => {
await rightClickCanvasCentre(page);
await expect.poll(() => popupItemCount(page), { timeout: 8000 }).toBeGreaterThanOrEqual(4);
expect(await clickMenuItem(page, 'Snap to grid')).toBe(true);
await expect.poll(
() => testLogger.consoleLogs.some((l) => l.includes('[CTXMENU_EVENT] Snap to grid ON')),
{ timeout: 8000, message: 'the check item should toggle ON' },
).toBe(true);
});
test('Escape cancels without firing a command', async ({ page, testLogger }) => {
await rightClickCanvasCentre(page);
await expect.poll(() => popupItemCount(page), { timeout: 8000 }).toBeGreaterThanOrEqual(4);
const before = testLogger.consoleLogs.filter((l) => l.includes('chosen')).length;
await page.keyboard.press('Escape');
await expect.poll(() => popupItemCount(page), {
timeout: 4000,
message: 'Escape should dismiss the popup',
}).toBe(0);
const after = testLogger.consoleLogs.filter((l) => l.includes('chosen')).length;
expect(after, 'no command should fire on cancel').toBe(before);
});
});

View file

@ -0,0 +1,63 @@
// Draggable scrollbar e2e — the DOM scrollbar widget reports drags back to
// C++ (wxEVT_SCROLL for the standalone wxScrollBar; wxEVT_SCROLLWIN for the
// wxScrolledWindow gutter, which scrolls the content). The thumb registers as
// 'slider' + 'slidertrack' so Playwright can drag it.
import { test, expect, tryLoadApp } from './utils/fixtures';
import { findRenderedByType } from './utils/element-tracker';
test.describe('DOM-port scrollbars', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/standalone/scrollbar/scrollbar_test.html');
expect(await tryLoadApp(page, 30000), 'scrollbar app should load').toBe(true);
await page.waitForTimeout(500);
});
test('scrollbars render draggable thumbs', async ({ page, testLogger }) => {
await expect.poll(
async () => (await findRenderedByType(page, 'slider')).length,
{ timeout: 8000, message: 'scrollbar thumbs should register' },
).toBeGreaterThanOrEqual(2);
await page.screenshot({ path: 'test-results/scrollbar-01-loaded.png', fullPage: true });
expect(testLogger.errors.filter((e) => !e.includes('favicon'))).toHaveLength(0);
});
test('dragging a thumb scrolls (standalone control fires wxEVT_SCROLL)', async ({
page,
testLogger,
}) => {
await expect.poll(
async () => (await findRenderedByType(page, 'slider')).length,
{ timeout: 8000 },
).toBeGreaterThanOrEqual(2);
const sliders = await findRenderedByType(page, 'slider');
const tracks = await findRenderedByType(page, 'slidertrack');
// Drag every thumb toward the far end of its track. The standalone
// scrollbars log "[SCROLLBAR_EVENT] scrollbar pos N"; the scrolled-window
// gutters scroll the content (captured in the screenshot).
for (let i = 0; i < sliders.length; i++) {
const s = sliders[i];
const t = tracks.find((tr) => tr.parentId === s.parentId) ?? tracks[i];
if (!t) continue;
const horizontal = t.width > t.height;
const tx = horizontal ? t.screenX + t.width * 0.85 : t.centerX;
const ty = horizontal ? t.centerY : t.screenY + t.height * 0.85;
await page.mouse.move(s.centerX, s.centerY);
await page.mouse.down();
await page.mouse.move(tx, ty, { steps: 6 });
await page.mouse.up();
await page.waitForTimeout(150);
}
await page.screenshot({ path: 'test-results/scrollbar-02-dragged.png', fullPage: true });
// At least one standalone scrollbar must have reported a non-zero position.
await expect.poll(
() => testLogger.consoleLogs.some((l) => /\[SCROLLBAR_EVENT\] scrollbar pos [1-9]/.test(l)),
{ timeout: 8000, message: 'a standalone scrollbar drag should report a non-zero position' },
).toBe(true);
});
});