import QtQuick import QtTest import Quickshell.Io import "../core" // Test hooks for the dashboard: screenshots, named clicks and key presses. Item { id: root parent: ShellState.dashboardWindow ? ShellState.dashboardWindow.contentItem : null TestCase { id: input name: "DashboardDriver" when: false } function find(name) { return ShellState.dashboardWindow ? input.findChild(ShellState.dashboardWindow.contentItem, name) : null; } IpcHandler { target: "dashboardTest" function screenshot(path: string): bool { const surface = root.find("dashboardSurface"); return !!surface && surface.grabToImage(result => result.saveToFile(path)); } function click(name: string): bool { const item = root.find(name); if (!item || !item.visible) return false; input.mouseClick(item, item.width / 2, item.height / 2); return true; } function key(key: int): void { input.keyClick(key); } function outside(): void { input.mouseClick(ShellState.dashboardWindow.contentItem, -40, -40); } function settingsClick(name: string): bool { const item = ShellState.settingsWindow ? input.findChild(ShellState.settingsWindow.contentItem, name) : null; if (!item || !item.visible || !item.enabled) return false; // Scroll the settings page so the control is under the pointer. for (let p = item.parent; p; p = p.parent) if (p.contentY !== undefined && p.contentItem && p.contentHeight > p.height) p.contentY = Math.max(0, Math.min(p.contentHeight - p.height, item.mapToItem(p.contentItem, 0, 0).y - p.height / 2)); input.wait(60); input.mouseClick(item, item.width / 2, item.height / 2); return true; } function settingsScreenshot(path: string): bool { return !!ShellState.settingsWindow && input.findChild(ShellState.settingsWindow.contentItem, "settingsPageLoader").grabToImage(result => result.saveToFile(path)); } } }