diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-10-14 11:32:01 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-10-18 12:39:29 +0200 |
commit | 27027a5424ed2e797ecfa30239bfdb6f89eee0a1 (patch) | |
tree | 0d0f8ca687eaf0fcc9513b25c35ddf93face758e /tests/auto/quick/qquickwindow | |
parent | 45d8ea9e663a16c59ee5594b2e6dd95d4737b592 (diff) |
Fix tst_qquickwindow::grab with non-integer dpr
Do not introduce yet another way of calculating the scaled size.
Truncating the width * dpr and height * dpr is separately not the
same as doing size * dpr (because that rounds). And it is the
latter that is used everywhere.
This makes the case not fail anymore with device pixel ratios such
as 1.25.
Pick-to: 6.2
Change-Id: Id5d7b1799977967b3110925bf7ccd0417c6bdaa9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickwindow')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index e1f3d19b00..f88ce43c9b 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1528,8 +1528,7 @@ void tst_qquickwindow::grab() } QImage content = window.grabWindow(); - QCOMPARE(content.width(), int(window.width() * window.devicePixelRatio())); - QCOMPARE(content.height(), int(window.height() * window.devicePixelRatio())); + QCOMPARE(content.size(), window.size() * window.devicePixelRatio()); if (alpha) { QCOMPARE((uint) content.convertToFormat(QImage::Format_ARGB32_Premultiplied).pixel(0, 0), (uint) 0x00000000); @@ -1544,8 +1543,7 @@ void tst_qquickwindow::grab() // never was renderable before grabbing. window.hide(); QImage content = window.grabWindow(); - QCOMPARE(content.width(), int(window.width() * window.devicePixelRatio())); - QCOMPARE(content.height(), int(window.height() * window.devicePixelRatio())); + QCOMPARE(content.size(), window.size() * window.devicePixelRatio()); if (alpha) { QCOMPARE((uint) content.convertToFormat(QImage::Format_ARGB32_Premultiplied).pixel(0, 0), (uint) 0x00000000); } else { @@ -1556,8 +1554,7 @@ void tst_qquickwindow::grab() window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); content = window.grabWindow(); - QCOMPARE(content.width(), int(window.width() * window.devicePixelRatio())); - QCOMPARE(content.height(), int(window.height() * window.devicePixelRatio())); + QCOMPARE(content.size(), window.size() * window.devicePixelRatio()); if (alpha) { QCOMPARE((uint) content.convertToFormat(QImage::Format_ARGB32_Premultiplied).pixel(0, 0), (uint) 0x00000000); } else { |