15#include <KWayland/Client/surface.h>
19static const QString s_socketName = QStringLiteral(
"wayland_test_kwin_showing_desktop-0");
29 void testRestoreFocus();
30 void testRestoreFocusWithDesktopWindow();
31 void testQuitAfterActivatingHiddenWindow();
32 void testDontQuitAfterActivatingDock();
33 void testQuitAfterAddingWindow();
34 void testDontQuitAfterAddingDock();
37void ShowingDesktopTest::initTestCase()
39 qRegisterMetaType<KWin::Window *>();
43 QRect(0, 0, 1280, 1024),
44 QRect(1280, 0, 1280, 1024),
48 QVERIFY(applicationStartedSpy.wait());
51void ShowingDesktopTest::init()
56void ShowingDesktopTest::cleanup()
61void ShowingDesktopTest::testRestoreFocus()
69 QVERIFY(window1 != window2);
71 QCOMPARE(
workspace()->activeWindow(), window2);
78 QCOMPARE(
workspace()->activeWindow(), window2);
81void ShowingDesktopTest::testRestoreFocusWithDesktopWindow()
86 std::unique_ptr<Test::LayerSurfaceV1> desktopShellSurface(
Test::createLayerSurfaceV1(desktopSurface.get(), QStringLiteral(
"desktop")));
87 desktopShellSurface->set_keyboard_interactivity(1);
88 desktopShellSurface->set_layer(Test::LayerShellV1::layer_background);
89 desktopShellSurface->set_size(0, 0);
90 desktopShellSurface->set_exclusive_zone(-1);
91 desktopShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_bottom
92 | Test::LayerSurfaceV1::anchor_top
93 | Test::LayerSurfaceV1::anchor_left
94 | Test::LayerSurfaceV1::anchor_right);
95 desktopSurface->commit(KWayland::Client::Surface::CommitFlag::None);
97 QVERIFY(desktopConfigureRequestedSpy.wait());
100 QVERIFY(desktop->isDesktop());
109 QVERIFY(window1 != window2);
111 QCOMPARE(
workspace()->activeWindow(), window2);
114 QCOMPARE(
workspace()->activeWindow(), desktop);
119 QCOMPARE(
workspace()->activeWindow(), window2);
122void ShowingDesktopTest::testQuitAfterActivatingHiddenWindow()
132 QCOMPARE(
workspace()->activeWindow(), window2);
141void ShowingDesktopTest::testDontQuitAfterActivatingDock()
146 std::unique_ptr<Test::LayerSurfaceV1> desktopShellSurface(
Test::createLayerSurfaceV1(desktopSurface.get(), QStringLiteral(
"desktop")));
147 desktopShellSurface->set_keyboard_interactivity(1);
148 desktopShellSurface->set_layer(Test::LayerShellV1::layer_background);
149 desktopShellSurface->set_size(0, 0);
150 desktopShellSurface->set_exclusive_zone(-1);
151 desktopShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_bottom
152 | Test::LayerSurfaceV1::anchor_top
153 | Test::LayerSurfaceV1::anchor_left
154 | Test::LayerSurfaceV1::anchor_right);
155 desktopSurface->commit(KWayland::Client::Surface::CommitFlag::None);
157 QVERIFY(desktopConfigureRequestedSpy.wait());
161 std::unique_ptr<Test::LayerSurfaceV1> dockShellSurface{
Test::createLayerSurfaceV1(dockSurface.get(), QStringLiteral(
"dock"))};
162 dockShellSurface->set_size(1280, 50);
163 dockShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_bottom);
164 dockShellSurface->set_exclusive_zone(50);
165 dockShellSurface->set_keyboard_interactivity(1);
166 dockSurface->commit(KWayland::Client::Surface::CommitFlag::None);
168 QVERIFY(dockConfigureRequestedSpy.wait());
174 QVERIFY(window->isActive());
178 QVERIFY(desktop->isActive());
182 QVERIFY(dock->isActive());
186 QVERIFY(desktop->isActive());
192void ShowingDesktopTest::testQuitAfterAddingWindow()
210void ShowingDesktopTest::testDontQuitAfterAddingDock()
217 QVERIFY(window->isActive());
223 std::unique_ptr<Test::LayerSurfaceV1> dockShellSurface{
Test::createLayerSurfaceV1(dockSurface.get(), QStringLiteral(
"dock"))};
224 dockShellSurface->set_size(1280, 50);
225 dockShellSurface->set_anchor(Test::LayerSurfaceV1::anchor_bottom);
226 dockShellSurface->set_exclusive_zone(50);
227 dockShellSurface->set_keyboard_interactivity(1);
228 dockSurface->commit(KWayland::Client::Surface::CommitFlag::None);
230 QVERIFY(dockConfigureRequestedSpy.wait());
232 QVERIFY(dock->isActive());
239#include "showing_desktop_test.moc"
void configureRequested(quint32 serial, const QSize &size)
void slotToggleShowDesktop()
void activateWindow(Window *window, bool force=false)
#define WAYLANDTEST_MAIN(TestObject)
Window * renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format=QImage::Format_ARGB32, int timeout=5000)
void destroyWaylandConnection()
void setOutputConfig(const QList< QRect > &geometries)
bool setupWaylandConnection(AdditionalWaylandInterfaces flags=AdditionalWaylandInterfaces())
LayerSurfaceV1 * createLayerSurfaceV1(KWayland::Client::Surface *surface, const QString &scope, KWayland::Client::Output *output=nullptr, LayerShellV1::layer layer=LayerShellV1::layer_top)
std::unique_ptr< KWayland::Client::Surface > createSurface()
XdgToplevel * createXdgToplevelSurface(KWayland::Client::Surface *surface, QObject *parent=nullptr)
WaylandServer * waylandServer()