Files
DankMaterialShell/quickshell/tests/qml/process-list-cache.qml
T
bbedward bb20528f68 popouts: grow surfaces at their origin
cc: slide grid with the detail page
settings: tweak appearance header style
settings: tweak sidebar profile style
2026-09-21 15:47:01 -04:00

95 lines
3.0 KiB
QML

import QtQuick
import QtTest
import Quickshell
import qs.Common
import qs.Services
import qs.Modules.ProcessList
import qs.DankCommon.Common as DC
ShellRoot {
id: root
TestCase {
id: input
when: false
name: "process-list-cache"
}
PanelWindow {
color: "transparent"
implicitWidth: 600
implicitHeight: 500
anchors {
top: true
left: true
}
ProcessesView {
id: view
anchors.fill: parent
active: false
}
}
Component.onCompleted: {
Quickshell.watchFiles = false;
DC.Style.theme = Theme;
DC.Style.settings = SettingsData;
DC.I18n.backend = I18n;
}
function check(value, message) {
if (!value)
throw new Error(message);
}
function process(pid, command) {
return {
pid: pid,
command: command,
fullCommand: command,
username: UserInfoService.username,
cpu: 1,
memoryKB: 1024
};
}
readonly property var emptyLabel: view.listView.children.find(c => c.text !== undefined && c.font !== undefined)
Timer {
interval: 0
running: true
onTriggered: {
try {
root.check(root.emptyLabel && root.emptyLabel.visible && view.cachedProcesses.length === 0, "first open with no data shows an empty state");
DgopService.allProcesses = [root.process(1, "init"), root.process(2, "shell")];
view.active = true;
input.tryCompare(root.emptyLabel, "visible", false);
root.check(view.cachedProcesses.length === 2 && !root.emptyLabel.visible, "rows appear once data and activity meet");
view.active = false;
root.check(view.cachedProcesses.length === 2 && !root.emptyLabel.visible, "closing keeps the last rows for the close animation");
DgopService.allProcesses = [];
root.check(view.cachedProcesses.length === 2 && !root.emptyLabel.visible, "releasing the data source keeps the last rows");
view.active = true;
root.check(view.cachedProcesses.length === 2 && !root.emptyLabel.visible, "reopening before the first sample keeps the last rows");
DgopService.allProcesses = [root.process(3, "editor")];
root.check(view.cachedProcesses.length === 1 && view.cachedProcesses[0].pid === 3, "first sample after reopen replaces the rows");
view.searchText = "nomatch";
input.tryCompare(root.emptyLabel, "visible", true);
root.check(view.cachedProcesses.length === 0 && root.emptyLabel.visible, "a search with no hits shows the empty state");
console.log("FIXTURE_PASS process list keeps rows across close, release and reopen; empty state only for real misses");
} catch (error) {
console.error("FIXTURE_FAIL", error.message);
}
Qt.quit();
}
}
}