aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-02-25 11:57:50 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-02-25 11:57:50 +0100
commit15dc45ce109fe41699950a9b87282901b21f2d3d (patch)
tree809e79e7b55988006bb3d990168b2bb7eda360b5 /tests/auto/quick/qquickflickable
parentcf53bf9ae6716613c120cc4a0202c69bd59eba1e (diff)
parenta496e0874858a4b7d991c179c0e12df46c3d324c (diff)
Merge remote-tracking branch 'origin/stable' into dev
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml37
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp71
2 files changed, 108 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml
new file mode 100644
index 0000000000..59318e5b95
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml
@@ -0,0 +1,37 @@
+import QtQuick 2.0
+
+Flickable {
+ id: outer
+ objectName: "outerFlickable"
+ width: 400
+ height: 400
+ contentX: 50
+ contentY: 50
+ contentWidth: 500
+ contentHeight: 500
+ flickableDirection: inner.flickableDirection
+
+ Rectangle {
+ x: 100
+ y: 100
+ width: 300
+ height: 300
+
+ color: "yellow"
+ Flickable {
+ id: inner
+ objectName: "innerFlickable"
+ anchors.fill: parent
+ contentX: 100
+ contentY: 100
+ contentWidth: 400
+ contentHeight: 400
+ boundsBehavior: Flickable.StopAtBounds
+ Rectangle {
+ anchors.fill: parent
+ anchors.margins: 100
+ color: "blue"
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 9645aaaab3..875ade45b8 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -91,6 +91,8 @@ private slots:
void cancelOnMouseGrab();
void clickAndDragWhenTransformed();
void flickTwiceUsingTouches();
+ void nestedStopAtBounds();
+ void nestedStopAtBounds_data();
private:
void flickWithTouch(QWindow *window, QTouchDevice *touchDevice);
@@ -1308,6 +1310,75 @@ void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDev
QTest::qWait(1);
}
+void tst_qquickflickable::nestedStopAtBounds_data()
+{
+ QTest::addColumn<bool>("transpose");
+ QTest::addColumn<bool>("invert");
+
+ QTest::newRow("left") << false << false;
+ QTest::newRow("right") << false << true;
+ QTest::newRow("top") << true << false;
+ QTest::newRow("bottom") << true << true;
+}
+
+void tst_qquickflickable::nestedStopAtBounds()
+{
+ QFETCH(bool, transpose);
+ QFETCH(bool, invert);
+
+ QQuickView view;
+ view.setSource(testFileUrl("nestedStopAtBounds.qml"));
+ view.show();
+ view.requestActivate();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(view.rootObject());
+
+ QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(view.rootObject());
+ QVERIFY(outer);
+
+ QQuickFlickable *inner = outer->findChild<QQuickFlickable*>("innerFlickable");
+ QVERIFY(inner);
+ inner->setFlickableDirection(transpose ? QQuickFlickable::VerticalFlick : QQuickFlickable::HorizontalFlick);
+ inner->setContentX(invert ? 0 : 100);
+ inner->setContentY(invert ? 0 : 100);
+
+ const int threshold = qApp->styleHints()->startDragDistance();
+
+ QPoint position(200, 200);
+ int &axis = transpose ? position.ry() : position.rx();
+
+ // drag toward the aligned boundary. Outer flickable dragged.
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ axis += invert ? threshold * 2 : -threshold * 2;
+ QTest::mouseMove(&view, position);
+ axis += invert ? threshold : -threshold;
+ QTest::mouseMove(&view, position);
+ QCOMPARE(outer->isDragging(), true);
+ QCOMPARE(inner->isDragging(), false);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QVERIFY(!outer->isDragging());
+ QTRY_VERIFY(!outer->isMoving());
+
+ axis = 200;
+ outer->setContentX(50);
+ outer->setContentY(50);
+
+ // drag away from the aligned boundary. Inner flickable dragged.
+ QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ QTest::qWait(10);
+ axis += invert ? -threshold * 2 : threshold * 2;
+ QTest::mouseMove(&view, position);
+ axis += invert ? -threshold : threshold;
+ QTest::mouseMove(&view, position);
+ QCOMPARE(outer->isDragging(), false);
+ QCOMPARE(inner->isDragging(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, position);
+
+ QTRY_VERIFY(!outer->isMoving());
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"