From f5ae7e4f8109a37c5bfab912ba0859f91ecac608 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 12 May 2016 15:54:58 +0200 Subject: 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 --- tests/auto/quick/qquicktext/tst_qquicktext.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/auto/quick/qquicktext/tst_qquicktext.cpp') 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; -- cgit v1.2.3