aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2017-04-13 20:56:01 +0200
commit1fb1c6c4f8769250dffa375e3941738eb1fcc885 (patch)
tree4f4c4afae97b54a793a0589f8ca53b7c919de728 /tests/auto/quick
parentd0ce320646b7f852a24f6e0a9e9621ddcedef554 (diff)
parent9c1c471e54bb12e8740b76d1c048f2f916a6ab59 (diff)
Merge remote-tracking branch 'origin/dev' into wip/pointerhandler
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp1
-rw-r--r--tests/auto/quick/nokeywords/tst_nokeywords.cpp1
-rw-r--r--tests/auto/quick/qquickapplication/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickflickable/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedSlider.qml36
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp328
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp2
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/BLACKLIST6
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp2
-rw-r--r--tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml12
-rw-r--r--tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml9
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp44
-rw-r--r--tests/auto/quick/qquickwindow/BLACKLIST4
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp258
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp76
15 files changed, 642 insertions, 141 deletions
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
index d5c9aaeb90..b6742b9efe 100644
--- a/tests/auto/quick/examples/tst_examples.cpp
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -29,7 +29,6 @@
#include <qtest.h>
#include <QLibraryInfo>
#include <QDir>
-#include <QProcess>
#include <QDebug>
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
index ad77743ddd..e6655589a3 100644
--- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp
+++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp
@@ -55,7 +55,6 @@
#include <QtQuick/private/qsgdefaultinternalrectanglenode_p.h>
#include <QtQuick/private/qsgdepthstencilbuffer_p.h>
#include <QtQuick/private/qsgdistancefieldglyphnode_p.h>
-#include <QtQuick/private/qsgdistancefieldutil_p.h>
#endif
#include <QtQuick/private/qsggeometry_p.h>
#include <QtQuick/private/qsgnode_p.h>
diff --git a/tests/auto/quick/qquickapplication/BLACKLIST b/tests/auto/quick/qquickapplication/BLACKLIST
new file mode 100644
index 0000000000..81592db56f
--- /dev/null
+++ b/tests/auto/quick/qquickapplication/BLACKLIST
@@ -0,0 +1,2 @@
+[active]
+osx-10.11
diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST
index 647bf819a5..f35397f119 100644
--- a/tests/auto/quick/qquickflickable/BLACKLIST
+++ b/tests/auto/quick/qquickflickable/BLACKLIST
@@ -17,3 +17,5 @@ osx
osx-10.10
[flickVelocity]
osx-10.10
+[nestedSliderUsingTouch:keepNeither]
+ubuntu-16.04
diff --git a/tests/auto/quick/qquickflickable/data/nestedSlider.qml b/tests/auto/quick/qquickflickable/data/nestedSlider.qml
new file mode 100644
index 0000000000..2fd0cbfcc8
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/nestedSlider.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.0
+import Test 1.0
+
+Flickable {
+ width: 240
+ height: 320
+ contentWidth: width * 1.5
+ contentHeight: height * 1.5
+ contentY: height * 0.25
+
+ Rectangle {
+ id: slider
+ width: 50
+ height: 200
+ color: "lightgray"
+ border.color: drag.active ? "green" : "black"
+ anchors.centerIn: parent
+ radius: 4
+
+ TouchDragArea {
+ id: drag
+ objectName: "drag"
+ anchors.fill: parent
+ }
+
+ Rectangle {
+ width: parent.width - 2
+ height: 20
+ radius: 5
+ color: "darkgray"
+ border.color: "black"
+ x: 1
+ y: Math.min(slider.height - height, Math.max(0, drag.pos.y - height / 2))
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 9ead271bfe..ef6e444580 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -46,12 +46,107 @@
using namespace QQuickViewTestUtil;
using namespace QQuickVisualTestUtil;
+// an abstract Slider which only handles touch events
+class TouchDragArea : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QPointF pos READ pos NOTIFY posChanged)
+ Q_PROPERTY(bool active READ active NOTIFY activeChanged)
+ Q_PROPERTY(bool keepMouseGrab READ keepMouseGrab WRITE setKeepMouseGrab NOTIFY keepMouseGrabChanged)
+ Q_PROPERTY(bool keepTouchGrab READ keepTouchGrab WRITE setKeepTouchGrab NOTIFY keepTouchGrabChanged)
+
+public:
+ TouchDragArea(QQuickItem *parent = 0)
+ : QQuickItem(parent)
+ , touchEvents(0)
+ , touchUpdates(0)
+ , touchReleases(0)
+ , ungrabs(0)
+ , m_active(false)
+ { }
+
+ QPointF pos() const { return m_pos; }
+
+ bool active() const { return m_active; }
+
+ void setKeepMouseGrab(bool keepMouseGrab)
+ {
+ QQuickItem::setKeepMouseGrab(keepMouseGrab);
+ emit keepMouseGrabChanged();
+ }
+
+ void setKeepTouchGrab(bool keepTouchGrab)
+ {
+ QQuickItem::setKeepTouchGrab(keepTouchGrab);
+ emit keepTouchGrabChanged();
+ }
+
+ int touchEvents;
+ int touchUpdates;
+ int touchReleases;
+ int ungrabs;
+ QVector<Qt::TouchPointState> touchPointStates;
+
+protected:
+ void touchEvent(QTouchEvent *ev) override
+ {
+ QCOMPARE(ev->touchPoints().count(), 1);
+ auto touchpoint = ev->touchPoints().first();
+ switch (touchpoint.state()) {
+ case Qt::TouchPointPressed:
+ QVERIFY(!m_active);
+ m_active = true;
+ emit activeChanged();
+ grabTouchPoints(QVector<int>() << touchpoint.id());
+ break;
+ case Qt::TouchPointMoved:
+ ++touchUpdates;
+ break;
+ case Qt::TouchPointReleased:
+ QVERIFY(m_active);
+ m_active = false;
+ ++touchReleases;
+ emit activeChanged();
+ case Qt::TouchPointStationary:
+ break;
+ }
+ touchPointStates << touchpoint.state();
+ ++touchEvents;
+ m_pos = touchpoint.pos();
+ emit posChanged();
+ }
+
+ void touchUngrabEvent() override
+ {
+ ++ungrabs;
+ QVERIFY(m_active);
+ emit ungrabbed();
+ m_active = false;
+ emit activeChanged();
+ }
+
+signals:
+ void ungrabbed();
+ void posChanged();
+ void keepMouseGrabChanged();
+ void keepTouchGrabChanged();
+ void activeChanged();
+
+private:
+ QPointF m_pos;
+ bool m_active;
+};
+
class tst_qquickflickable : public QQmlDataTest
{
Q_OBJECT
public:
+ tst_qquickflickable()
+ : touchDevice(QTest::createTouchDevice())
+ {}
private slots:
+ void initTestCase() override;
void create();
void horizontalViewportSize();
void verticalViewportSize();
@@ -89,6 +184,8 @@ private slots:
void stopAtBounds();
void stopAtBounds_data();
void nestedMouseAreaUsingTouch();
+ void nestedSliderUsingTouch();
+ void nestedSliderUsingTouch_data();
void pressDelayWithLoader();
void movementFromProgrammaticFlick();
void cleanup();
@@ -101,9 +198,16 @@ private slots:
void overshoot_reentrant();
private:
- void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
+ void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to);
+ QTouchDevice *touchDevice;
};
+void tst_qquickflickable::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TouchDragArea>("Test",1,0,"TouchDragArea");
+}
+
void tst_qquickflickable::cleanup()
{
QVERIFY(QGuiApplication::topLevelWindows().isEmpty());
@@ -1530,12 +1634,6 @@ void tst_qquickflickable::clickAndDragWhenTransformed()
void tst_qquickflickable::flickTwiceUsingTouches()
{
- QTouchDevice *touchDevice = new QTouchDevice;
- touchDevice->setName("Fake Touchscreen");
- touchDevice->setType(QTouchDevice::TouchScreen);
- touchDevice->setCapabilities(QTouchDevice::Position);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
-
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("longList.qml"));
QTRY_COMPARE(window->status(), QQuickView::Ready);
@@ -1548,7 +1646,7 @@ void tst_qquickflickable::flickTwiceUsingTouches()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 0.0f);
- flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), QPoint(100, 400), QPoint(100, 240));
qreal contentYAfterFirstFlick = flickable->contentY();
qDebug() << "contentYAfterFirstFlick " << contentYAfterFirstFlick;
@@ -1556,7 +1654,7 @@ void tst_qquickflickable::flickTwiceUsingTouches()
// Wait until view stops moving
QTRY_VERIFY(!flickable->isMoving());
- flickWithTouch(window.data(), touchDevice, QPoint(100, 400), QPoint(100, 240));
+ flickWithTouch(window.data(), QPoint(100, 400), QPoint(100, 240));
// In the original bug, that second flick would cause Flickable to halt immediately
qreal contentYAfterSecondFlick = flickable->contentY();
@@ -1564,7 +1662,7 @@ void tst_qquickflickable::flickTwiceUsingTouches()
QTRY_VERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f));
}
-void tst_qquickflickable::flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to)
+void tst_qquickflickable::flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to)
{
QTest::touchEvent(window, touchDevice).press(0, from, window);
QQuickTouchUtils::flush(window);
@@ -1869,12 +1967,6 @@ void tst_qquickflickable::stopAtBounds()
void tst_qquickflickable::nestedMouseAreaUsingTouch()
{
- QTouchDevice *touchDevice = new QTouchDevice;
- touchDevice->setName("Fake Touchscreen");
- touchDevice->setType(QTouchDevice::TouchScreen);
- touchDevice->setCapabilities(QTouchDevice::Position);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
-
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("nestedmousearea.qml"));
QTRY_COMPARE(window->status(), QQuickView::Ready);
@@ -1887,7 +1979,7 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
QVERIFY(flickable != 0);
QCOMPARE(flickable->contentY(), 50.0f);
- flickWithTouch(window.data(), touchDevice, QPoint(100, 300), QPoint(100, 200));
+ flickWithTouch(window.data(), QPoint(100, 300), QPoint(100, 200));
// flickable should not have moved
QCOMPARE(flickable->contentY(), 50.0);
@@ -1897,6 +1989,65 @@ void tst_qquickflickable::nestedMouseAreaUsingTouch()
QVERIFY(nested->y() < 100.0);
}
+void tst_qquickflickable::nestedSliderUsingTouch_data()
+{
+ QTest::addColumn<bool>("keepMouseGrab");
+ QTest::addColumn<bool>("keepTouchGrab");
+ QTest::addColumn<int>("updates");
+ QTest::addColumn<int>("releases");
+ QTest::addColumn<int>("ungrabs");
+
+ QTest::newRow("keepBoth") << true << true << 8 << 1 << 0;
+ QTest::newRow("keepMouse") << true << false << 8 << 1 << 0;
+ QTest::newRow("keepTouch") << false << true << 8 << 1 << 0;
+ QTest::newRow("keepNeither") << false << false << 6 << 0 << 1;
+}
+
+void tst_qquickflickable::nestedSliderUsingTouch()
+{
+ QFETCH(bool, keepMouseGrab);
+ QFETCH(bool, keepTouchGrab);
+ QFETCH(int, updates);
+ QFETCH(int, releases);
+ QFETCH(int, ungrabs);
+
+ QQuickView *window = new QQuickView;
+ QScopedPointer<QQuickView> windowPtr(window);
+ windowPtr->setSource(testFileUrl("nestedSlider.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window);
+ QQuickViewTestUtil::moveMouseAway(window);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable);
+
+ TouchDragArea *tda = flickable->findChild<TouchDragArea*>("drag");
+ QVERIFY(tda);
+
+ // Drag down and a little to the right: flickable will steal the grab only if tda allows it
+ const int dragThreshold = qApp->styleHints()->startDragDistance();
+ tda->setKeepMouseGrab(keepMouseGrab);
+ tda->setKeepTouchGrab(keepTouchGrab);
+ QPoint p0 = tda->mapToScene(QPoint(20, 20)).toPoint();
+ QTest::touchEvent(window, touchDevice).press(0, p0, window);
+ QQuickTouchUtils::flush(window);
+ for (int i = 0; i < 8; ++i) {
+ p0 += QPoint(dragThreshold / 6, dragThreshold / 4);
+ QTest::touchEvent(window, touchDevice).move(0, p0, window);
+ QQuickTouchUtils::flush(window);
+ }
+ QCOMPARE(tda->active(), !ungrabs);
+ QTest::touchEvent(window, touchDevice).release(0, p0, window);
+ QQuickTouchUtils::flush(window);
+ QTRY_COMPARE(tda->touchPointStates.first(), Qt::TouchPointPressed);
+ QTRY_COMPARE(tda->touchUpdates, updates);
+ QTRY_COMPARE(tda->touchReleases, releases);
+ QTRY_COMPARE(tda->ungrabs, ungrabs);
+}
+
// QTBUG-31328
void tst_qquickflickable::pressDelayWithLoader()
{
@@ -2065,6 +2216,7 @@ Q_DECLARE_METATYPE(QQuickFlickable::BoundsBehavior)
void tst_qquickflickable::overshoot()
{
QFETCH(QQuickFlickable::BoundsBehavior, boundsBehavior);
+ QFETCH(int, boundsMovement);
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("overshoot.qml"));
@@ -2081,6 +2233,7 @@ void tst_qquickflickable::overshoot()
QCOMPARE(flickable->contentHeight(), 400.0);
flickable->setBoundsBehavior(boundsBehavior);
+ flickable->setBoundsMovement(QQuickFlickable::BoundsMovement(boundsMovement));
// drag past the beginning
QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10));
@@ -2089,23 +2242,30 @@ void tst_qquickflickable::overshoot()
QTest::mouseMove(window.data(), QPoint(40, 40));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 50));
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) && (boundsBehavior & QQuickFlickable::DragOverBounds)) {
+ QVERIFY(flickable->property("minContentX").toReal() < 0.0);
+ QVERIFY(flickable->property("minContentY").toReal() < 0.0);
+ } else {
+ QCOMPARE(flickable->property("minContentX").toReal(), 0.0);
+ QCOMPARE(flickable->property("minContentY").toReal(), 0.0);
+ }
if (boundsBehavior & QQuickFlickable::DragOverBounds) {
- QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0);
QVERIFY(flickable->property("minHorizontalOvershoot").toReal() < 0.0);
- QCOMPARE(flickable->property("minContentY").toReal(),
- flickable->property("minVerticalOvershoot").toReal());
- QCOMPARE(flickable->property("minContentX").toReal(),
- flickable->property("minHorizontalOvershoot").toReal());
+ QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0);
} else {
- QCOMPARE(flickable->property("minContentY").toReal(), 0.0);
- QCOMPARE(flickable->property("minContentX").toReal(), 0.0);
- QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
+ }
+ if (bool(boundsMovement == QQuickFlickable::FollowBoundsBehavior) == bool(boundsBehavior & QQuickFlickable::DragOverBounds)) {
+ QCOMPARE(flickable->property("minContentX").toReal(),
+ flickable->property("minHorizontalOvershoot").toReal());
+ QCOMPARE(flickable->property("minContentY").toReal(),
+ flickable->property("minVerticalOvershoot").toReal());
}
- QCOMPARE(flickable->property("maxContentY").toReal(), 0.0);
QCOMPARE(flickable->property("maxContentX").toReal(), 0.0);
- QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxContentY").toReal(), 0.0);
QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
flickable->setContentX(20.0);
flickable->setContentY(20.0);
@@ -2115,23 +2275,30 @@ void tst_qquickflickable::overshoot()
flick(window.data(), QPoint(10, 10), QPoint(50, 50), 100);
QTRY_VERIFY(!flickable->property("flicking").toBool());
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) && (boundsBehavior & QQuickFlickable::OvershootBounds)) {
+ QVERIFY(flickable->property("minContentX").toReal() < 0.0);
+ QVERIFY(flickable->property("minContentY").toReal() < 0.0);
+ } else {
+ QCOMPARE(flickable->property("minContentX").toReal(), 0.0);
+ QCOMPARE(flickable->property("minContentY").toReal(), 0.0);
+ }
if (boundsBehavior & QQuickFlickable::OvershootBounds) {
- QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0);
QVERIFY(flickable->property("minHorizontalOvershoot").toReal() < 0.0);
- QCOMPARE(flickable->property("minContentY").toReal(),
- flickable->property("minVerticalOvershoot").toReal());
- QCOMPARE(flickable->property("minContentX").toReal(),
- flickable->property("minHorizontalOvershoot").toReal());
+ QVERIFY(flickable->property("minVerticalOvershoot").toReal() < 0.0);
} else {
- QCOMPARE(flickable->property("minContentY").toReal(), 0.0);
- QCOMPARE(flickable->property("minContentX").toReal(), 0.0);
- QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
+ }
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) == (boundsBehavior & QQuickFlickable::OvershootBounds)) {
+ QCOMPARE(flickable->property("minContentX").toReal(),
+ flickable->property("minHorizontalOvershoot").toReal());
+ QCOMPARE(flickable->property("minContentY").toReal(),
+ flickable->property("minVerticalOvershoot").toReal());
}
- QCOMPARE(flickable->property("maxContentY").toReal(), 20.0);
QCOMPARE(flickable->property("maxContentX").toReal(), 20.0);
- QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxContentY").toReal(), 20.0);
QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
flickable->setContentX(200.0);
flickable->setContentY(200.0);
@@ -2144,23 +2311,30 @@ void tst_qquickflickable::overshoot()
QTest::mouseMove(window.data(), QPoint(20, 20));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(10, 10));
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) && (boundsBehavior & QQuickFlickable::DragOverBounds)) {
+ QVERIFY(flickable->property("maxContentX").toReal() > 200.0);
+ QVERIFY(flickable->property("maxContentX").toReal() > 200.0);
+ } else {
+ QCOMPARE(flickable->property("maxContentX").toReal(), 200.0);
+ QCOMPARE(flickable->property("maxContentY").toReal(), 200.0);
+ }
if (boundsBehavior & QQuickFlickable::DragOverBounds) {
- QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0);
QVERIFY(flickable->property("maxHorizontalOvershoot").toReal() > 0.0);
- QCOMPARE(flickable->property("maxContentY").toReal() - 200.0,
- flickable->property("maxVerticalOvershoot").toReal());
- QCOMPARE(flickable->property("maxContentX").toReal() - 200.0,
- flickable->property("maxHorizontalOvershoot").toReal());
+ QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0);
} else {
- QCOMPARE(flickable->property("maxContentY").toReal(), 200.0);
- QCOMPARE(flickable->property("maxContentX").toReal(), 200.0);
- QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
+ }
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) == (boundsBehavior & QQuickFlickable::DragOverBounds)) {
+ QCOMPARE(flickable->property("maxContentX").toReal() - 200.0,
+ flickable->property("maxHorizontalOvershoot").toReal());
+ QCOMPARE(flickable->property("maxContentY").toReal() - 200.0,
+ flickable->property("maxVerticalOvershoot").toReal());
}
- QCOMPARE(flickable->property("minContentY").toReal(), 200.0);
QCOMPARE(flickable->property("minContentX").toReal(), 200.0);
- QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minContentY").toReal(), 200.0);
QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
flickable->setContentX(180.0);
flickable->setContentY(180.0);
@@ -2170,37 +2344,59 @@ void tst_qquickflickable::overshoot()
flick(window.data(), QPoint(50, 50), QPoint(10, 10), 100);
QTRY_VERIFY(!flickable->property("flicking").toBool());
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) && (boundsBehavior & QQuickFlickable::OvershootBounds)) {
+ QVERIFY(flickable->property("maxContentX").toReal() > 200.0);
+ QVERIFY(flickable->property("maxContentY").toReal() > 200.0);
+ } else {
+ QCOMPARE(flickable->property("maxContentX").toReal(), 200.0);
+ QCOMPARE(flickable->property("maxContentY").toReal(), 200.0);
+ }
if (boundsBehavior & QQuickFlickable::OvershootBounds) {
- QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0);
QVERIFY(flickable->property("maxHorizontalOvershoot").toReal() > 0.0);
- QCOMPARE(flickable->property("maxContentY").toReal() - 200.0,
- flickable->property("maxVerticalOvershoot").toReal());
- QCOMPARE(flickable->property("maxContentX").toReal() - 200.0,
- flickable->property("maxHorizontalOvershoot").toReal());
+ QVERIFY(flickable->property("maxVerticalOvershoot").toReal() > 0.0);
} else {
- QCOMPARE(flickable->property("maxContentY").toReal(), 200.0);
- QCOMPARE(flickable->property("maxContentX").toReal(), 200.0);
- QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
QCOMPARE(flickable->property("maxHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("maxVerticalOvershoot").toReal(), 0.0);
+ }
+ if ((boundsMovement == QQuickFlickable::FollowBoundsBehavior) == (boundsBehavior & QQuickFlickable::OvershootBounds)) {
+ QCOMPARE(flickable->property("maxContentX").toReal() - 200.0,
+ flickable->property("maxHorizontalOvershoot").toReal());
+ QCOMPARE(flickable->property("maxContentY").toReal() - 200.0,
+ flickable->property("maxVerticalOvershoot").toReal());
}
- QCOMPARE(flickable->property("minContentY").toReal(), 180.0);
QCOMPARE(flickable->property("minContentX").toReal(), 180.0);
- QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minContentY").toReal(), 180.0);
QCOMPARE(flickable->property("minHorizontalOvershoot").toReal(), 0.0);
+ QCOMPARE(flickable->property("minVerticalOvershoot").toReal(), 0.0);
}
void tst_qquickflickable::overshoot_data()
{
QTest::addColumn<QQuickFlickable::BoundsBehavior>("boundsBehavior");
-
- QTest::newRow("StopAtBounds")
- << QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds);
- QTest::newRow("DragOverBounds")
- << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds);
- QTest::newRow("OvershootBounds")
- << QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds);
- QTest::newRow("DragAndOvershootBounds")
- << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
+ QTest::addColumn<int>("boundsMovement");
+
+ QTest::newRow("StopAtBounds,FollowBoundsBehavior")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::StopAtBounds)
+ << int(QQuickFlickable::FollowBoundsBehavior);
+ QTest::newRow("DragOverBounds,FollowBoundsBehavior")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds)
+ << int(QQuickFlickable::FollowBoundsBehavior);
+ QTest::newRow("OvershootBounds,FollowBoundsBehavior")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds)
+ << int(QQuickFlickable::FollowBoundsBehavior);
+ QTest::newRow("DragAndOvershootBounds,FollowBoundsBehavior")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds)
+ << int(QQuickFlickable::FollowBoundsBehavior);
+
+ QTest::newRow("DragOverBounds,StopAtBounds")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragOverBounds)
+ << int(QQuickFlickable::StopAtBounds);
+ QTest::newRow("OvershootBounds,StopAtBounds")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::OvershootBounds)
+ << int(QQuickFlickable::StopAtBounds);
+ QTest::newRow("DragAndOvershootBounds,StopAtBounds")
+ << QQuickFlickable::BoundsBehavior(QQuickFlickable::DragAndOvershootBounds)
+ << int(QQuickFlickable::StopAtBounds);
}
void tst_qquickflickable::overshoot_reentrant()
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
index 2681f1a966..36d99ad48d 100644
--- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -375,7 +375,7 @@ void tst_qquickimage::mirror()
}
QImage img = expected.toImage();
- QCOMPARE(screenshots[fillMode], img);
+ QCOMPARE(screenshots[fillMode].convertToFormat(img.format()), img);
}
}
diff --git a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
index 1777af9e0c..cab6e2f7bf 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
+++ b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST
@@ -1,2 +1,4 @@
-[inFlickable]
-*
+[nonOverlapping]
+ubuntu-16.04
+[nested]
+ubuntu-16.04
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index 2872556a94..87acd67f6a 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -800,7 +800,7 @@ void tst_QQuickMultiPointTouchArea::inFlickable2()
QVERIFY(flickable->contentY() < 0);
QVERIFY(flickable->isMoving());
- QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point11->pressed(), false);
QTest::touchEvent(window.data(), device).release(0, p1);
QQuickTouchUtils::flush(window.data());
diff --git a/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml
deleted file mode 100644
index 8da9fc270d..0000000000
--- a/tests/auto/quick/qquickpositioners/data/implicitGridOneItem.qml
+++ /dev/null
@@ -1,12 +0,0 @@
-import QtQuick 2.9
-import PositionerTest 1.0
-
-ImplicitGrid {
- columns: 2
- rows: 1
-
- Text {
- text: "Text"
- width: parent.width
- }
-}
diff --git a/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml b/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml
deleted file mode 100644
index 25a287cf31..0000000000
--- a/tests/auto/quick/qquickpositioners/data/implicitRowOneItem.qml
+++ /dev/null
@@ -1,9 +0,0 @@
-import QtQuick 2.9
-import PositionerTest 1.0
-
-ImplicitRow {
- Text {
- text: "Text"
- width: parent.width
- }
-}
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
index 4c4afb7a7b..1b3939401a 100644
--- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -98,8 +98,6 @@ private slots:
void test_attachedproperties();
void test_attachedproperties_data();
void test_attachedproperties_dynamic();
- void test_useImplicitSize_oneItem_data();
- void test_useImplicitSize_oneItem();
void populateTransitions_row();
void populateTransitions_row_data();
@@ -306,8 +304,6 @@ void tst_qquickpositioners::moveTransitions_flow_data()
tst_qquickpositioners::tst_qquickpositioners()
{
- qmlRegisterType<QQuickImplicitRow>("PositionerTest", 1, 0, "ImplicitRow");
- qmlRegisterType<QQuickImplicitGrid>("PositionerTest", 1, 0, "ImplicitGrid");
}
void tst_qquickpositioners::test_horizontal()
@@ -4008,46 +4004,6 @@ void tst_qquickpositioners::test_attachedproperties_dynamic()
}
-void tst_qquickpositioners::test_useImplicitSize_oneItem_data()
-{
- QTest::addColumn<QString>("positionerType");
-
- QTest::newRow("Grid") << "Grid";
- QTest::newRow("Row") << "Row";
-}
-
-void tst_qquickpositioners::test_useImplicitSize_oneItem()
-{
- QFETCH(QString, positionerType);
-
- QQuickView view;
- view.setSource(testFileUrl(QString::fromLatin1("implicit%1OneItem.qml").arg(positionerType)));
- QCOMPARE(view.status(), QQuickView::Ready);
- view.show();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
-
- QQuickItem *positioner = view.rootObject();
- QVERIFY(positioner);
- const qreal oldPositionerImplicitWidth = positioner->implicitWidth();
-
- QQuickText *text = qobject_cast<QQuickText*>(positioner->childItems().first());
- QVERIFY(text);
- const qreal oldTextImplicitWidth = text->implicitWidth();
- QCOMPARE(positioner->implicitWidth(), text->implicitWidth());
-
- // Ensure that the implicit size of the positioner changes when the implicit size
- // of one of its children changes.
- text->setText(QLatin1String("Even More Text"));
- const qreal textImplicitWidthIncrease = text->implicitWidth() - oldTextImplicitWidth;
- QVERIFY(textImplicitWidthIncrease > 0);
- QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
-
- // Ensure that the implicit size of the positioner does not change when the
- // explicit size of one of its children changes.
- text->setWidth(10);
- QTRY_COMPARE(positioner->implicitWidth(), oldPositionerImplicitWidth + textImplicitWidthIncrease);
-}
-
QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
{
QQuickView *window = new QQuickView(0);
diff --git a/tests/auto/quick/qquickwindow/BLACKLIST b/tests/auto/quick/qquickwindow/BLACKLIST
new file mode 100644
index 0000000000..157808fdbf
--- /dev/null
+++ b/tests/auto/quick/qquickwindow/BLACKLIST
@@ -0,0 +1,4 @@
+[requestActivate]
+osx-10.11
+[attachedProperty]
+osx-10.11
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 578f737c4d..4fea13eb49 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -28,6 +28,7 @@
#include <qtest.h>
#include <QDebug>
+#include <QMimeData>
#include <QTouchEvent>
#include <QtQuick/QQuickItem>
#include <QtQuick/QQuickView>
@@ -385,6 +386,8 @@ private slots:
void grabContentItemToImage();
+ void testDragEventPropertyPropagation();
+
private:
QTouchDevice *touchDevice;
QTouchDevice *touchDeviceWithVelocity;
@@ -2617,6 +2620,261 @@ void tst_qquickwindow::grabContentItemToImage()
QTRY_COMPARE(created->property("success").toInt(), 1);
}
+class TestDropTarget : public QQuickItem
+{
+ Q_OBJECT
+public:
+ TestDropTarget(QQuickItem *parent = 0)
+ : QQuickItem(parent)
+ , enterDropAction(Qt::CopyAction)
+ , moveDropAction(Qt::CopyAction)
+ , dropDropAction(Qt::CopyAction)
+ , enterAccept(true)
+ , moveAccept(true)
+ , dropAccept(true)
+ {
+ setFlags(ItemAcceptsDrops);
+ }
+
+ void reset()
+ {
+ enterDropAction = Qt::CopyAction;
+ moveDropAction = Qt::CopyAction;
+ dropDropAction = Qt::CopyAction;
+ enterAccept = true;
+ moveAccept = true;
+ dropAccept = true;
+ }
+
+ void dragEnterEvent(QDragEnterEvent *event)
+ {
+ event->setAccepted(enterAccept);
+ event->setDropAction(enterDropAction);
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event)
+ {
+ event->setAccepted(moveAccept);
+ event->setDropAction(moveDropAction);
+ }
+
+ void dropEvent(QDropEvent *event)
+ {
+ event->setAccepted(dropAccept);
+ event->setDropAction(dropDropAction);
+ }
+
+ Qt::DropAction enterDropAction;
+ Qt::DropAction moveDropAction;
+ Qt::DropAction dropDropAction;
+ bool enterAccept;
+ bool moveAccept;
+ bool dropAccept;
+};
+
+class DragEventTester {
+public:
+ DragEventTester()
+ : pos(60, 60)
+ , actions(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)
+ , buttons(Qt::LeftButton)
+ , modifiers(Qt::NoModifier)
+ {
+ }
+
+ ~DragEventTester() {
+ qDeleteAll(events);
+ events.clear();
+ enterEvent = 0;
+ moveEvent = 0;
+ dropEvent = 0;
+ leaveEvent = 0;
+ }
+
+ void addEnterEvent()
+ {
+ enterEvent = new QDragEnterEvent(pos, actions, &data, buttons, modifiers);
+ events.append(enterEvent);
+ }
+
+ void addMoveEvent()
+ {
+ moveEvent = new QDragMoveEvent(pos, actions, &data, buttons, modifiers, QEvent::DragMove);
+ events.append(moveEvent);
+ }
+
+ void addDropEvent()
+ {
+ dropEvent = new QDropEvent(pos, actions, &data, buttons, modifiers, QEvent::Drop);
+ events.append(dropEvent);
+ }
+
+ void addLeaveEvent()
+ {
+ leaveEvent = new QDragLeaveEvent();
+ events.append(leaveEvent);
+ }
+
+ void sendDragEventSequence(QQuickWindow *window) const {
+ for (int i = 0; i < events.size(); ++i) {
+ QCoreApplication::sendEvent(window, events[i]);
+ }
+ }
+
+ // Used for building events.
+ QMimeData data;
+ QPoint pos;
+ Qt::DropActions actions;
+ Qt::MouseButtons buttons;
+ Qt::KeyboardModifiers modifiers;
+
+ // Owns events.
+ QList<QEvent *> events;
+
+ // Non-owner pointers for easy acccess.
+ QDragEnterEvent *enterEvent;
+ QDragMoveEvent *moveEvent;
+ QDropEvent *dropEvent;
+ QDragLeaveEvent *leaveEvent;
+};
+
+void tst_qquickwindow::testDragEventPropertyPropagation()
+{
+ QQuickWindow window;
+ TestDropTarget dropTarget(window.contentItem());
+
+ // Setting the size is important because the QQuickWindow checks if the drag happened inside
+ // the drop target.
+ dropTarget.setSize(QSizeF(100, 100));
+
+ // Test enter events property propagation.
+ // For enter events, only isAccepted gets propagated.
+ {
+ DragEventTester builder;
+ dropTarget.enterAccept = false;
+ dropTarget.enterDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragEnterEvent* enterEvent = builder.enterEvent;
+ QCOMPARE(enterEvent->isAccepted(), dropTarget.enterAccept);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.enterAccept = false;
+ dropTarget.enterDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragEnterEvent* enterEvent = builder.enterEvent;
+ QCOMPARE(enterEvent->isAccepted(), dropTarget.enterAccept);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.enterAccept = true;
+ dropTarget.enterDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragEnterEvent* enterEvent = builder.enterEvent;
+ QCOMPARE(enterEvent->isAccepted(), dropTarget.enterAccept);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.enterAccept = true;
+ dropTarget.enterDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragEnterEvent* enterEvent = builder.enterEvent;
+ QCOMPARE(enterEvent->isAccepted(), dropTarget.enterAccept);
+ }
+
+ // Test move events property propagation.
+ // For move events, both isAccepted and dropAction get propagated.
+ dropTarget.reset();
+ {
+ DragEventTester builder;
+ dropTarget.moveAccept = false;
+ dropTarget.moveDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragMoveEvent* moveEvent = builder.moveEvent;
+ QCOMPARE(moveEvent->isAccepted(), dropTarget.moveAccept);
+ QCOMPARE(moveEvent->dropAction(), dropTarget.moveDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.moveAccept = false;
+ dropTarget.moveDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragMoveEvent* moveEvent = builder.moveEvent;
+ QCOMPARE(moveEvent->isAccepted(), dropTarget.moveAccept);
+ QCOMPARE(moveEvent->dropAction(), dropTarget.moveDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.moveAccept = true;
+ dropTarget.moveDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragMoveEvent* moveEvent = builder.moveEvent;
+ QCOMPARE(moveEvent->isAccepted(), dropTarget.moveAccept);
+ QCOMPARE(moveEvent->dropAction(), dropTarget.moveDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.moveAccept = true;
+ dropTarget.moveDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addLeaveEvent();
+ builder.sendDragEventSequence(&window);
+ QDragMoveEvent* moveEvent = builder.moveEvent;
+ QCOMPARE(moveEvent->isAccepted(), dropTarget.moveAccept);
+ QCOMPARE(moveEvent->dropAction(), dropTarget.moveDropAction);
+ }
+
+ // Test drop events property propagation.
+ // For drop events, both isAccepted and dropAction get propagated.
+ dropTarget.reset();
+ {
+ DragEventTester builder;
+ dropTarget.dropAccept = false;
+ dropTarget.dropDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addDropEvent();
+ builder.sendDragEventSequence(&window);
+ QDropEvent* dropEvent = builder.dropEvent;
+ QCOMPARE(dropEvent->isAccepted(), dropTarget.dropAccept);
+ QCOMPARE(dropEvent->dropAction(), dropTarget.dropDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.dropAccept = false;
+ dropTarget.dropDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addDropEvent();
+ builder.sendDragEventSequence(&window);
+ QDropEvent* dropEvent = builder.dropEvent;
+ QCOMPARE(dropEvent->isAccepted(), dropTarget.dropAccept);
+ QCOMPARE(dropEvent->dropAction(), dropTarget.dropDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.dropAccept = true;
+ dropTarget.dropDropAction = Qt::IgnoreAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addDropEvent();
+ builder.sendDragEventSequence(&window);
+ QDropEvent* dropEvent = builder.dropEvent;
+ QCOMPARE(dropEvent->isAccepted(), dropTarget.dropAccept);
+ QCOMPARE(dropEvent->dropAction(), dropTarget.dropDropAction);
+ }
+ {
+ DragEventTester builder;
+ dropTarget.dropAccept = true;
+ dropTarget.dropDropAction = Qt::CopyAction;
+ builder.addEnterEvent(); builder.addMoveEvent(); builder.addDropEvent();
+ builder.sendDragEventSequence(&window);
+ QDropEvent* dropEvent = builder.dropEvent;
+ QCOMPARE(dropEvent->isAccepted(), dropTarget.dropAccept);
+ QCOMPARE(dropEvent->dropAction(), dropTarget.dropDropAction);
+ }
+}
+
QTEST_MAIN(tst_qquickwindow)
#include "tst_qquickwindow.moc"
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index b02d60d0c5..6e7fce6189 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -71,7 +71,7 @@ Q_SIGNALS:
public:
EventItem(QQuickItem *parent = 0)
- : QQuickItem(parent), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1)
+ : QQuickItem(parent), touchUngrabCount(0), acceptMouse(false), acceptTouch(false), filterTouch(false), point0(-1)
{
setAcceptedMouseButtons(Qt::LeftButton);
}
@@ -111,11 +111,17 @@ public:
eventList.append(Event(QEvent::UngrabMouse, QPoint(0,0), QPoint(0,0)));
}
+ void touchUngrabEvent()
+ {
+ ++touchUngrabCount;
+ }
+
bool event(QEvent *event) {
return QQuickItem::event(event);
}
QList<Event> eventList;
+ int touchUngrabCount;
bool acceptMouse;
bool acceptTouch;
bool filterTouch; // when used as event filter
@@ -158,6 +164,7 @@ private slots:
void mouseOverTouch();
void buttonOnFlickable();
+ void touchButtonOnFlickable();
void buttonOnDelayedPressFlickable_data();
void buttonOnDelayedPressFlickable();
void buttonOnTouch();
@@ -568,9 +575,10 @@ void tst_TouchMouse::buttonOnFlickable()
QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1);
QCOMPARE(window->mouseGrabberItem(), eventItem1);
- p1 += QPoint(0, -10);
- QPoint p2 = p1 + QPoint(0, -10);
- QPoint p3 = p2 + QPoint(0, -10);
+ int dragDelta = -qApp->styleHints()->startDragDistance();
+ p1 += QPoint(0, dragDelta);
+ QPoint p2 = p1 + QPoint(0, dragDelta);
+ QPoint p3 = p2 + QPoint(0, dragDelta);
QQuickTouchUtils::flush(window.data());
QTest::touchEvent(window.data(), device).move(0, p1, window.data());
QQuickTouchUtils::flush(window.data());
@@ -593,6 +601,66 @@ void tst_TouchMouse::buttonOnFlickable()
QQuickTouchUtils::flush(window.data());
}
+void tst_TouchMouse::touchButtonOnFlickable()
+{
+ // flickable - height 500 / 1000
+ // - eventItem1 y: 100, height 100
+ // - eventItem2 y: 300, height 100
+
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("buttononflickable.qml"));
+ window->show();
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject() != 0);
+
+ QQuickFlickable *flickable = window->rootObject()->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flickable);
+
+ EventItem *eventItem2 = window->rootObject()->findChild<EventItem*>("eventItem2");
+ QVERIFY(eventItem2);
+ QCOMPARE(eventItem2->eventList.size(), 0);
+ eventItem2->acceptTouch = true;
+
+ // press via touch, then drag: check that flickable moves and that the button gets ungrabbed
+ QCOMPARE(eventItem2->eventList.size(), 0);
+ QPoint p1 = QPoint(10, 310);
+ QTest::touchEvent(window.data(), device).press(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QCOMPARE(eventItem2->eventList.size(), 1);
+ QCOMPARE(eventItem2->eventList.at(0).type, QEvent::TouchBegin);
+
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data());
+ QVERIFY(windowPriv->touchMouseId == -1);
+ auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent();
+ QCOMPARE(pointerEvent->point(0)->grabberItem(), eventItem2);
+ QCOMPARE(window->mouseGrabberItem(), nullptr);
+
+ int dragDelta = qApp->styleHints()->startDragDistance() * -0.7;
+ p1 += QPoint(0, dragDelta);
+ QPoint p2 = p1 + QPoint(0, dragDelta);
+ QPoint p3 = p2 + QPoint(0, dragDelta);
+
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p2, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QTest::touchEvent(window.data(), device).move(0, p3, window.data());
+ QQuickTouchUtils::flush(window.data());
+
+ QVERIFY(eventItem2->eventList.size() > 2);
+ QCOMPARE(eventItem2->eventList.at(1).type, QEvent::TouchUpdate);
+ QCOMPARE(eventItem2->touchUngrabCount, 1);
+ QCOMPARE(window->mouseGrabberItem(), flickable);
+ QVERIFY(windowPriv->touchMouseId != -1);
+ QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable);
+ QVERIFY(flickable->isMovingVertically());
+
+ QTest::touchEvent(window.data(), device).release(0, p3, window.data());
+ QQuickTouchUtils::flush(window.data());
+}
+
void tst_TouchMouse::buttonOnDelayedPressFlickable_data()
{
QTest::addColumn<bool>("scrollBeforeDelayIsOver");