Files
glassMxrph/quickshell/testing/LauncherDriver.qml
T
mxandClaude Opus 5.5 5a10469efe Add Clipboard History as a launcher mode backed by cliphist
The launcher gains a clipboard mode with the same bar, position and size:
the latest five entries show at once and the rest scroll, search filters
in recency order, Enter copies, Shift+Delete removes an entry. >clipboard
switches in place without closing or animating; glassmxrph clipboard
toggles it directly. History stays with the user's cliphist watcher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 15:16:14 +02:00

110 lines
3.9 KiB
QML

import QtQuick
import QtTest
import Quickshell.Io
import "../launcher"
import "../core"
import "../theme"
Item {
id: root
parent: LauncherState.window ? LauncherState.window.contentItem : null
function search() {
return input.findChild(LauncherState.window.contentItem, "launcherSearch");
}
TestCase {
id: input
name: "LauncherInputDriver"
when: false
}
// The panel grows to fit results; wait for it to settle before pointing.
function settle(): void {
const panel = input.findChild(LauncherState.window.contentItem, "launcherSurface");
let last = -1;
for (let i = 0; i < 40 && panel.height !== last; i++) {
last = panel.height;
input.wait(Math.max(50, Theme.duration / 2));
}
}
IpcHandler {
target: "launcherTest"
function query(text: string): void {
const field = root.search();
field.text = text;
field.forceActiveFocus();
}
function key(key: int): void {
input.keyClick(key);
}
function typeAscii(text: string): void {
for (let i = 0; i < text.length; i++)
input.keyClick(text.charAt(i).toUpperCase().charCodeAt(0));
}
function snapshot(): string {
const w = LauncherState.window, panel = input.findChild(w.contentItem, "launcherSurface");
return JSON.stringify({
activeMonitor: ScreenService.active ? ScreenService.active.name : "",
opened: ShellState.launcherOpen,
mode: ShellState.launcherMode,
screen: w.screen.name,
screenWidth: w.width,
screenHeight: w.height,
x: panel.x,
y: panel.y,
width: panel.width,
height: panel.height,
visible: w.visible,
query: root.search().text,
focused: root.search().activeFocus,
selected: w.selectedIndex,
results: w.results.map(r => ({
id: r.id,
title: r.title,
command: !!r.command,
image: !!(r.clip && r.clip.image)
})),
error: w.launchError
});
}
function click(index: int): bool {
root.settle();
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
list.positionViewAtIndex(index, ListView.Contain);
const row = list.itemAtIndex(index);
if (!row)
return false;
input.mouseClick(row, row.width / 2, row.height / 2);
return true;
}
function hover(index: int): bool {
root.settle();
const list = input.findChild(LauncherState.window.contentItem, "launcherResults");
const row = list.itemAtIndex(index);
if (!row)
return false;
input.mouseMove(row, row.width / 2, row.height / 2);
return true;
}
function outside(): void {
input.mouseClick(LauncherState.window.contentItem, 5, 5);
}
function browse(): void {
LauncherState.window.toggleBrowse();
}
function screenshot(path: string): bool {
return input.findChild(LauncherState.window.contentItem, "launcherSurface").grabToImage(result => result.saveToFile(path));
}
function extension(add: bool): bool {
if (!add) {
CommandRegistry.unregisterCommand("fixture");
return true;
}
return CommandRegistry.registerCommand({
id: "fixture",
title: "Fixture command",
description: "Test extension",
run: () => ShellState.openSettings("about")
});
}
}
}