Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/maximize_animation_test.cpp
Show All 20 Lines | |||||
21 | #include "kwin_wayland_test.h" | 21 | #include "kwin_wayland_test.h" | ||
22 | 22 | | |||
23 | #include "abstract_client.h" | 23 | #include "abstract_client.h" | ||
24 | #include "composite.h" | 24 | #include "composite.h" | ||
25 | #include "effectloader.h" | 25 | #include "effectloader.h" | ||
26 | #include "effects.h" | 26 | #include "effects.h" | ||
27 | #include "platform.h" | 27 | #include "platform.h" | ||
28 | #include "scene.h" | 28 | #include "scene.h" | ||
29 | #include "xdgshellclient.h" | | |||
30 | #include "wayland_server.h" | 29 | #include "wayland_server.h" | ||
31 | #include "workspace.h" | 30 | #include "workspace.h" | ||
32 | 31 | | |||
33 | #include "effect_builtins.h" | 32 | #include "effect_builtins.h" | ||
34 | 33 | | |||
35 | #include <KWayland/Client/surface.h> | 34 | #include <KWayland/Client/surface.h> | ||
36 | #include <KWayland/Client/xdgshell.h> | 35 | #include <KWayland/Client/xdgshell.h> | ||
37 | 36 | | |||
Show All 14 Lines | 45 | private Q_SLOTS: | |||
52 | void testMaximizeRestore(); | 51 | void testMaximizeRestore(); | ||
53 | }; | 52 | }; | ||
54 | 53 | | |||
55 | void MaximizeAnimationTest::initTestCase() | 54 | void MaximizeAnimationTest::initTestCase() | ||
56 | { | 55 | { | ||
57 | qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); | 56 | qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); | ||
58 | 57 | | |||
59 | qRegisterMetaType<KWin::AbstractClient *>(); | 58 | qRegisterMetaType<KWin::AbstractClient *>(); | ||
60 | qRegisterMetaType<KWin::XdgShellClient *>(); | | |||
61 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 59 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
62 | QVERIFY(workspaceCreatedSpy.isValid()); | 60 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
63 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 61 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
64 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 62 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
65 | 63 | | |||
66 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | 64 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||
67 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | 65 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | ||
68 | ScriptedEffectLoader loader; | 66 | ScriptedEffectLoader loader; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 105 | { | |||
128 | QCOMPARE(configureRequestedSpy.count(), 1); | 126 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
129 | QCOMPARE(configureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0)); | 127 | QCOMPARE(configureRequestedSpy.last().at(0).value<QSize>(), QSize(0, 0)); | ||
130 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | 128 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
131 | QVERIFY(!states.testFlag(XdgShellSurface::State::Activated)); | 129 | QVERIFY(!states.testFlag(XdgShellSurface::State::Activated)); | ||
132 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | 130 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||
133 | 131 | | |||
134 | // Draw contents of the surface. | 132 | // Draw contents of the surface. | ||
135 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | 133 | shellSurface->ackConfigure(configureRequestedSpy.last().at(2).value<quint32>()); | ||
136 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 134 | AbstractClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
137 | QVERIFY(client); | 135 | QVERIFY(client); | ||
138 | QVERIFY(client->isActive()); | 136 | QVERIFY(client->isActive()); | ||
139 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | 137 | QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); | ||
140 | 138 | | |||
141 | // We should receive a configure event when the client becomes active. | 139 | // We should receive a configure event when the client becomes active. | ||
142 | QVERIFY(configureRequestedSpy.wait()); | 140 | QVERIFY(configureRequestedSpy.wait()); | ||
143 | QCOMPARE(configureRequestedSpy.count(), 2); | 141 | QCOMPARE(configureRequestedSpy.count(), 2); | ||
144 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | 142 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
145 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | 143 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||
146 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | 144 | QVERIFY(!states.testFlag(XdgShellSurface::State::Maximized)); | ||
147 | 145 | | |||
148 | // Load effect that will be tested. | 146 | // Load effect that will be tested. | ||
149 | const QString effectName = QStringLiteral("kwin4_effect_maximize"); | 147 | const QString effectName = QStringLiteral("kwin4_effect_maximize"); | ||
150 | auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects); | 148 | auto effectsImpl = qobject_cast<EffectsHandlerImpl *>(effects); | ||
151 | QVERIFY(effectsImpl); | 149 | QVERIFY(effectsImpl); | ||
152 | QVERIFY(effectsImpl->loadEffect(effectName)); | 150 | QVERIFY(effectsImpl->loadEffect(effectName)); | ||
153 | QCOMPARE(effectsImpl->loadedEffects().count(), 1); | 151 | QCOMPARE(effectsImpl->loadedEffects().count(), 1); | ||
154 | QCOMPARE(effectsImpl->loadedEffects().first(), effectName); | 152 | QCOMPARE(effectsImpl->loadedEffects().first(), effectName); | ||
155 | Effect *effect = effectsImpl->findEffect(effectName); | 153 | Effect *effect = effectsImpl->findEffect(effectName); | ||
156 | QVERIFY(effect); | 154 | QVERIFY(effect); | ||
157 | QVERIFY(!effect->isActive()); | 155 | QVERIFY(!effect->isActive()); | ||
158 | 156 | | |||
159 | // Maximize the client. | 157 | // Maximize the client. | ||
160 | QSignalSpy frameGeometryChangedSpy(client, &XdgShellClient::frameGeometryChanged); | 158 | QSignalSpy frameGeometryChangedSpy(client, &AbstractClient::frameGeometryChanged); | ||
161 | QVERIFY(frameGeometryChangedSpy.isValid()); | 159 | QVERIFY(frameGeometryChangedSpy.isValid()); | ||
162 | QSignalSpy maximizeChangedSpy(client, qOverload<AbstractClient *, bool, bool>(&XdgShellClient::clientMaximizedStateChanged)); | 160 | QSignalSpy maximizeChangedSpy(client, qOverload<AbstractClient *, bool, bool>(&AbstractClient::clientMaximizedStateChanged)); | ||
163 | QVERIFY(maximizeChangedSpy.isValid()); | 161 | QVERIFY(maximizeChangedSpy.isValid()); | ||
164 | 162 | | |||
165 | workspace()->slotWindowMaximize(); | 163 | workspace()->slotWindowMaximize(); | ||
166 | QVERIFY(configureRequestedSpy.wait()); | 164 | QVERIFY(configureRequestedSpy.wait()); | ||
167 | QCOMPARE(configureRequestedSpy.count(), 3); | 165 | QCOMPARE(configureRequestedSpy.count(), 3); | ||
168 | QCOMPARE(configureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024)); | 166 | QCOMPARE(configureRequestedSpy.last().at(0).value<QSize>(), QSize(1280, 1024)); | ||
169 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | 167 | states = configureRequestedSpy.last().at(1).value<XdgShellSurface::States>(); | ||
170 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | 168 | QVERIFY(states.testFlag(XdgShellSurface::State::Activated)); | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |