Files
glassMxrph/quickshell/testing/SettingsDriver.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

191 lines
8.9 KiB
QML

import QtQuick
import QtTest
import Quickshell.Io
import "../core"
import "../services"
import "../theme"
import "../widgets"
import "../lock"
Item {
id: root
property var lastDrag: ({})
parent: ShellState.settingsWindow ? ShellState.settingsWindow.contentItem : null
TestCase {
id: input
name: "SettingsInputDriver"
when: false
}
function child(name) {
return input.findChild(ShellState.settingsWindow.contentItem, name);
}
function reveal(item) {
let parent = item.parent;
while (parent) {
if (parent.contentY !== undefined && parent.contentItem && parent.contentHeight > parent.height) {
const position = item.mapToItem(parent.contentItem, 0, 0);
parent.contentY = Math.max(0, Math.min(parent.contentHeight - parent.height, position.y - parent.height / 2));
}
parent = parent.parent;
}
input.wait(40);
}
IpcHandler {
target: "settingsTest"
function snapshot(): string {
return JSON.stringify({
lastDrag:root.lastDrag,
picker:ShellState.wallpaperPickerOpen,
pickerScreen:ShellState.wallpaperWindow.screen.name,
glass:GlassService.state,glassError:GlassService.error,glassBusy:GlassService.busy,
page: ShellState.settingsPage,
data: ConfigService.data,
palette: MatugenService.accent.toString(),
theme: Theme.accent.toString(),
busy: MatugenService.busy,
error: MatugenService.error,
wallpaper: WallpaperService.currentPath,
images: WallpaperService.images,
backend: WallpaperService.backend
});
}
function color(): bool {
const item = root.child("colorSaturationValue");
if (!item)
return false;
input.mouseClick(item, item.width * .65, item.height * .35);
return true;
}
function click(name: string): bool {
const item = root.child(name);
if (!item)
return false;
root.reveal(item);
input.mouseClick(item, item.width / 2, item.height / 2);
return true;
}
function dragModule(id: string, lane: string, before: string): bool {
const source=root.child("bar-drag-"+id);
const target=root.child(before ? "bar-drag-"+before : "bar-lane-"+lane);
if(!source || !target)return false;
root.reveal(source);
const end=source.mapFromItem(target,target.width/2,before ? 2 : target.height-10);
input.mousePress(source,source.width/2,source.height/2);
input.mouseMove(source,source.width/2+12,source.height/2,40);
input.mouseMove(source,end.x,end.y,80);
input.wait(80);
const editor=root.child("barEditor");root.lastDrag={id:id,lane:editor.targetLane,before:editor.beforeId,dragging:editor.dragging,x:end.x,y:end.y};
input.mouseRelease(source,end.x,end.y);
input.wait(80);
return true;
}
function wallpaper(index: int): bool {
const grid = root.child("wallpaperGrid");
grid.positionViewAtIndex(index, GridView.Contain);
const item = grid.itemAtIndex(index);
if (!item)
return false;
root.reveal(item);
input.mouseClick(item, item.width / 2, item.height / 2);
return true;
}
function search(text: string): int {
ShellState.settingsWindow.openSearch();
root.child("settingsSearch").text = text;
return ShellState.settingsWindow.searchResults.length;
}
function dragPanel(dx: int, dy: int): string {
const win = ShellState.settingsWindow;
const handle = root.child("settingsDragHandle");
const start = {x: win.panelX, y: win.panelY};
const p = handle.mapToItem(null, handle.width / 4, handle.height / 2);
input.mousePress(win.contentItem, p.x, p.y);
for (let i = 0; i < 40 && !win.spanning; i++)
input.wait(25);
const spanned = win.spanning;
input.mouseMove(win.contentItem, start.x + p.x + dx, start.y + p.y + dy, 30);
input.mouseRelease(win.contentItem, start.x + p.x + dx, start.y + p.y + dy);
for (let i = 0; i < 40 && win.spanning; i++)
input.wait(25);
return JSON.stringify({start: start, end: {x: win.panelX, y: win.panelY}, spanned: spanned, spanningAfter: win.spanning, width: win.width, height: win.height});
}
function searchChoose(index: int): bool {
const result = ShellState.settingsWindow.searchResults[index];
ShellState.settingsWindow.chooseResult(result);
return !!result;
}
function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;}
function pickerSelect(index: int): bool {
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperCarousel");
view.positionViewAtIndex(index,ListView.Contain);input.wait(50);
const item=view.itemAtIndex(index);if(!item)return false;
input.mouseClick(item,item.width/2,item.height/2);input.keyClick(Qt.Key_Return);return true;
}
function pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));}
function geometry(name: string): string {
const item = root.child(name);
if (!item)
return "{}";
const p = item.mapToItem(null, 0, 0);
const parentWidth = item.parent ? item.parent.width : -1;
const chain = [];
for (let node = item.parent, i = 0; node && i < 12; node = node.parent, i++)
chain.push(String(node).split("(")[0] + ":" + Math.round(node.width) + "@" + Math.round(node.mapToItem(null, 0, 0).x));
return JSON.stringify({x: p.x, width: item.width, scale: item.scale, visualWidth: item.width * item.scale, parentWidth: parentWidth, chain: chain});
}
function widgetScreenshot(id: string, path: string): bool {
const surface = WidgetState.surfaces[id];
return !!surface && surface.grabToImage(result => result.saveToFile(path));
}
function lockScreenshot(index: int, path: string): bool {
const surface = LockState.surfaces[index];
return !!surface && surface.grabToImage(result => result.saveToFile(path));
}
function lockSubmit(text: string): bool {
return LockState.submit(text, LockState.previewing ? "preview" : "test");
}
function lockTest(text: string): bool {
return LockState.test(text);
}
function widgetEdit(id: string): void {
WidgetState.edit(id);
}
function widgetDrag(id: string, dx: int, dy: int): string {
for (const editor of WidgetState.editors) {
const frame = input.findChild(editor, "widgetMove-" + id);
if (!frame)
continue;
// Coordinates relative to the (static) editor; the frame moves while dragging.
const p = frame.mapToItem(editor, 20, 20);
input.mousePress(editor, p.x, p.y);
input.mouseMove(editor, p.x + dx / 2, p.y + dy / 2, 30);
input.mouseMove(editor, p.x + dx, p.y + dy, 30);
input.mouseRelease(editor, p.x + dx, p.y + dy);
input.wait(400);
return JSON.stringify(WidgetState.item(id));
}
return "{}";
}
function editorScreenshot(index: int, path: string): bool {
const editor = WidgetState.editors[index];
return !!editor && editor.grabToImage(result => result.saveToFile(path));
}
function barScreenshot(path: string): bool {
return barScreenshotAt(0, path);
}
function barScreenshotAt(index: int, path: string): bool {
const pill = ShellState.systemPills[index];
// Pill → Loader → ModuleRow → bar surface.
const surface = pill ? pill.parent.parent.parent : null;
return !!surface && surface.grabToImage(result => result.saveToFile(path));
}
function osdScreenshot(path: string): bool {
const surface = input.findChild(ShellState.osdWindow.contentItem, "osdSurface");
return !!surface && surface.grabToImage(result => result.saveToFile(path));
}
function screenshot(path: string): bool {
return root.child("settingsSurface").grabToImage(result => result.saveToFile(path));
}
}
}