Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/showing_desktop_test.cpp
Show All 19 Lines | |||||
20 | #include "kwin_wayland_test.h" | 20 | #include "kwin_wayland_test.h" | ||
21 | #include "platform.h" | 21 | #include "platform.h" | ||
22 | #include "shell_client.h" | 22 | #include "shell_client.h" | ||
23 | #include "wayland_server.h" | 23 | #include "wayland_server.h" | ||
24 | #include "workspace.h" | 24 | #include "workspace.h" | ||
25 | 25 | | |||
26 | #include <KWayland/Client/plasmashell.h> | 26 | #include <KWayland/Client/plasmashell.h> | ||
27 | #include <KWayland/Client/surface.h> | 27 | #include <KWayland/Client/surface.h> | ||
28 | #include <KWayland/Client/shell.h> | | |||
29 | 28 | | |||
30 | using namespace KWin; | 29 | using namespace KWin; | ||
31 | using namespace KWayland::Client; | 30 | using namespace KWayland::Client; | ||
32 | 31 | | |||
33 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_showing_desktop-0"); | 32 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_showing_desktop-0"); | ||
34 | 33 | | |||
35 | class ShowingDesktopTest : public QObject | 34 | class ShowingDesktopTest : public QObject | ||
36 | { | 35 | { | ||
Show All 29 Lines | |||||
66 | void ShowingDesktopTest::cleanup() | 65 | void ShowingDesktopTest::cleanup() | ||
67 | { | 66 | { | ||
68 | Test::destroyWaylandConnection(); | 67 | Test::destroyWaylandConnection(); | ||
69 | } | 68 | } | ||
70 | 69 | | |||
71 | void ShowingDesktopTest::testRestoreFocus() | 70 | void ShowingDesktopTest::testRestoreFocus() | ||
72 | { | 71 | { | ||
73 | QScopedPointer<Surface> surface1(Test::createSurface()); | 72 | QScopedPointer<Surface> surface1(Test::createSurface()); | ||
74 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | 73 | QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data())); | ||
75 | auto client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue); | 74 | auto client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue); | ||
76 | QScopedPointer<Surface> surface2(Test::createSurface()); | 75 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
77 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | 76 | QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data())); | ||
78 | auto client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | 77 | auto client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | ||
79 | QVERIFY(client1 != client2); | 78 | QVERIFY(client1 != client2); | ||
80 | 79 | | |||
81 | QCOMPARE(workspace()->activeClient(), client2); | 80 | QCOMPARE(workspace()->activeClient(), client2); | ||
82 | workspace()->slotToggleShowDesktop(); | 81 | workspace()->slotToggleShowDesktop(); | ||
83 | QVERIFY(workspace()->showingDesktop()); | 82 | QVERIFY(workspace()->showingDesktop()); | ||
84 | workspace()->slotToggleShowDesktop(); | 83 | workspace()->slotToggleShowDesktop(); | ||
85 | QVERIFY(!workspace()->showingDesktop()); | 84 | QVERIFY(!workspace()->showingDesktop()); | ||
86 | 85 | | |||
87 | QVERIFY(workspace()->activeClient()); | 86 | QVERIFY(workspace()->activeClient()); | ||
88 | QCOMPARE(workspace()->activeClient(), client2); | 87 | QCOMPARE(workspace()->activeClient(), client2); | ||
89 | } | 88 | } | ||
90 | 89 | | |||
91 | void ShowingDesktopTest::testRestoreFocusWithDesktopWindow() | 90 | void ShowingDesktopTest::testRestoreFocusWithDesktopWindow() | ||
92 | { | 91 | { | ||
93 | // first create a desktop window | 92 | // first create a desktop window | ||
94 | 93 | | |||
95 | QScopedPointer<Surface> desktopSurface(Test::createSurface()); | 94 | QScopedPointer<Surface> desktopSurface(Test::createSurface()); | ||
96 | QVERIFY(!desktopSurface.isNull()); | 95 | QVERIFY(!desktopSurface.isNull()); | ||
97 | QScopedPointer<ShellSurface> desktopShellSurface(Test::createShellSurface(desktopSurface.data())); | 96 | QScopedPointer<XdgShellSurface> desktopShellSurface(Test::createXdgShellStableSurface(desktopSurface.data())); | ||
98 | QVERIFY(!desktopSurface.isNull()); | 97 | QVERIFY(!desktopSurface.isNull()); | ||
99 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(desktopSurface.data())); | 98 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(desktopSurface.data())); | ||
100 | QVERIFY(!plasmaSurface.isNull()); | 99 | QVERIFY(!plasmaSurface.isNull()); | ||
101 | plasmaSurface->setRole(PlasmaShellSurface::Role::Desktop); | 100 | plasmaSurface->setRole(PlasmaShellSurface::Role::Desktop); | ||
102 | 101 | | |||
103 | auto desktop = Test::renderAndWaitForShown(desktopSurface.data(), QSize(100, 50), Qt::blue); | 102 | auto desktop = Test::renderAndWaitForShown(desktopSurface.data(), QSize(100, 50), Qt::blue); | ||
104 | QVERIFY(desktop); | 103 | QVERIFY(desktop); | ||
105 | QVERIFY(desktop->isDesktop()); | 104 | QVERIFY(desktop->isDesktop()); | ||
106 | 105 | | |||
107 | // now create some windows | 106 | // now create some windows | ||
108 | QScopedPointer<Surface> surface1(Test::createSurface()); | 107 | QScopedPointer<Surface> surface1(Test::createSurface()); | ||
109 | QScopedPointer<ShellSurface> shellSurface1(Test::createShellSurface(surface1.data())); | 108 | QScopedPointer<XdgShellSurface> shellSurface1(Test::createXdgShellStableSurface(surface1.data())); | ||
110 | auto client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue); | 109 | auto client1 = Test::renderAndWaitForShown(surface1.data(), QSize(100, 50), Qt::blue); | ||
111 | QScopedPointer<Surface> surface2(Test::createSurface()); | 110 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
112 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | 111 | QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data())); | ||
113 | auto client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | 112 | auto client2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue); | ||
114 | QVERIFY(client1 != client2); | 113 | QVERIFY(client1 != client2); | ||
115 | 114 | | |||
116 | QCOMPARE(workspace()->activeClient(), client2); | 115 | QCOMPARE(workspace()->activeClient(), client2); | ||
117 | workspace()->slotToggleShowDesktop(); | 116 | workspace()->slotToggleShowDesktop(); | ||
118 | QVERIFY(workspace()->showingDesktop()); | 117 | QVERIFY(workspace()->showingDesktop()); | ||
119 | QCOMPARE(workspace()->activeClient(), desktop); | 118 | QCOMPARE(workspace()->activeClient(), desktop); | ||
120 | workspace()->slotToggleShowDesktop(); | 119 | workspace()->slotToggleShowDesktop(); | ||
121 | QVERIFY(!workspace()->showingDesktop()); | 120 | QVERIFY(!workspace()->showingDesktop()); | ||
122 | 121 | | |||
123 | QVERIFY(workspace()->activeClient()); | 122 | QVERIFY(workspace()->activeClient()); | ||
124 | QCOMPARE(workspace()->activeClient(), client2); | 123 | QCOMPARE(workspace()->activeClient(), client2); | ||
125 | } | 124 | } | ||
126 | 125 | | |||
127 | WAYLANDTEST_MAIN(ShowingDesktopTest) | 126 | WAYLANDTEST_MAIN(ShowingDesktopTest) | ||
128 | #include "showing_desktop_test.moc" | 127 | #include "showing_desktop_test.moc" |