86 lines
4.1 KiB
QML
86 lines
4.1 KiB
QML
// SPDX-License-Identifier: MIT
|
|
import QtQuick
|
|
import QtTest
|
|
import se.ajpanton.panelactions 1.0
|
|
|
|
TestCase {
|
|
name: "PanelPlugin"
|
|
PanelController { id: controller }
|
|
PanelSettings { id: panelSettings }
|
|
function test_loadsInstalledTypes() {
|
|
verify(controller !== null);
|
|
verify(panelSettings.values.emptyAction !== undefined);
|
|
}
|
|
function test_widgetComponentsCompile() {
|
|
for (const path of ["../package/contents/ui/main.qml", "../controller/contents/ui/main.qml"]) {
|
|
const component = Qt.createComponent(path);
|
|
compare(component.status, Component.Ready, component.errorString());
|
|
component.destroy();
|
|
}
|
|
}
|
|
function test_settingsWindowWithoutWidget() {
|
|
const component = Qt.createComponent("../src/SettingsWindow.qml");
|
|
compare(component.status, Component.Ready, component.errorString());
|
|
const window = component.createObject(null);
|
|
verify(window !== null);
|
|
tryCompare(window, "visible", true);
|
|
const form = findChild(window, "settingsForm");
|
|
verify(form !== null);
|
|
compare(form.cfg_tasksAction, panelSettings.values.tasksAction);
|
|
compare(findChild(form, "tasksAction").currentValue, panelSettings.values.tasksAction);
|
|
window.width = 600;
|
|
window.height = 400;
|
|
const save = findChild(window, "saveSettings");
|
|
const page = window.pageStack.currentItem;
|
|
tryVerify(() => page.flickable.contentHeight > page.flickable.height);
|
|
tryVerify(() => {
|
|
const position = save.mapToItem(window.contentItem, 0, 0);
|
|
return position.y >= 0 && position.y + save.height <= window.height;
|
|
});
|
|
const saveY = save.mapToItem(window.contentItem, 0, 0).y;
|
|
page.flickable.contentY = page.flickable.contentHeight - page.flickable.height;
|
|
compare(save.mapToItem(window.contentItem, 0, 0).y, saveY);
|
|
form.cfg_tasksAction = "brightness";
|
|
save.clicked();
|
|
compare(panelSettings.values.tasksAction, "brightness");
|
|
window.close();
|
|
window.destroy();
|
|
component.destroy();
|
|
}
|
|
function test_clickDetailsWrap() {
|
|
const component = Qt.createComponent("../src/SettingsWindow.qml");
|
|
compare(component.status, Component.Ready, component.errorString());
|
|
const window = component.createObject(null);
|
|
verify(window !== null);
|
|
const form = findChild(window, "settingsForm");
|
|
form.cfg_leftClick = "application";
|
|
form.applications = [{text: "A moderately long application name", value: "test.desktop"}];
|
|
form.cfg_leftClickApplication = "test.desktop";
|
|
form.cfg_middleClick = "command";
|
|
const action = findChild(form, "leftClick");
|
|
const application = findChild(form, "leftClickApplication");
|
|
const middleAction = findChild(form, "middleClick");
|
|
const command = findChild(form, "middleClickCommand");
|
|
const scrollAction = findChild(form, "emptyAction");
|
|
window.minimumWidth = 320;
|
|
for (const width of [760, 360, 900]) {
|
|
window.width = width;
|
|
if (width === 360) {
|
|
tryVerify(() => application.y >= action.y + action.height);
|
|
tryVerify(() => command.y >= middleAction.y + middleAction.height);
|
|
} else {
|
|
tryVerify(() => application.x >= action.x + action.width && application.y === action.y);
|
|
tryVerify(() => command.x >= middleAction.x + middleAction.width && command.y === middleAction.y);
|
|
}
|
|
verify(application.x + application.width <= application.parent.width);
|
|
verify(command.x + command.width <= command.parent.width);
|
|
tryCompare(application, "width", Math.min(application.implicitWidth, application.parent.width));
|
|
tryVerify(() => Math.abs(command.x + command.width - command.parent.width) < 1);
|
|
tryVerify(() => Math.abs(scrollAction.mapToItem(form, 0, 0).x - action.mapToItem(form, 0, 0).x) <= 1);
|
|
}
|
|
window.close();
|
|
window.destroy();
|
|
component.destroy();
|
|
}
|
|
}
|