162 lines
6.3 KiB
QML
162 lines
6.3 KiB
QML
// SPDX-License-Identifier: MIT
|
|
import QtQuick
|
|
import QtTest
|
|
import "../controller/contents/ui/areas.js" as Areas
|
|
|
|
Item {
|
|
width: 600
|
|
height: 100
|
|
Item {
|
|
id: panel
|
|
x: 30
|
|
y: 20
|
|
width: 500
|
|
height: 40
|
|
Item {
|
|
width: 200
|
|
height: 40
|
|
property alias applet: tasks
|
|
Item {
|
|
id: tasks
|
|
anchors.fill: parent
|
|
property QtObject plasmoid: QtObject { property string pluginName: "org.kde.plasma.taskmanager" }
|
|
Item {
|
|
id: button
|
|
width: 80
|
|
height: 40
|
|
property Item tasksRoot: tasks
|
|
property bool isWindow: true
|
|
property int index: 0
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
x: 200
|
|
width: 60
|
|
height: 40
|
|
property QtObject applet: QtObject {
|
|
property QtObject plasmoid: QtObject { property string pluginName: "org.kde.plasma.systemtray" }
|
|
}
|
|
}
|
|
Item {
|
|
id: arbitraryWidget
|
|
x: 260
|
|
width: 60
|
|
height: 40
|
|
property QtObject applet: QtObject {
|
|
property QtObject plasmoid: QtObject { property string pluginName: "third.party.widget" }
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
id: edges
|
|
x: 40
|
|
y: 10
|
|
property bool vertical: false
|
|
property bool reversed: false
|
|
width: vertical ? 60 : 400
|
|
height: vertical ? 400 : 60
|
|
Item { width: 0; height: 60 } // invisible controller's zero-width slot
|
|
Item { x: -100; y: -100; width: 50; height: 50; visible: false }
|
|
Item {
|
|
id: launcher
|
|
x: edges.vertical ? 8 : edges.reversed ? 350 : 12
|
|
y: edges.vertical ? (edges.reversed ? 350 : 12) : 8
|
|
width: edges.vertical ? 44 : 36
|
|
height: edges.vertical ? 36 : 44
|
|
property QtObject applet: QtObject {
|
|
property QtObject plasmoid: QtObject { property string pluginName: "org.kde.plasma.kickoff" }
|
|
}
|
|
}
|
|
Item {
|
|
x: edges.vertical ? 8 : 90
|
|
y: edges.vertical ? 90 : 8
|
|
width: edges.vertical ? 44 : 80
|
|
height: edges.vertical ? 80 : 44
|
|
property QtObject applet: QtObject {
|
|
property QtObject plasmoid: QtObject { property string pluginName: "org.kde.plasma.panelspacer" }
|
|
}
|
|
}
|
|
Item {
|
|
id: clock
|
|
x: edges.vertical ? 8 : edges.reversed ? 12 : 350
|
|
y: edges.vertical ? (edges.reversed ? 12 : 350) : 8
|
|
width: edges.vertical ? 44 : 36
|
|
height: edges.vertical ? 36 : 44
|
|
property QtObject applet: QtObject {
|
|
property QtObject plasmoid: QtObject { property string pluginName: "org.kde.plasma.digitalclock" }
|
|
}
|
|
}
|
|
}
|
|
TestCase {
|
|
name: "PanelAreas"
|
|
when: windowShown
|
|
function init() {
|
|
edges.vertical = false;
|
|
edges.reversed = false;
|
|
edges.scale = 1;
|
|
launcher.visible = true;
|
|
}
|
|
function scrollAt(along, across) {
|
|
const p = edges.mapToItem(null, edges.vertical ? across : along, edges.vertical ? along : across);
|
|
return Areas.scrollAreaAt(edges, p.x, p.y, edges.vertical);
|
|
}
|
|
function test_scrollMargins_data() {
|
|
return [
|
|
{tag: "horizontal", vertical: false, scale: 1},
|
|
{tag: "vertical", vertical: true, scale: 1},
|
|
{tag: "scaled", vertical: false, scale: 1.5},
|
|
{tag: "vertical-scaled", vertical: true, scale: 1.5}
|
|
];
|
|
}
|
|
function test_scrollMargins(data) {
|
|
edges.vertical = data.vertical;
|
|
edges.scale = data.scale;
|
|
compare(scrollAt(-20, 58), "launcher"); // leading outer corner
|
|
compare(scrollAt(30, 2), "launcher"); // thickness padding above/beside icon
|
|
compare(scrollAt(420, 58), "clock"); // trailing outer corner
|
|
compare(scrollAt(65, 58), "empty"); // internal gap
|
|
compare(scrollAt(120, 58), "empty"); // explicit spacer
|
|
compare(scrollAt(200, 58), "empty");
|
|
edges.reversed = true; // physical order, not QObject child order
|
|
compare(scrollAt(-20, 58), "clock");
|
|
compare(scrollAt(420, 58), "launcher");
|
|
}
|
|
function test_clickMarginsStayEmpty() {
|
|
const p = edges.mapToItem(null, -20, 58);
|
|
compare(Areas.areaAt(edges, p.x, p.y), "empty");
|
|
compare(Areas.scrollAreaAt(edges, p.x, p.y, false), "launcher");
|
|
const inside = launcher.mapToItem(null, 10, 10);
|
|
compare(Areas.areaAt(edges, inside.x, inside.y), "launcher");
|
|
}
|
|
function test_hiddenAndZeroSizeDoNotOwnPadding() {
|
|
launcher.visible = false;
|
|
compare(scrollAt(-20, 58), "empty"); // spacer becomes first
|
|
compare(Areas.scrollAreaAt(null, 0, 0, false), "");
|
|
}
|
|
function test_taskThicknessPaddingKeepsUnusedSpaceEmpty() {
|
|
compare(Areas.scrollAreaAt(panel, 40, 65, false), "tasks");
|
|
compare(Areas.scrollAreaAt(panel, 150, 65, false), "empty");
|
|
compare(Areas.areaAt(panel, 40, 65), "empty");
|
|
compare(Areas.scrollAreaAt(panel, 0, 65, false), "tasks");
|
|
}
|
|
function test_taskButtonsVersusUnusedSpace() {
|
|
compare(Areas.areaAt(panel, 40, 30), "tasks");
|
|
compare(Areas.areaAt(panel, 150, 30), "empty");
|
|
button.isWindow = false; // pinned launchers still count as buttons
|
|
compare(Areas.areaAt(panel, 40, 30), "tasks");
|
|
button.visible = false;
|
|
compare(Areas.areaAt(panel, 40, 30), "empty");
|
|
button.visible = true;
|
|
}
|
|
function test_trayAndUnrecognizedWidgetsKeepClicks() {
|
|
compare(Areas.areaAt(panel, 240, 30), "tray");
|
|
compare(Areas.areaAt(panel, 300, 30), "other");
|
|
arbitraryWidget.visible = false;
|
|
compare(Areas.areaAt(panel, 300, 30), "empty");
|
|
arbitraryWidget.visible = true;
|
|
compare(Areas.areaAt(null, 40, 30), "");
|
|
}
|
|
}
|
|
}
|