Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/maximize_test.cpp
Show All 25 Lines | |||||
26 | #include "workspace.h" | 26 | #include "workspace.h" | ||
27 | 27 | | |||
28 | #include <KWayland/Client/compositor.h> | 28 | #include <KWayland/Client/compositor.h> | ||
29 | #include <KWayland/Client/shell.h> | 29 | #include <KWayland/Client/shell.h> | ||
30 | #include <KWayland/Client/shm_pool.h> | 30 | #include <KWayland/Client/shm_pool.h> | ||
31 | #include <KWayland/Client/surface.h> | 31 | #include <KWayland/Client/surface.h> | ||
32 | #include <KWayland/Client/server_decoration.h> | 32 | #include <KWayland/Client/server_decoration.h> | ||
33 | #include <KWayland/Client/xdgdecoration.h> | 33 | #include <KWayland/Client/xdgdecoration.h> | ||
34 | #include <KWayland/Client/xdgshell.h> | ||||
35 | #include <KWayland/Client/plasmashell.h> | ||||
34 | 36 | | |||
35 | #include <KWayland/Server/shell_interface.h> | 37 | #include <KWayland/Server/shell_interface.h> | ||
36 | #include <KWayland/Server/xdgdecoration_interface.h> | 38 | #include <KWayland/Server/xdgdecoration_interface.h> | ||
37 | 39 | | |||
38 | #include <KDecoration2/Decoration> | 40 | #include <KDecoration2/Decoration> | ||
39 | #include <KDecoration2/DecoratedClient> | 41 | #include <KDecoration2/DecoratedClient> | ||
40 | 42 | | |||
41 | using namespace KWin; | 43 | using namespace KWin; | ||
42 | using namespace KWayland::Client; | 44 | using namespace KWayland::Client; | ||
43 | 45 | | |||
44 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_maximized-0"); | 46 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_maximized-0"); | ||
45 | 47 | | |||
46 | class TestMaximized : public QObject | 48 | class TestMaximized : public QObject | ||
47 | { | 49 | { | ||
48 | Q_OBJECT | 50 | Q_OBJECT | ||
49 | private Q_SLOTS: | 51 | private Q_SLOTS: | ||
50 | void initTestCase(); | 52 | void initTestCase(); | ||
51 | void init(); | 53 | void init(); | ||
52 | void cleanup(); | 54 | void cleanup(); | ||
53 | 55 | | |||
54 | void testMaximizedPassedToDeco(); | 56 | void testMaximizedPassedToDeco(); | ||
55 | void testInitiallyMaximized(); | 57 | void testInitiallyMaximized(); | ||
56 | void testBorderlessMaximizedWindow(); | 58 | void testBorderlessMaximizedWindow(); | ||
57 | void testBorderlessMaximizedWindowNoClientSideDecoration(); | 59 | void testBorderlessMaximizedWindowNoClientSideDecoration(); | ||
60 | void testMaximizePlacementStrategy(); | ||||
58 | }; | 61 | }; | ||
59 | 62 | | |||
60 | void TestMaximized::initTestCase() | 63 | void TestMaximized::initTestCase() | ||
61 | { | 64 | { | ||
62 | qRegisterMetaType<KWin::ShellClient*>(); | 65 | qRegisterMetaType<KWin::ShellClient*>(); | ||
63 | qRegisterMetaType<KWin::AbstractClient*>(); | 66 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
64 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 67 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
65 | QVERIFY(workspaceCreatedSpy.isValid()); | 68 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
Show All 9 Lines | |||||
75 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 78 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
76 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 79 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
77 | waylandServer()->initWorkspace(); | 80 | waylandServer()->initWorkspace(); | ||
78 | } | 81 | } | ||
79 | 82 | | |||
80 | void TestMaximized::init() | 83 | void TestMaximized::init() | ||
81 | { | 84 | { | ||
82 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | 85 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | | ||
83 | Test::AdditionalWaylandInterface::XdgDecoration)); | 86 | Test::AdditionalWaylandInterface::XdgDecoration | | ||
87 | Test::AdditionalWaylandInterface::PlasmaShell)); | ||||
84 | 88 | | |||
85 | screens()->setCurrent(0); | 89 | screens()->setCurrent(0); | ||
86 | KWin::Cursor::setPos(QPoint(1280, 512)); | 90 | KWin::Cursor::setPos(QPoint(1280, 512)); | ||
87 | } | 91 | } | ||
88 | 92 | | |||
89 | void TestMaximized::cleanup() | 93 | void TestMaximized::cleanup() | ||
90 | { | 94 | { | ||
91 | Test::destroyWaylandConnection(); | 95 | Test::destroyWaylandConnection(); | ||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 235 | { | |||
289 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | 293 | Test::render(surface.data(), sizeChangeRequestedSpy.last().first().toSize(), Qt::red); | ||
290 | QVERIFY(geometryChangedSpy.wait()); | 294 | QVERIFY(geometryChangedSpy.wait()); | ||
291 | 295 | | |||
292 | QVERIFY(client->isDecorated()); | 296 | QVERIFY(client->isDecorated()); | ||
293 | QVERIFY(!client->noBorder()); | 297 | QVERIFY(!client->noBorder()); | ||
294 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | 298 | QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); | ||
295 | } | 299 | } | ||
296 | 300 | | |||
301 | void TestMaximized::testMaximizePlacementStrategy() | ||||
302 | { | ||||
303 | // adjust config | ||||
304 | auto group = kwinApp()->config()->group("Windows"); | ||||
305 | group.writeEntry("Placement", "Maximizing"); | ||||
306 | group.sync(); | ||||
307 | Workspace::self()->slotReconfigure(); | ||||
308 | | ||||
309 | // add a top panel | ||||
310 | QScopedPointer<Surface> panelSurface(Test::createSurface()); | ||||
311 | QScopedPointer<QObject> panelShellSurface(Test::createXdgShellStableSurface(panelSurface.data())); | ||||
312 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data())); | ||||
313 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||||
314 | plasmaSurface->setPosition(QPoint(0, 0)); | ||||
315 | Test::renderAndWaitForShown(panelSurface.data(), QSize(1280, 20), Qt::blue); | ||||
316 | | ||||
317 | // create a new window - it should be maximised on the first configure and positioned beneath the strut | ||||
318 | QScopedPointer<Surface> surface(Test::createSurface()); | ||||
319 | auto shellSurface = Test::createXdgShellStableSurface(surface.data(), surface.data(), Test::CreationSetup::CreateOnly); | ||||
320 | QSignalSpy configSpy(shellSurface, &XdgShellSurface::configureRequested); | ||||
321 | surface->commit(Surface::CommitFlag::None); | ||||
322 | QVERIFY(configSpy.wait()); | ||||
323 | | ||||
324 | const auto size = configSpy[0][0].toSize(); | ||||
325 | const auto states = configSpy[0][1].value<KWayland::Client::XdgShellSurface::States>(); | ||||
zzag: Does it compile? | |||||
326 | QVERIFY(states & XdgShellSurface::State::Maximized); | ||||
327 | shellSurface->ackConfigure(configSpy[0][2].toUInt()); | ||||
328 | QCOMPARE(size, QSize(1280, 1024 - 20)); | ||||
329 | | ||||
330 | auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::red); | ||||
331 | QVERIFY(c); | ||||
332 | QCOMPARE(c->geometry(), QRect(0, 20, 1280, 1024 - 20)); | ||||
333 | } | ||||
334 | | ||||
297 | WAYLANDTEST_MAIN(TestMaximized) | 335 | WAYLANDTEST_MAIN(TestMaximized) | ||
298 | #include "maximize_test.moc" | 336 | #include "maximize_test.moc" |
Does it compile?