aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-05-12 15:54:58 +0200
committerMitch Curtis <mitch.curtis@qt.io>2016-05-12 19:08:51 +0000
commitf5ae7e4f8109a37c5bfab912ba0859f91ecac608 (patch)
treed5220d3518d9e2813fcb2dec73d1e7f1b405104c
parented7d33ebcddc617a7e0197aa559e2fb15ce7a172 (diff)
Fix tst_qquicktext::hAlignImplicitWidth() on high DPI displays
The test assumed that the grabbed image of the window was the same size as what was specified in QML, but QQuickWindow::grabWindow() returns an image that is scaled by the screen's devicePixelRatio. Change-Id: I5b361edb28bec562c7f528d06892277dcbe5769f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index 2df70d89ff..46ec099501 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -913,8 +913,10 @@ void tst_qquicktext::hAlignImplicitWidth()
// Try to check whether alignment works by checking the number of black
// pixels in the thirds of the grabbed image.
- const int windowWidth = 220;
- const int textWidth = qCeil(text->implicitWidth());
+ // QQuickWindow::grabWindow() scales the returned image by the devicePixelRatio of the screen.
+ const qreal devicePixelRatio = view.screen()->devicePixelRatio();
+ const int windowWidth = 220 * devicePixelRatio;
+ const int textWidth = qCeil(text->implicitWidth()) * devicePixelRatio;
QVERIFY2(textWidth < windowWidth, "System font too large.");
const int sectionWidth = textWidth / 3;
const int centeredSection1 = (windowWidth - textWidth) / 2;