aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgflickable/data/flickable03.qml2
-rw-r--r--tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp48
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml2
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp49
4 files changed, 99 insertions, 2 deletions
diff --git a/tests/auto/declarative/qsgflickable/data/flickable03.qml b/tests/auto/declarative/qsgflickable/data/flickable03.qml
index e34b63b6ac..ebc49ba90a 100644
--- a/tests/auto/declarative/qsgflickable/data/flickable03.qml
+++ b/tests/auto/declarative/qsgflickable/data/flickable03.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
Flickable {
- width: 100; height: 100
+ width: 100; height: 200
contentWidth: column.width; contentHeight: column.height
Column {
diff --git a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
index 0b9fdf0004..d12008f5b7 100644
--- a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
+++ b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
@@ -79,10 +79,12 @@ private slots:
void wheel();
void movingAndDragging();
void disabled();
+ void flickVelocity();
private:
QDeclarativeEngine engine;
+ void flick(QSGView *canvas, const QPoint &from, const QPoint &to, int duration);
template<typename T>
T *findItem(QSGItem *parent, const QString &objectName);
};
@@ -545,6 +547,52 @@ void tst_qsgflickable::disabled()
QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
}
+void tst_qsgflickable::flickVelocity()
+{
+#ifdef Q_WS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
+#endif
+
+ QSGView *canvas = new QSGView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QSGFlickable *flickable = qobject_cast<QSGFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ delete canvas;
+}
+
+void tst_qsgflickable::flick(QSGView *canvas, const QPoint &from, const QPoint &to, int duration)
+{
+ const int pointCount = 5;
+ QPoint diff = to - from;
+
+ // send press, five equally spaced moves, and release.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, from);
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas, &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
+}
+
template<typename T>
T *tst_qsgflickable::findItem(QSGItem *parent, const QString &objectName)
{
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
index a3e92fe6a6..8359ad1bb4 100644
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
+++ b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
@@ -1,7 +1,7 @@
import QtQuick 1.0
Flickable {
- width: 100; height: 100
+ width: 100; height: 200
contentWidth: column.width; contentHeight: column.height
Column {
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 80bf71a191..2d8c75ba22 100644
--- a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -79,10 +79,12 @@ private slots:
void testQtQuick11Attributes_data();
void wheel();
void disabled();
+ void flickVelocity();
private:
QDeclarativeEngine engine;
+ void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration);
template<typename T>
T *findItem(QGraphicsObject *parent, const QString &objectName);
};
@@ -514,6 +516,53 @@ void tst_qdeclarativeflickable::disabled()
QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
}
+void tst_qdeclarativeflickable::flickVelocity()
+{
+#ifdef Q_WS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
+#endif
+
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ delete canvas;
+}
+
+void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration)
+{
+ const int pointCount = 5;
+ QPoint diff = to - from;
+
+ // send press, five equally spaced moves, and release.
+ QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from));
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas->viewport(), &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to));
+}
+
+
template<typename T>
T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
{