diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-19 17:12:28 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-20 14:47:41 +0200 |
commit | 9d866a5a0379fb8bdac39f60360e9e6004eb33a2 (patch) | |
tree | a25ba47ea9a8f8b972327aebeee32caba8dad7f7 /tests/auto/quick | |
parent | d27705d1d3e76ad9342928dba47fcf5e273a5e9e (diff) |
tst_qquickimage: Fix test when running on HighDPI screen
Change-Id: I3018355df2a69c7d5a80d18d3d58ac365f1c0b49
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquickimage/tst_qquickimage.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index f5b0fd7d62..8e016bd014 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -904,6 +904,12 @@ void tst_qquickimage::sourceClipRect_data() << (QList<QPoint>() << QPoint(54, 54) << QPoint(15, 59)); } +static QImage toUnscaledImage(const QImage &image) +{ + auto dpr = image.devicePixelRatio(); + return image.scaled(image.width() / dpr, image.height() / dpr); +} + void tst_qquickimage::sourceClipRect() { QFETCH(QRectF, sourceClipRect); @@ -931,7 +937,7 @@ void tst_qquickimage::sourceClipRect() if ((QGuiApplication::platformName() == QLatin1String("offscreen")) || (QGuiApplication::platformName() == QLatin1String("minimal"))) QSKIP("Skipping due to grabWindow not functional on offscreen/minimal platforms"); - QImage contents = window->grabWindow(); + QImage contents = toUnscaledImage(window->grabWindow()); if (contents.width() < sourceClipRect.width()) QSKIP("Skipping due to grabWindow not functional"); #ifdef DEBUG_WRITE_OUTPUT @@ -1167,7 +1173,7 @@ void tst_qquickimage::hugeImages() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QImage contents = view.grabWindow(); + QImage contents = toUnscaledImage(view.grabWindow()); QCOMPARE(contents.pixel(0, 0), qRgba(255, 0, 0, 255)); QCOMPARE(contents.pixel(99, 99), qRgba(255, 0, 0, 255)); @@ -1240,7 +1246,7 @@ void tst_qquickimage::multiFrame() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - QImage contents = view.grabWindow(); + QImage contents = toUnscaledImage(view.grabWindow()); if (contents.width() < 40) QSKIP("Skipping due to grabWindow not functional"); // The first frame is a blue ball, approximately qRgba(0x33, 0x6d, 0xcc, 0xff) @@ -1253,7 +1259,7 @@ void tst_qquickimage::multiFrame() QTRY_COMPARE(image->status(), QQuickImageBase::Ready); QCOMPARE(currentSpy.count(), 1); QCOMPARE(image->currentFrame(), 1); - contents = view.grabWindow(); + contents = toUnscaledImage(view.grabWindow()); // The second frame is a green ball, approximately qRgba(0x27, 0xc8, 0x22, 0xff) color = contents.pixel(16, 16); QVERIFY(qRed(color) < 0xc0); |