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