Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/scene_qpainter_test.cpp
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | 163 | { | |||
---|---|---|---|---|---|
177 | QVERIFY(frameRenderedSpy.isValid()); | 177 | QVERIFY(frameRenderedSpy.isValid()); | ||
178 | 178 | | |||
179 | // now let's map the window | 179 | // now let's map the window | ||
180 | QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue)); | 180 | QVERIFY(Test::renderAndWaitForShown(s.data(), QSize(200, 300), Qt::blue)); | ||
181 | // which should trigger a frame | 181 | // which should trigger a frame | ||
182 | if (frameRenderedSpy.isEmpty()) { | 182 | if (frameRenderedSpy.isEmpty()) { | ||
183 | QVERIFY(frameRenderedSpy.wait()); | 183 | QVERIFY(frameRenderedSpy.wait()); | ||
184 | } | 184 | } | ||
185 | // we didn't set a cursor image on the surface yet, so it should be just black + window | 185 | // we didn't set a cursor image on the surface yet, so it should be just black + window and previous cursor | ||
186 | QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32); | 186 | QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32); | ||
187 | referenceImage.fill(Qt::black); | 187 | referenceImage.fill(Qt::black); | ||
188 | QPainter painter(&referenceImage); | 188 | QPainter painter(&referenceImage); | ||
189 | painter.fillRect(0, 0, 200, 300, Qt::blue); | 189 | painter.fillRect(0, 0, 200, 300, Qt::blue); | ||
190 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | | |||
191 | 190 | | |||
192 | // now let's set a cursor image | 191 | // now let's set a cursor image | ||
193 | QScopedPointer<Surface> cs(Test::createSurface()); | 192 | QScopedPointer<Surface> cs(Test::createSurface()); | ||
194 | QVERIFY(!cs.isNull()); | 193 | QVERIFY(!cs.isNull()); | ||
195 | Test::render(cs.data(), QSize(10, 10), Qt::red); | 194 | Test::render(cs.data(), QSize(10, 10), Qt::red); | ||
196 | p->setCursor(cs.data(), QPoint(5, 5)); | 195 | p->setCursor(cs.data(), QPoint(5, 5)); | ||
197 | QVERIFY(frameRenderedSpy.wait()); | 196 | QVERIFY(frameRenderedSpy.wait()); | ||
198 | painter.fillRect(KWin::Cursor::pos().x() - 5, KWin::Cursor::pos().y() - 5, 10, 10, Qt::red); | 197 | painter.fillRect(KWin::Cursor::pos().x() - 5, KWin::Cursor::pos().y() - 5, 10, 10, Qt::red); | ||
Show All 11 Lines | 208 | { | |||
210 | KWin::Cursor::setPos(10, 10); | 209 | KWin::Cursor::setPos(10, 10); | ||
211 | // this test verifies that a window is rendered correctly | 210 | // this test verifies that a window is rendered correctly | ||
212 | using namespace KWayland::Client; | 211 | using namespace KWayland::Client; | ||
213 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | 212 | QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); | ||
214 | QVERIFY(Test::waitForWaylandPointer()); | 213 | QVERIFY(Test::waitForWaylandPointer()); | ||
215 | QScopedPointer<Surface> s(Test::createSurface()); | 214 | QScopedPointer<Surface> s(Test::createSurface()); | ||
216 | QScopedPointer<ShellSurface> ss(Test::createShellSurface(s.data())); | 215 | QScopedPointer<ShellSurface> ss(Test::createShellSurface(s.data())); | ||
217 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | 216 | QScopedPointer<Pointer> p(Test::waylandSeat()->createPointer()); | ||
217 | QSignalSpy pointerEnteredSpy(p.data(), &Pointer::entered); | ||||
218 | QVERIFY(pointerEnteredSpy.isValid()); | ||||
218 | 219 | | |||
219 | auto scene = KWin::Compositor::self()->scene(); | 220 | auto scene = KWin::Compositor::self()->scene(); | ||
220 | QVERIFY(scene); | 221 | QVERIFY(scene); | ||
221 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | 222 | QSignalSpy frameRenderedSpy(scene, &Scene::frameRendered); | ||
222 | QVERIFY(frameRenderedSpy.isValid()); | 223 | QVERIFY(frameRenderedSpy.isValid()); | ||
223 | 224 | | |||
224 | // now let's set a cursor image | 225 | // now let's set a cursor image | ||
225 | QScopedPointer<Surface> cs(Test::createSurface()); | 226 | QScopedPointer<Surface> cs(Test::createSurface()); | ||
226 | QVERIFY(!cs.isNull()); | 227 | QVERIFY(!cs.isNull()); | ||
227 | Test::render(cs.data(), QSize(10, 10), Qt::red); | 228 | Test::render(cs.data(), QSize(10, 10), Qt::red); | ||
228 | p->setCursor(cs.data(), QPoint(5, 5)); | | |||
229 | 229 | | |||
230 | // now let's map the window | 230 | // now let's map the window | ||
231 | s->setScale(2); | 231 | s->setScale(2); | ||
232 | 232 | | |||
233 | //draw a blue square@400x600 with red rectangle@200x200 in the middle | 233 | //draw a blue square@400x600 with red rectangle@200x200 in the middle | ||
234 | const QSize size(400,600); | 234 | const QSize size(400,600); | ||
235 | QImage img(size, QImage::Format_ARGB32_Premultiplied); | 235 | QImage img(size, QImage::Format_ARGB32_Premultiplied); | ||
236 | img.fill(Qt::blue); | 236 | img.fill(Qt::blue); | ||
237 | QPainter surfacePainter(&img); | 237 | QPainter surfacePainter(&img); | ||
238 | surfacePainter.fillRect(200,300,200,200, Qt::red); | 238 | surfacePainter.fillRect(200,300,200,200, Qt::red); | ||
239 | 239 | | |||
240 | //add buffer | 240 | //add buffer | ||
241 | Test::render(s.data(), img); | 241 | Test::render(s.data(), img); | ||
242 | Test::waitForWaylandWindowShown(); | 242 | QVERIFY(pointerEnteredSpy.wait()); | ||
243 | p->setCursor(cs.data(), QPoint(5, 5)); | ||||
243 | 244 | | |||
244 | // which should trigger a frame | 245 | // which should trigger a frame | ||
245 | if (frameRenderedSpy.isEmpty()) { | | |||
246 | QVERIFY(frameRenderedSpy.wait()); | 246 | QVERIFY(frameRenderedSpy.wait()); | ||
247 | } | | |||
248 | QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32); | 247 | QImage referenceImage(QSize(1280, 1024), QImage::Format_RGB32); | ||
249 | referenceImage.fill(Qt::black); | 248 | referenceImage.fill(Qt::black); | ||
250 | QPainter painter(&referenceImage); | 249 | QPainter painter(&referenceImage); | ||
251 | painter.fillRect(0, 0, 200, 300, Qt::blue); | 250 | painter.fillRect(0, 0, 200, 300, Qt::blue); | ||
252 | painter.fillRect(100, 150, 100, 100, Qt::red); | 251 | painter.fillRect(100, 150, 100, 100, Qt::red); | ||
253 | painter.fillRect(5, 5, 10, 10, Qt::red); //cursor | 252 | painter.fillRect(5, 5, 10, 10, Qt::red); //cursor | ||
254 | 253 | | |||
255 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | 254 | QCOMPARE(referenceImage, *scene->qpainterRenderBuffer()); | ||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |