summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-07-07 16:55:24 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-07-10 08:42:56 +0000
commit33624629d36acd63b5179e39a288df960e348955 (patch)
tree4278eabc6c8f87b6c13b785c37c329f2ba7bdc45
parentb9767f03bdfcc06dae49661150fbeb0f19a8547b (diff)
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 <simon.hausmann@qt.io>
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp4
1 files 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<QQuickImage*>(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;
}