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>
This commit is contained in:
Mitch Curtis 2016-05-12 15:54:58 +02:00
parent ed7d33ebcd
commit f5ae7e4f81
1 changed files with 4 additions and 2 deletions

View File

@ -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;