aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-rw-r--r--tests/auto/particles/shared/particlestestsshared.h11
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp17
-rw-r--r--tests/auto/qml/qqmlmetatype/data/Components/App.qml57
-rw-r--r--tests/auto/qml/qqmlmetatype/data/Components/qmldir3
-rw-r--r--tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml11
-rw-r--r--tests/auto/qml/qqmlmetatype/qqmlmetatype.pro7
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp32
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp10
-rw-r--r--tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp4
-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
17 files changed, 291 insertions, 20 deletions
diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h
index 5ef1d2cabb..e1fc6f4ccd 100644
--- a/tests/auto/particles/shared/particlestestsshared.h
+++ b/tests/auto/particles/shared/particlestestsshared.h
@@ -31,6 +31,8 @@
#include <QtQuick/QQuickView>
#include <QtTest>
#include <QAbstractAnimation>
+#include <QScopedPointer>
+
const qreal EPSILON = 0.0001;
bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances
@@ -55,17 +57,18 @@ bool myFuzzyGEQ(qreal a, qreal b)
QQuickView* createView(const QUrl &filename, int additionalWait=0)
{
- QQuickView *view = new QQuickView(0);
+ QScopedPointer<QQuickView> view(new QQuickView(nullptr));
view->setSource(filename);
if (view->status() != QQuickView::Ready)
- return 0;
+ return nullptr;
view->show();
- QTest::qWaitForWindowExposed(view);
+ if (!QTest::qWaitForWindowExposed(view.data()))
+ return nullptr;
if (additionalWait)
QTest::qWait(additionalWait);
- return view;
+ return view.take();
}
void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes...
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 2436882318..98f9bfe3ef 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -366,6 +366,7 @@ private slots:
void tailCallWithArguments();
void deleteSparseInIteration();
void saveAccumulatorBeforeToInt32();
+ void intMinDividedByMinusOne();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8967,6 +8968,22 @@ void tst_qqmlecmascript::saveAccumulatorBeforeToInt32()
QCOMPARE(value.toString(), QLatin1String("RangeError: Maximum call stack size exceeded."));
}
+void tst_qqmlecmascript::intMinDividedByMinusOne()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQml 2.2\n"
+ "QtObject {\n"
+ " property int intMin: -2147483648\n"
+ " property int minusOne: -1\n"
+ " property double doesNotFitInInt: intMin / minusOne\n"
+ "}"), QUrl());
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+ QCOMPARE(object->property("doesNotFitInInt").toUInt(), 2147483648u);
+}
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlmetatype/data/Components/App.qml b/tests/auto/qml/qqmlmetatype/data/Components/App.qml
new file mode 100644
index 0000000000..3792ca665e
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/Components/App.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml 2.0
+
+import Components 1.0
+
+QtObject {
+ id: mainRect
+
+ property int appState: App.AppState.Blue
+ property string color: "blue"
+
+ enum AppState {
+ Red,
+ Green,
+ Blue
+ }
+
+ onAppStateChanged: {
+ if (appState === App.AppState.Green)
+ mainRect.color = "green"
+ else if (appState === App.AppState.Red)
+ mainRect.color = "red"
+ }
+
+ property Timer timer: Timer {
+ onTriggered: appState = App.AppState.Green
+ running: true
+ interval: 100
+ }
+}
diff --git a/tests/auto/qml/qqmlmetatype/data/Components/qmldir b/tests/auto/qml/qqmlmetatype/data/Components/qmldir
new file mode 100644
index 0000000000..3f6db4ed2d
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/Components/qmldir
@@ -0,0 +1,3 @@
+module Components
+
+App 1.0 App.qml
diff --git a/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml
new file mode 100644
index 0000000000..eef6abc6e5
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml
@@ -0,0 +1,11 @@
+import QtQml 2.0
+
+import Components 1.0
+
+QtObject {
+ property App app: App {
+ appState: 0
+ }
+
+ property string color: app.color
+}
diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
index 345bc59615..109de7d212 100644
--- a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
+++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
@@ -10,4 +10,11 @@ qmlfiles.files = data/CompositeType.qml
qmlfiles.prefix = /tstqqmlmetatype
RESOURCES += qmlfiles
+qmldirresource.files = \
+ data/Components/App.qml \
+ data/Components/qmldir \
+ data/enumsInRecursiveImport.qml
+qmldirresource.prefix = /
+RESOURCES += qmldirresource
+
QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index ac75eeab26..1878cccd39 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -66,6 +66,9 @@ private slots:
void normalizeUrls();
void unregisterAttachedProperties();
void revisionedGroupedProperties();
+
+ void enumsInRecursiveImport_data();
+ void enumsInRecursiveImport();
};
class TestType : public QObject
@@ -628,6 +631,35 @@ void tst_qqmlmetatype::revisionedGroupedProperties()
}
}
+void tst_qqmlmetatype::enumsInRecursiveImport_data()
+{
+ QTest::addColumn<QString>("importPath");
+ QTest::addColumn<QUrl>("componentUrl");
+
+ QTest::addRow("data directory") << dataDirectory()
+ << testFileUrl("enumsInRecursiveImport.qml");
+
+ // The qrc case behaves differently because we failed to detect the recursion in type loading
+ // due to varying numbers of slashes after the "qrc:" in the URLs.
+ QTest::addRow("resources") << QStringLiteral("qrc:/data")
+ << QUrl("qrc:/data/enumsInRecursiveImport.qml");
+}
+
+void tst_qqmlmetatype::enumsInRecursiveImport()
+{
+ QFETCH(QString, importPath);
+ QFETCH(QUrl, componentUrl);
+
+ qmlClearTypeRegistrations();
+ QQmlEngine engine;
+ engine.addImportPath(importPath);
+ QQmlComponent c(&engine, componentUrl);
+ QVERIFY(c.isReady());
+ QScopedPointer<QObject> obj(c.create());
+ QVERIFY(!obj.isNull());
+ QTRY_COMPARE(obj->property("color").toString(), QString("green"));
+}
+
QTEST_MAIN(tst_qqmlmetatype)
#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index 71dd900073..fead8c4ebc 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -234,8 +234,8 @@ void tst_qqmlparser::stringLiteral()
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
QVERIFY(literal);
QCOMPARE(literal->value, "hello string");
- QCOMPARE(literal->firstSourceLocation().begin(), 0);
- QCOMPARE(literal->lastSourceLocation().end(), code.size());
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
}
void tst_qqmlparser::noSubstitutionTemplateLiteral()
@@ -255,8 +255,8 @@ void tst_qqmlparser::noSubstitutionTemplateLiteral()
QVERIFY(literal);
QCOMPARE(literal->value, "hello template");
- QCOMPARE(literal->firstSourceLocation().begin(), 0);
- QCOMPARE(literal->lastSourceLocation().end(), code.size());
+ QCOMPARE(literal->firstSourceLocation().begin(), 0u);
+ QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
}
void tst_qqmlparser::templateLiteral()
@@ -275,7 +275,7 @@ void tst_qqmlparser::templateLiteral()
auto *templateLiteral = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
QVERIFY(templateLiteral);
- QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0);
+ QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0u);
auto *e = templateLiteral->expression;
QVERIFY(e);
}
diff --git a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
index 095943cdc7..308fba9049 100644
--- a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
+++ b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp
@@ -67,8 +67,8 @@ void tst_qv4identifiertable::sweepFirstEntryInBucket()
table.asPropertyKey(entry2);
table.asPropertyKey(entry3);
- QCOMPARE(table.size, 3);
- QCOMPARE(table.alloc, 5);
+ QCOMPARE(table.size, 3u);
+ QCOMPARE(table.alloc, 5u);
QCOMPARE(table.entriesByHash[0], entry1);
QCOMPARE(table.entriesByHash[1], entry2);
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");