Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/shell_client_test.cpp
Show All 30 Lines | |||||
31 | 31 | | |||
32 | #include <KWayland/Client/connection_thread.h> | 32 | #include <KWayland/Client/connection_thread.h> | ||
33 | #include <KWayland/Client/compositor.h> | 33 | #include <KWayland/Client/compositor.h> | ||
34 | #include <KWayland/Client/shell.h> | 34 | #include <KWayland/Client/shell.h> | ||
35 | #include <KWayland/Client/output.h> | 35 | #include <KWayland/Client/output.h> | ||
36 | #include <KWayland/Client/server_decoration.h> | 36 | #include <KWayland/Client/server_decoration.h> | ||
37 | #include <KWayland/Client/surface.h> | 37 | #include <KWayland/Client/surface.h> | ||
38 | #include <KWayland/Client/xdgshell.h> | 38 | #include <KWayland/Client/xdgshell.h> | ||
39 | #include <KWayland/Client/xdgdecoration.h> | ||||
39 | #include <KWayland/Client/appmenu.h> | 40 | #include <KWayland/Client/appmenu.h> | ||
40 | 41 | | |||
41 | #include <KWayland/Server/clientconnection.h> | 42 | #include <KWayland/Server/clientconnection.h> | ||
42 | #include <KWayland/Server/display.h> | 43 | #include <KWayland/Server/display.h> | ||
43 | #include <KWayland/Server/shell_interface.h> | 44 | #include <KWayland/Server/shell_interface.h> | ||
44 | 45 | #include <KWayland/Server/xdgdecoration_interface.h> | |||
45 | 46 | | |||
46 | // system | 47 | // system | ||
47 | #include <sys/types.h> | 48 | #include <sys/types.h> | ||
48 | #include <sys/socket.h> | 49 | #include <sys/socket.h> | ||
49 | #include <unistd.h> | 50 | #include <unistd.h> | ||
50 | 51 | | |||
51 | using namespace KWin; | 52 | using namespace KWin; | ||
52 | using namespace KWayland::Client; | 53 | using namespace KWayland::Client; | ||
Show All 34 Lines | 60 | private Q_SLOTS: | |||
87 | void testCaptionMultipleWindows(); | 88 | void testCaptionMultipleWindows(); | ||
88 | void testUnresponsiveWindow_data(); | 89 | void testUnresponsiveWindow_data(); | ||
89 | void testUnresponsiveWindow(); | 90 | void testUnresponsiveWindow(); | ||
90 | void testX11WindowId_data(); | 91 | void testX11WindowId_data(); | ||
91 | void testX11WindowId(); | 92 | void testX11WindowId(); | ||
92 | void testAppMenu(); | 93 | void testAppMenu(); | ||
93 | void testNoDecorationModeRequested_data(); | 94 | void testNoDecorationModeRequested_data(); | ||
94 | void testNoDecorationModeRequested(); | 95 | void testNoDecorationModeRequested(); | ||
96 | void testXdgDecoration_data(); | ||||
97 | void testXdgDecoration(); | ||||
95 | }; | 98 | }; | ||
96 | 99 | | |||
97 | void TestShellClient::initTestCase() | 100 | void TestShellClient::initTestCase() | ||
98 | { | 101 | { | ||
99 | qRegisterMetaType<KWin::Deleted*>(); | 102 | qRegisterMetaType<KWin::Deleted*>(); | ||
100 | qRegisterMetaType<KWin::ShellClient*>(); | 103 | qRegisterMetaType<KWin::ShellClient*>(); | ||
101 | qRegisterMetaType<KWin::AbstractClient*>(); | 104 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
102 | qRegisterMetaType<KWayland::Client::Output*>(); | 105 | qRegisterMetaType<KWayland::Client::Output*>(); | ||
Show All 10 Lines | |||||
113 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 116 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
114 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 117 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
115 | waylandServer()->initWorkspace(); | 118 | waylandServer()->initWorkspace(); | ||
116 | } | 119 | } | ||
117 | 120 | | |||
118 | void TestShellClient::init() | 121 | void TestShellClient::init() | ||
119 | { | 122 | { | ||
120 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | 123 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | ||
124 | Test::AdditionalWaylandInterface::XdgDecoration | | ||||
121 | Test::AdditionalWaylandInterface::AppMenu)); | 125 | Test::AdditionalWaylandInterface::AppMenu)); | ||
122 | 126 | | |||
123 | screens()->setCurrent(0); | 127 | screens()->setCurrent(0); | ||
124 | KWin::Cursor::setPos(QPoint(1280, 512)); | 128 | KWin::Cursor::setPos(QPoint(1280, 512)); | ||
125 | } | 129 | } | ||
126 | 130 | | |||
127 | void TestShellClient::cleanup() | 131 | void TestShellClient::cleanup() | ||
128 | { | 132 | { | ||
▲ Show 20 Lines • Show All 953 Lines • ▼ Show 20 Line(s) | 1075 | { | |||
1082 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | 1086 | QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); | ||
1083 | 1087 | | |||
1084 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1088 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1085 | QVERIFY(c); | 1089 | QVERIFY(c); | ||
1086 | QCOMPARE(c->noBorder(), false); | 1090 | QCOMPARE(c->noBorder(), false); | ||
1087 | QCOMPARE(c->isDecorated(), true); | 1091 | QCOMPARE(c->isDecorated(), true); | ||
1088 | } | 1092 | } | ||
1089 | 1093 | | |||
1094 | void TestShellClient::testXdgDecoration_data() | ||||
1095 | { | ||||
1096 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("requestedMode"); | ||||
1097 | QTest::addColumn<KWayland::Client::XdgDecoration::Mode>("expectedMode"); | ||||
1098 | | ||||
1099 | QTest::newRow("client side requested") << XdgDecoration::Mode::ClientSide << XdgDecoration::Mode::ClientSide; | ||||
1100 | QTest::newRow("server side requested") << XdgDecoration::Mode::ServerSide << XdgDecoration::Mode::ServerSide; | ||||
1101 | } | ||||
1102 | | ||||
1103 | void TestShellClient::testXdgDecoration() | ||||
1104 | { | ||||
1105 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
1106 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||||
1107 | QScopedPointer<XdgDecoration> deco(Test::xdgDecorationManager()->getToplevelDecoration(shellSurface.data())); | ||||
1108 | | ||||
1109 | QSignalSpy decorationConfiguredSpy(deco.data(), &XdgDecoration::modeChanged); | ||||
1110 | QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested); | ||||
1111 | | ||||
1112 | QFETCH(KWayland::Client::XdgDecoration::Mode, requestedMode); | ||||
1113 | QFETCH(KWayland::Client::XdgDecoration::Mode, expectedMode); | ||||
1114 | | ||||
1115 | //request a mode | ||||
1116 | deco->setMode(requestedMode); | ||||
1117 | | ||||
1118 | //kwin will send a configure | ||||
1119 | decorationConfiguredSpy.wait(); | ||||
1120 | configureRequestedSpy.wait(); | ||||
1121 | | ||||
1122 | QCOMPARE(decorationConfiguredSpy.count(), 1); | ||||
1123 | QCOMPARE(decorationConfiguredSpy.first()[0].value<KWayland::Client::XdgDecoration::Mode>(), expectedMode); | ||||
1124 | QVERIFY(configureRequestedSpy.count() > 0); | ||||
1125 | | ||||
1126 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
1127 | | ||||
1128 | auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||||
1129 | QCOMPARE(c->userCanSetNoBorder(), expectedMode == XdgDecoration::Mode::ServerSide); | ||||
1130 | QCOMPARE(c->isDecorated(), expectedMode == XdgDecoration::Mode::ServerSide); | ||||
1131 | | ||||
1132 | } | ||||
1133 | | ||||
1090 | WAYLANDTEST_MAIN(TestShellClient) | 1134 | WAYLANDTEST_MAIN(TestShellClient) | ||
1091 | #include "shell_client_test.moc" | 1135 | #include "shell_client_test.moc" |