Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/effects/toplevel_open_close_animation_test.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "abstract_client.h" | 23 | #include "abstract_client.h" | ||
24 | #include "composite.h" | 24 | #include "composite.h" | ||
25 | #include "deleted.h" | 25 | #include "deleted.h" | ||
26 | #include "effectloader.h" | 26 | #include "effectloader.h" | ||
27 | #include "effects.h" | 27 | #include "effects.h" | ||
28 | #include "platform.h" | 28 | #include "platform.h" | ||
29 | #include "scene.h" | 29 | #include "scene.h" | ||
30 | #include "shell_client.h" | 30 | #include "xdgshellclient.h" | ||
31 | #include "wayland_server.h" | 31 | #include "wayland_server.h" | ||
32 | #include "workspace.h" | 32 | #include "workspace.h" | ||
33 | 33 | | |||
34 | #include "effect_builtins.h" | 34 | #include "effect_builtins.h" | ||
35 | 35 | | |||
36 | #include <KWayland/Client/surface.h> | 36 | #include <KWayland/Client/surface.h> | ||
37 | #include <KWayland/Client/xdgshell.h> | 37 | #include <KWayland/Client/xdgshell.h> | ||
38 | 38 | | |||
Show All 17 Lines | |||||
56 | }; | 56 | }; | ||
57 | 57 | | |||
58 | void ToplevelOpenCloseAnimationTest::initTestCase() | 58 | void ToplevelOpenCloseAnimationTest::initTestCase() | ||
59 | { | 59 | { | ||
60 | qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); | 60 | qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); | ||
61 | 61 | | |||
62 | qRegisterMetaType<KWin::AbstractClient *>(); | 62 | qRegisterMetaType<KWin::AbstractClient *>(); | ||
63 | qRegisterMetaType<KWin::Deleted *>(); | 63 | qRegisterMetaType<KWin::Deleted *>(); | ||
64 | qRegisterMetaType<KWin::ShellClient *>(); | 64 | qRegisterMetaType<KWin::XdgShellClient *>(); | ||
65 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 65 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
66 | QVERIFY(workspaceCreatedSpy.isValid()); | 66 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
67 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 67 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
68 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 68 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
69 | 69 | | |||
70 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | 70 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||
71 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | 71 | KConfigGroup plugins(config, QStringLiteral("Plugins")); | ||
72 | ScriptedEffectLoader loader; | 72 | ScriptedEffectLoader loader; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 117 | { | |||
132 | QVERIFY(!effect->isActive()); | 132 | QVERIFY(!effect->isActive()); | ||
133 | 133 | | |||
134 | // Create the test client. | 134 | // Create the test client. | ||
135 | using namespace KWayland::Client; | 135 | using namespace KWayland::Client; | ||
136 | QScopedPointer<Surface> surface(Test::createSurface()); | 136 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
137 | QVERIFY(!surface.isNull()); | 137 | QVERIFY(!surface.isNull()); | ||
138 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 138 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
139 | QVERIFY(!shellSurface.isNull()); | 139 | QVERIFY(!shellSurface.isNull()); | ||
140 | ShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 140 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
141 | QVERIFY(client); | 141 | QVERIFY(client); | ||
142 | QVERIFY(effect->isActive()); | 142 | QVERIFY(effect->isActive()); | ||
143 | 143 | | |||
144 | // Eventually, the animation will be complete. | 144 | // Eventually, the animation will be complete. | ||
145 | QTRY_VERIFY(!effect->isActive()); | 145 | QTRY_VERIFY(!effect->isActive()); | ||
146 | 146 | | |||
147 | // Close the test client, the effect should start animating the disappearing | 147 | // Close the test client, the effect should start animating the disappearing | ||
148 | // of the client. | 148 | // of the client. | ||
149 | QSignalSpy windowClosedSpy(client, &ShellClient::windowClosed); | 149 | QSignalSpy windowClosedSpy(client, &XdgShellClient::windowClosed); | ||
150 | QVERIFY(windowClosedSpy.isValid()); | 150 | QVERIFY(windowClosedSpy.isValid()); | ||
151 | shellSurface.reset(); | 151 | shellSurface.reset(); | ||
152 | surface.reset(); | 152 | surface.reset(); | ||
153 | QVERIFY(windowClosedSpy.wait()); | 153 | QVERIFY(windowClosedSpy.wait()); | ||
154 | QVERIFY(effect->isActive()); | 154 | QVERIFY(effect->isActive()); | ||
155 | 155 | | |||
156 | // Eventually, the animation will be complete. | 156 | // Eventually, the animation will be complete. | ||
157 | QTRY_VERIFY(!effect->isActive()); | 157 | QTRY_VERIFY(!effect->isActive()); | ||
Show All 18 Lines | 170 | { | |||
176 | QVERIFY(effectsImpl); | 176 | QVERIFY(effectsImpl); | ||
177 | 177 | | |||
178 | // Create the main window. | 178 | // Create the main window. | ||
179 | using namespace KWayland::Client; | 179 | using namespace KWayland::Client; | ||
180 | QScopedPointer<Surface> mainWindowSurface(Test::createSurface()); | 180 | QScopedPointer<Surface> mainWindowSurface(Test::createSurface()); | ||
181 | QVERIFY(!mainWindowSurface.isNull()); | 181 | QVERIFY(!mainWindowSurface.isNull()); | ||
182 | QScopedPointer<XdgShellSurface> mainWindowShellSurface(Test::createXdgShellStableSurface(mainWindowSurface.data())); | 182 | QScopedPointer<XdgShellSurface> mainWindowShellSurface(Test::createXdgShellStableSurface(mainWindowSurface.data())); | ||
183 | QVERIFY(!mainWindowShellSurface.isNull()); | 183 | QVERIFY(!mainWindowShellSurface.isNull()); | ||
184 | ShellClient *mainWindow = Test::renderAndWaitForShown(mainWindowSurface.data(), QSize(100, 50), Qt::blue); | 184 | XdgShellClient *mainWindow = Test::renderAndWaitForShown(mainWindowSurface.data(), QSize(100, 50), Qt::blue); | ||
185 | QVERIFY(mainWindow); | 185 | QVERIFY(mainWindow); | ||
186 | 186 | | |||
187 | // Load effect that will be tested. | 187 | // Load effect that will be tested. | ||
188 | QFETCH(QString, effectName); | 188 | QFETCH(QString, effectName); | ||
189 | QVERIFY(effectsImpl->loadEffect(effectName)); | 189 | QVERIFY(effectsImpl->loadEffect(effectName)); | ||
190 | QCOMPARE(effectsImpl->loadedEffects().count(), 1); | 190 | QCOMPARE(effectsImpl->loadedEffects().count(), 1); | ||
191 | QCOMPARE(effectsImpl->loadedEffects().first(), effectName); | 191 | QCOMPARE(effectsImpl->loadedEffects().first(), effectName); | ||
192 | Effect *effect = effectsImpl->findEffect(effectName); | 192 | Effect *effect = effectsImpl->findEffect(effectName); | ||
193 | QVERIFY(effect); | 193 | QVERIFY(effect); | ||
194 | QVERIFY(!effect->isActive()); | 194 | QVERIFY(!effect->isActive()); | ||
195 | 195 | | |||
196 | // Create a popup, it should not be animated. | 196 | // Create a popup, it should not be animated. | ||
197 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | 197 | QScopedPointer<Surface> popupSurface(Test::createSurface()); | ||
198 | QVERIFY(!popupSurface.isNull()); | 198 | QVERIFY(!popupSurface.isNull()); | ||
199 | XdgPositioner positioner(QSize(20, 20), QRect(0, 0, 10, 10)); | 199 | XdgPositioner positioner(QSize(20, 20), QRect(0, 0, 10, 10)); | ||
200 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 200 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
201 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::LeftEdge); | 201 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::LeftEdge); | ||
202 | QScopedPointer<XdgShellPopup> popupShellSurface(Test::createXdgShellStablePopup(popupSurface.data(), mainWindowShellSurface.data(), positioner)); | 202 | QScopedPointer<XdgShellPopup> popupShellSurface(Test::createXdgShellStablePopup(popupSurface.data(), mainWindowShellSurface.data(), positioner)); | ||
203 | QVERIFY(!popupShellSurface.isNull()); | 203 | QVERIFY(!popupShellSurface.isNull()); | ||
204 | ShellClient *popup = Test::renderAndWaitForShown(popupSurface.data(), positioner.initialSize(), Qt::red); | 204 | XdgShellClient *popup = Test::renderAndWaitForShown(popupSurface.data(), positioner.initialSize(), Qt::red); | ||
205 | QVERIFY(popup); | 205 | QVERIFY(popup); | ||
206 | QVERIFY(popup->isPopupWindow()); | 206 | QVERIFY(popup->isPopupWindow()); | ||
207 | QCOMPARE(popup->transientFor(), mainWindow); | 207 | QCOMPARE(popup->transientFor(), mainWindow); | ||
208 | QVERIFY(!effect->isActive()); | 208 | QVERIFY(!effect->isActive()); | ||
209 | 209 | | |||
210 | // Destroy the popup, it should not be animated. | 210 | // Destroy the popup, it should not be animated. | ||
211 | QSignalSpy popupClosedSpy(popup, &ShellClient::windowClosed); | 211 | QSignalSpy popupClosedSpy(popup, &XdgShellClient::windowClosed); | ||
212 | QVERIFY(popupClosedSpy.isValid()); | 212 | QVERIFY(popupClosedSpy.isValid()); | ||
213 | popupShellSurface.reset(); | 213 | popupShellSurface.reset(); | ||
214 | popupSurface.reset(); | 214 | popupSurface.reset(); | ||
215 | QVERIFY(popupClosedSpy.wait()); | 215 | QVERIFY(popupClosedSpy.wait()); | ||
216 | QVERIFY(!effect->isActive()); | 216 | QVERIFY(!effect->isActive()); | ||
217 | 217 | | |||
218 | // Destroy the main window. | 218 | // Destroy the main window. | ||
219 | mainWindowSurface.reset(); | 219 | mainWindowSurface.reset(); | ||
220 | QVERIFY(Test::waitForWindowDestroyed(mainWindow)); | 220 | QVERIFY(Test::waitForWindowDestroyed(mainWindow)); | ||
221 | } | 221 | } | ||
222 | 222 | | |||
223 | WAYLANDTEST_MAIN(ToplevelOpenCloseAnimationTest) | 223 | WAYLANDTEST_MAIN(ToplevelOpenCloseAnimationTest) | ||
224 | #include "toplevel_open_close_animation_test.moc" | 224 | #include "toplevel_open_close_animation_test.moc" |