Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/scene_qpainter_test.cpp
Show All 26 Lines | |||||
27 | #include "shell_client.h" | 27 | #include "shell_client.h" | ||
28 | #include "wayland_server.h" | 28 | #include "wayland_server.h" | ||
29 | #include "effect_builtins.h" | 29 | #include "effect_builtins.h" | ||
30 | #include "workspace.h" | 30 | #include "workspace.h" | ||
31 | 31 | | |||
32 | #include <KConfigGroup> | 32 | #include <KConfigGroup> | ||
33 | 33 | | |||
34 | #include <KWayland/Client/seat.h> | 34 | #include <KWayland/Client/seat.h> | ||
35 | #include <KWayland/Client/shell.h> | | |||
36 | #include <KWayland/Client/surface.h> | 35 | #include <KWayland/Client/surface.h> | ||
37 | #include <KWayland/Client/pointer.h> | 36 | #include <KWayland/Client/pointer.h> | ||
38 | #include <KWayland/Server/buffer_interface.h> | 37 | #include <KWayland/Server/buffer_interface.h> | ||
39 | #include <KWayland/Server/surface_interface.h> | 38 | #include <KWayland/Server/surface_interface.h> | ||
40 | 39 | | |||
41 | #include <QPainter> | 40 | #include <QPainter> | ||
42 | 41 | | |||
43 | #include <netwm.h> | 42 | #include <netwm.h> | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 125 | { | |||
148 | const QImage cursorImage = kwinApp()->platform()->softwareCursor(); | 147 | const QImage cursorImage = kwinApp()->platform()->softwareCursor(); | ||
149 | QVERIFY(!cursorImage.isNull()); | 148 | QVERIFY(!cursorImage.isNull()); | ||
150 | p.drawImage(QPoint(45, 45) - kwinApp()->platform()->softwareCursorHotspot(), cursorImage); | 149 | p.drawImage(QPoint(45, 45) - kwinApp()->platform()->softwareCursorHotspot(), cursorImage); | ||
151 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | 150 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | ||
152 | } | 151 | } | ||
153 | 152 | | |||
154 | void SceneQPainterTest::testWindow_data() | 153 | void SceneQPainterTest::testWindow_data() | ||
155 | { | 154 | { | ||
156 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 155 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
157 | 156 | | |||
158 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 157 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
159 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 158 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
160 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 159 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
161 | QTest::newRow("xdgWmBase") << Test::ShellSurfaceType::XdgShellStable; | | |||
162 | } | 160 | } | ||
163 | 161 | | |||
164 | void SceneQPainterTest::testWindow() | 162 | void SceneQPainterTest::testWindow() | ||
165 | { | 163 | { | ||
166 | KWin::Cursor::setPos(45, 45); | 164 | KWin::Cursor::setPos(45, 45); | ||
167 | // this test verifies that a window is rendered correctly | 165 | // this test verifies that a window is rendered correctly | ||
168 | using namespace KWayland::Client; | 166 | using namespace KWayland::Client; | ||
169 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | 167 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | ||
170 | QVERIFY(Test::waitForWaylandPointer()); | 168 | QVERIFY(Test::waitForWaylandPointer()); | ||
171 | QScopedPointer<Surface> s(Test::createSurface()); | 169 | QScopedPointer<Surface> s(Test::createSurface()); | ||
172 | QFETCH(Test::ShellSurfaceType, type); | 170 | QFETCH(Test::XdgShellSurfaceType, type); | ||
173 | QScopedPointer<QObject> ss(Test::createShellSurface(type, s.data())); | 171 | QScopedPointer<XdgShellSurface> ss(Test::createXdgShellSurface(type, s.data())); | ||
174 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | 172 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | ||
175 | 173 | | |||
176 | auto scene = KWin::Compositor::self()->scene(); | 174 | auto scene = KWin::Compositor::self()->scene(); | ||
177 | QVERIFY(scene); | 175 | QVERIFY(scene); | ||
178 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | 176 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | ||
179 | QVERIFY(frameRenderedSpy.isValid()); | 177 | QVERIFY(frameRenderedSpy.isValid()); | ||
180 | 178 | | |||
181 | // now let's map the window | 179 | // now let's map the window | ||
Show All 27 Lines | |||||
209 | void SceneQPainterTest::testWindowScaled() | 207 | void SceneQPainterTest::testWindowScaled() | ||
210 | { | 208 | { | ||
211 | KWin::Cursor::setPos(10, 10); | 209 | KWin::Cursor::setPos(10, 10); | ||
212 | // this test verifies that a window is rendered correctly | 210 | // this test verifies that a window is rendered correctly | ||
213 | using namespace KWayland::Client; | 211 | using namespace KWayland::Client; | ||
214 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | 212 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | ||
215 | QVERIFY(Test::waitForWaylandPointer()); | 213 | QVERIFY(Test::waitForWaylandPointer()); | ||
216 | QScopedPointer<Surface> s(Test::createSurface()); | 214 | QScopedPointer<Surface> s(Test::createSurface()); | ||
217 | QScopedPointer<ShellSurface> ss(Test::createShellSurface(s.data())); | 215 | QScopedPointer<XdgShellSurface> ss(Test::createXdgShellStableSurface(s.data())); | ||
218 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | 216 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | ||
219 | QSignalSpy pointerEnteredSpy(p.data(), &Pointer::entered); | 217 | QSignalSpy pointerEnteredSpy(p.data(), &Pointer::entered); | ||
220 | QVERIFY(pointerEnteredSpy.isValid()); | 218 | QVERIFY(pointerEnteredSpy.isValid()); | ||
221 | 219 | | |||
222 | auto scene = KWin::Compositor::self()->scene(); | 220 | auto scene = KWin::Compositor::self()->scene(); | ||
223 | QVERIFY(scene); | 221 | QVERIFY(scene); | ||
224 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | 222 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | ||
225 | QVERIFY(frameRenderedSpy.isValid()); | 223 | QVERIFY(frameRenderedSpy.isValid()); | ||
Show All 27 Lines | |||||
253 | painter.fillRect(100, 150, 100, 100, Qt::red); | 251 | painter.fillRect(100, 150, 100, 100, Qt::red); | ||
254 | painter.fillRect(5, 5, 10, 10, Qt::red); //cursor | 252 | painter.fillRect(5, 5, 10, 10, Qt::red); //cursor | ||
255 | 253 | | |||
256 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | 254 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | ||
257 | } | 255 | } | ||
258 | 256 | | |||
259 | void SceneQPainterTest::testCompositorRestart_data() | 257 | void SceneQPainterTest::testCompositorRestart_data() | ||
260 | { | 258 | { | ||
261 | QTest::addColumn<Test::ShellSurfaceType>("type"); | 259 | QTest::addColumn<Test::XdgShellSurfaceType>("type"); | ||
262 | 260 | | |||
263 | QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; | 261 | QTest::newRow("xdgShellV5") << Test::XdgShellSurfaceType::XdgShellV5; | ||
264 | QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; | 262 | QTest::newRow("xdgShellV6") << Test::XdgShellSurfaceType::XdgShellV6; | ||
265 | QTest::newRow("xdgShellV6") << Test::ShellSurfaceType::XdgShellV6; | 263 | QTest::newRow("xdgWmBase") << Test::XdgShellSurfaceType::XdgShellStable; | ||
266 | } | 264 | } | ||
267 | 265 | | |||
268 | void SceneQPainterTest::testCompositorRestart() | 266 | void SceneQPainterTest::testCompositorRestart() | ||
269 | { | 267 | { | ||
270 | // this test verifies that the compositor/SceneQPainter survive a restart of the compositor and still render correctly | 268 | // this test verifies that the compositor/SceneQPainter survive a restart of the compositor and still render correctly | ||
271 | KWin::Cursor::setPos(400, 400); | 269 | KWin::Cursor::setPos(400, 400); | ||
272 | 270 | | |||
273 | // first create a window | 271 | // first create a window | ||
274 | using namespace KWayland::Client; | 272 | using namespace KWayland::Client; | ||
275 | QVERIFY(Test::setupWaylandConnection()); | 273 | QVERIFY(Test::setupWaylandConnection()); | ||
276 | QScopedPointer<Surface> s(Test::createSurface()); | 274 | QScopedPointer<Surface> s(Test::createSurface()); | ||
277 | QFETCH(Test::ShellSurfaceType, type); | 275 | QFETCH(Test::XdgShellSurfaceType, type); | ||
278 | QScopedPointer<QObject> ss(Test::createShellSurface(type, s.data())); | 276 | QScopedPointer<XdgShellSurface> ss(Test::createXdgShellSurface(type, s.data())); | ||
279 | QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue)); | 277 | QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue)); | ||
280 | 278 | | |||
281 | // now let's try to reinitialize the compositing scene | 279 | // now let's try to reinitialize the compositing scene | ||
282 | auto oldScene = KWin::Compositor::self()->scene(); | 280 | auto oldScene = KWin::Compositor::self()->scene(); | ||
283 | QVERIFY(oldScene); | 281 | QVERIFY(oldScene); | ||
284 | QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &KWin::Compositor::sceneCreated); | 282 | QSignalSpy sceneCreatedSpy(KWin::Compositor::self(), &KWin::Compositor::sceneCreated); | ||
285 | QVERIFY(sceneCreatedSpy.isValid()); | 283 | QVERIFY(sceneCreatedSpy.isValid()); | ||
286 | KWin::Compositor::self()->reinitialize(); | 284 | KWin::Compositor::self()->reinitialize(); | ||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |