diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:48:12 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:48:12 +0200 |
commit | 7063fefe4b5e866b27001bb9b911fc2f68034e40 (patch) | |
tree | 1ce35139475d83399572a3265414c2da3443a321 /tests/auto/quick/qquickflickable | |
parent | f3446071da8357620d0c8593a04e3b4fbba88f21 (diff) | |
parent | 4f3379352a265bab00a7265f85ffc38a9ca4ffe4 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I11ea57222ba5aa683b7bfd7735fbc1d2cf86e875
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r-- | tests/auto/quick/qquickflickable/data/nestedPressDelay.qml | 10 | ||||
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 78 |
2 files changed, 86 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml index 742656641f..bdb866ce65 100644 --- a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml +++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml @@ -8,12 +8,18 @@ Flickable { contentHeight: 320 flickableDirection: Flickable.HorizontalFlick pressDelay: 10000 - Rectangle { + MouseArea { + objectName: "filteringMouseArea" x: 20 y: 20 width: 400 height: 300 - color: "yellow" + drag.filterChildren: true + Rectangle { + id: rectangle + color: "yellow" + anchors.fill: parent + } Flickable { objectName: "innerFlickable" anchors.fill: parent diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index eee7ffe560..dc7171746c 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -67,6 +67,7 @@ private slots: void flickDeceleration(); void pressDelay(); void nestedPressDelay(); + void filterReplayedPress(); void nestedClickThenFlick(); void flickableDirection(); void resizeContent(); @@ -93,6 +94,7 @@ private slots: void pressDelayWithLoader(); void movementFromProgrammaticFlick(); void cleanup(); + void contentSize(); private: void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); @@ -521,6 +523,48 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150)); } +void tst_qquickflickable::filterReplayedPress() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("nestedPressDelay.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(outer != 0); + + QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable"); + QVERIFY(inner != 0); + + QQuickItem *filteringMouseArea = outer->findChild<QQuickItem *>("filteringMouseArea"); + QVERIFY(filteringMouseArea); + + moveAndPress(window.data(), QPoint(150, 150)); + // the MouseArea filtering the Flickable is pressed immediately. + QCOMPARE(filteringMouseArea->property("pressed").toBool(), true); + + // Some event causes the mouse area to set keepMouseGrab. + filteringMouseArea->setKeepMouseGrab(true); + QCOMPARE(filteringMouseArea->keepMouseGrab(), true); + + // The inner pressDelay will prevail (50ms, vs. 10sec) + // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. + QTRY_VERIFY(outer->property("pressed").toBool()); + + // The replayed press event isn't delivered to parent items of the + // flickable with the press delay, and the state of the parent mouse + // area is therefore unaffected. + QCOMPARE(filteringMouseArea->property("pressed").toBool(), true); + QCOMPARE(filteringMouseArea->keepMouseGrab(), true); + + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); +} + + // QTBUG-37316 void tst_qquickflickable::nestedClickThenFlick() { @@ -1739,6 +1783,40 @@ void tst_qquickflickable::movementFromProgrammaticFlick() QTRY_COMPARE(flickable->property("signalString").toString(), QString("msfsfeme")); } +// QTBUG_35038 +void tst_qquickflickable::contentSize() +{ + QQuickFlickable flickable; + QCOMPARE(flickable.contentWidth(), qreal(-1)); + QCOMPARE(flickable.contentHeight(), qreal(-1)); + + QSignalSpy cwspy(&flickable, SIGNAL(contentWidthChanged())); + QVERIFY(cwspy.isValid()); + + QSignalSpy chspy(&flickable, SIGNAL(contentHeightChanged())); + QVERIFY(chspy.isValid()); + + flickable.setWidth(100); + QCOMPARE(flickable.width(), qreal(100)); + QCOMPARE(flickable.contentWidth(), qreal(-1.0)); + QCOMPARE(cwspy.count(), 0); + + flickable.setContentWidth(10); + QCOMPARE(flickable.width(), qreal(100)); + QCOMPARE(flickable.contentWidth(), qreal(10)); + QCOMPARE(cwspy.count(), 1); + + flickable.setHeight(100); + QCOMPARE(flickable.height(), qreal(100)); + QCOMPARE(flickable.contentHeight(), qreal(-1.0)); + QCOMPARE(chspy.count(), 0); + + flickable.setContentHeight(10); + QCOMPARE(flickable.height(), qreal(100)); + QCOMPARE(flickable.contentHeight(), qreal(10)); + QCOMPARE(chspy.count(), 1); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |