From 33624629d36acd63b5179e39a288df960e348955 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 7 Jul 2017 16:55:24 +0200 Subject: Fix test for highdpi systems In this specific case, the original image is rendered at 212x300. If it is then scales (preserving aspect ratio) to 200x200, the width "should be" (212/300)*200 = 141.333.. Now when the backing store is not using highdpi, it will be rendered at 1x, so the width gets rounded to 141. However, if the backing store renders it at (say) 2x (so width 282.66..) it gets rounded to 283, which is then divided by 2, which makes 141.5. By rounding the width down, the result is always the same as on non-highdpi. Change-Id: I8c967edf60ddbe97496cfb3d561357887a177d3f Reviewed-by: Simon Hausmann --- tests/auto/quick/qquickimage/tst_qquickimage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index e439db543f..115fe53430 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -398,11 +398,11 @@ void tst_qquickimage::svg() component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QQuickImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QCOMPARE(obj->width(), 212.0); + QCOMPARE(int(obj->width()), 212); // round down: highdpi can give back fractional values QCOMPARE(obj->height(), 300.0); obj->setSourceSize(QSize(200,200)); - QCOMPARE(obj->width(), 141.0); + QCOMPARE(int(obj->width()), 141); // round down: highdpi can give back fractional values QCOMPARE(obj->height(), 200.0); delete obj; } -- cgit v1.2.3