aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-10 01:01:21 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-04-10 09:35:18 +0200
commit35f59635087a36e5037a9590ce0b0da0b138c488 (patch)
tree51e56fefa3b13fe69d290473f19e86cad3ef8ba6 /tests/auto/quick
parent96c4fffd8648e9c9fb95e8208a76933c8c2120bc (diff)
parent8c3172d724f3ad03cdee7bae23443fa109d350b1 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: src/qml/qml/qqmlmetatype.cpp src/qml/types/qqmlmodelsmodule.cpp Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml36
-rw-r--r--tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp33
-rw-r--r--tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp2
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp13
-rw-r--r--tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml29
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp34
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp10
-rw-r--r--tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp2
8 files changed, 150 insertions, 9 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml
new file mode 100644
index 0000000000..e5ca681bd5
--- /dev/null
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml
@@ -0,0 +1,36 @@
+import QtQuick 2.12
+
+Rectangle {
+ color: "#333"
+ width: 480; height: 480
+
+ Rectangle {
+ color: "#112"
+ width: 100
+ height: 100
+ x: 50; y: 50
+
+ DragHandler {
+ id: dragHandler
+ margin: 20
+ }
+
+ Rectangle {
+ id: rect
+ anchors.fill: parent
+ anchors.margins: -dragHandler.margin
+ color: "transparent"
+ border.color: "cyan"
+ border.width: 2
+ radius: 10
+ antialiasing: true
+
+ Text {
+ color: "cyan"
+ text: "drag this margin area"
+ font.pixelSize: 10
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
index eb210c2112..cc8c567e5c 100644
--- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp
@@ -55,6 +55,7 @@ private slots:
void defaultPropertyValues();
void touchDrag();
void mouseDrag();
+ void dragFromMargin();
void touchDragMulti();
void touchDragMultiSliders_data();
void touchDragMultiSliders();
@@ -251,6 +252,38 @@ void tst_DragHandler::mouseDrag()
QCOMPARE(centroidChangedSpy.count(), 5);
}
+void tst_DragHandler::dragFromMargin() // QTBUG-74966
+{
+ const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
+ QScopedPointer<QQuickView> windowPtr;
+ createView(windowPtr, "dragMargin.qml");
+ QQuickView * window = windowPtr.data();
+
+ QQuickItem *draggableItem = window->rootObject()->childItems().first();
+ QVERIFY(draggableItem);
+ QQuickDragHandler *dragHandler = draggableItem->findChild<QQuickDragHandler*>();
+ QVERIFY(dragHandler);
+
+ QPointF originalPos = draggableItem->position();
+ QPointF scenePressPos = originalPos - QPointF(10, 0);
+ QPoint p1 = scenePressPos.toPoint();
+ QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QVERIFY(!dragHandler->active());
+ QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ p1 += QPoint(dragThreshold * 2, 0);
+ QTest::mouseMove(window, p1);
+ QTRY_VERIFY(dragHandler->active());
+ QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos);
+ QCOMPARE(dragHandler->centroid().sceneGrabPosition(), p1);
+ QCOMPARE(dragHandler->translation().x(), 0.0); // hmm that's odd
+ QCOMPARE(dragHandler->translation().y(), 0.0);
+ QCOMPARE(draggableItem->position(), originalPos + QPointF(dragThreshold * 2, 0));
+ QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1);
+ QTRY_VERIFY(!dragHandler->active());
+ QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton);
+}
+
void tst_DragHandler::touchDragMulti()
{
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
index f141a2546c..575139f851 100644
--- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
+++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp
@@ -252,7 +252,7 @@ void tst_HoverHandler::movingItemWithHoverHandler()
QTRY_COMPARE(window->isVisible(), false);
QCursor::setPos(paddlePos);
window->show();
- QTest::qWaitForWindowExposed(window);
+ QVERIFY(QTest::qWaitForWindowExposed(window));
QTRY_COMPARE(paddleHH->isHovered(), true);
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
index 1a289a2087..2f90632841 100644
--- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -51,9 +51,8 @@ public:
view.setSource(testFileUrl(fileName));
view.showNormal();
- QTest::qWaitForWindowExposed(&view);
-
- return view.grabWindow();
+ return QTest::qWaitForWindowExposed(&view)
+ ? view.grabWindow() : QImage();
}
private slots:
@@ -153,6 +152,7 @@ void tst_QQuickItemLayer::layerSmooth()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Smooth.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
@@ -177,6 +177,7 @@ void tst_QQuickItemLayer::layerEnabled()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Enabled.qml");
+ QVERIFY(!fb.size().isEmpty());
// Verify the banding
QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
// Verify the gradient
@@ -212,6 +213,7 @@ void tst_QQuickItemLayer::layerEffect()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("Effect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
}
@@ -229,6 +231,7 @@ void tst_QQuickItemLayer::layerSourceRect()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("SourceRect.qml");
+ QVERIFY(!fb.size().isEmpty());
// Check that the edges are converted to blue
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
@@ -253,6 +256,7 @@ void tst_QQuickItemLayer::layerIsTextureProvider()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("TextureProvider.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
}
@@ -448,6 +452,7 @@ void tst_QQuickItemLayer::changeSamplerName()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("SamplerNameChange.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
}
@@ -459,6 +464,7 @@ void tst_QQuickItemLayer::itemEffect()
QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects");
QImage fb = runTest("ItemEffect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
@@ -472,6 +478,7 @@ void tst_QQuickItemLayer::rectangleEffect()
QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms");
QImage fb = runTest("RectangleEffect.qml");
+ QVERIFY(!fb.size().isEmpty());
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
diff --git a/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml b/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml
new file mode 100644
index 0000000000..e0b8222bfb
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml
@@ -0,0 +1,29 @@
+import QtQuick 2.12
+
+ListView {
+ id: root
+ objectName: "view"
+ width: 600
+ height: 600
+ model: 3
+ snapMode: ListView.SnapOneItem
+ boundsBehavior: Flickable.StopAtBounds
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 0
+ highlightMoveDuration: 100
+ delegate: Rectangle {
+ id: delegateRect
+ width: 500
+ height: 500
+ color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1)
+ Text {
+ text: index
+ font.pixelSize: 128
+ anchors.centerIn: parent
+ }
+ MouseArea {
+ anchors.fill: parent
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index d96590bdae..2ea8a477a8 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -38,6 +38,7 @@
#include <QtQml/qqmlincubator.h>
#include <QtQuick/private/qquickitemview_p_p.h>
#include <QtQuick/private/qquicklistview_p.h>
+#include <QtQuick/private/qquickmousearea_p.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQml/private/qqmlobjectmodel_p.h>
#include <QtQml/private/qqmllistmodel_p.h>
@@ -275,6 +276,7 @@ private slots:
void addOnCompleted();
void setPositionOnLayout();
+ void touchCancel();
private:
template <class T> void items(const QUrl &source);
@@ -330,6 +332,7 @@ private:
QQuickView *m_view;
QString testForView;
+ QTouchDevice *touchDevice = QTest::createTouchDevice();
};
class TestObject : public QObject
@@ -8968,6 +8971,37 @@ void tst_QQuickListView::useDelegateChooserWithoutDefault()
window->show();
};
+void tst_QQuickListView::touchCancel() // QTBUG-74679
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("delegateWithMouseArea.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickListView *listview = qobject_cast<QQuickListView *>(window->rootObject());
+ QVERIFY(listview);
+ QQuickMouseArea *mouseArea = listview->currentItem()->findChild<QQuickMouseArea *>();
+ QVERIFY(mouseArea);
+
+ QPoint p1(300, 300);
+ QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data());
+ QQuickTouchUtils::flush(window.data());
+ QTRY_VERIFY(mouseArea->pressed());
+ // and because Flickable filtered it, QQuickFlickablePrivate::pressed
+ // should be true, but it's not easily tested here
+
+ QTouchEvent cancelEvent(QEvent::TouchCancel);
+ cancelEvent.setDevice(touchDevice);
+ QCoreApplication::sendEvent(window.data(), &cancelEvent);
+ // now QQuickWindowPrivate::sendUngrabEvent() will be called, Flickable will filter it,
+ // QQuickFlickablePrivate::pressed will be set to false, and that will allow setCurrentIndex() to make it move
+ QQuickTouchUtils::flush(window.data());
+
+ listview->setCurrentIndex(1);
+ // ensure that it actually moves (animates) to the second delegate
+ QTRY_COMPARE(listview->contentY(), 500.0);
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
index d4ad282701..cd66fc4ede 100644
--- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -1145,16 +1145,18 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea()
QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
{
- QQuickView *window = new QQuickView(nullptr);
+ QScopedPointer<QQuickView> window(new QQuickView(nullptr));
window->setSource(testFileUrl(file));
+ if (window->status() != QQuickView::Ready)
+ return nullptr;
const QRect screenGeometry = window->screen()->availableGeometry();
const QSize size = window->size();
const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
window->setFramePosition(screenGeometry.center() - offset);
window->show();
- QTest::qWaitForWindowExposed(window);
-
- return window;
+ if (!QTest::qWaitForWindowExposed(window.data()))
+ return nullptr;
+ return window.take();
}
void tst_QQuickMultiPointTouchArea::mouseInteraction_data()
diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
index 832b973d96..710caaa734 100644
--- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
+++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp
@@ -134,7 +134,7 @@ void tst_qquickrectangle::gradient_separate()
// Start off clean
QQuickItemPrivate *rectPriv = QQuickItemPrivate::get(rect);
- QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0);
+ QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0u);
QMetaObject::invokeMethod(rect, "changeGradient");