aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
diff options
context:
space:
mode:
authorRiku Palomäki <riku@palomaki.fi>2015-10-21 22:13:19 +0300
committerShawn Rutledge <shawn.rutledge@qt.io>2016-08-18 13:36:44 +0000
commit96bd2337a98c892b5def555163c491507dce7185 (patch)
tree83fe9de9c7a6f873c84fde54ba96ab0443bba62b /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
parentb5f9c1e6e7f3a6881874e4ec2f43cea68107a06b (diff)
Flickable: Fixed rounding errors with contentX/Y
contentX/Y are qreals, but they are rounded using qRound/qFloor/qCeil which will limit the values to 2^31 needlessly. This fix will use (std::)round, std::floor and std::ceil instead to allow bigger values for contentX and contentY. Change-Id: I35ad4bcfa3b8bbc21e90768d348d3002ca400081 Task-number: QTBUG-48018 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index e1678b9acd..a03e3b8170 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -91,6 +91,7 @@ private slots:
void cleanup();
void contentSize();
void ratios_smallContent();
+ void contentXYNotTruncatedToInt();
private:
void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
@@ -1841,6 +1842,26 @@ void tst_qquickflickable::ratios_smallContent()
QCOMPARE(obj->property("widthRatioIs").toDouble(), 1.);
}
+// QTBUG-48018
+void tst_qquickflickable::contentXYNotTruncatedToInt()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("contentXY.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable);
+
+ flickable->setContentX(1e10);
+ flick(window.data(), QPoint(200, 100), QPoint(100, 100), 50);
+
+ // make sure we are not clipped at 2^31
+ QVERIFY(flickable->contentX() > qreal(1e10));
+}
QTEST_MAIN(tst_qquickflickable)