From bb2dce1d902405acfd5aaf997860c0f0318bce77 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 7 Feb 2019 12:34:36 +0100 Subject: Try to fix flakiness in flickableinterop test The usual problem is that Flickable doesn't instantly jump to the expected position but moves there after a delay. Change-Id: Iafc9dd493b97629377e7f7c60ae7adde13427bae Reviewed-by: Shawn Rutledge --- .../quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp index cf2ac4a830..f4ed051e1f 100644 --- a/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp +++ b/tests/auto/quick/pointerhandlers/flickableinterop/tst_flickableinterop.cpp @@ -741,7 +741,7 @@ void tst_FlickableInterop::touchAndDragHandlerOnFlickable() QQuickTouchUtils::flush(window); } if (!(buttonDragHandler && !pressDelay)) - QVERIFY(flickable->contentY() >= dragThreshold); + QTRY_VERIFY(flickable->contentY() >= dragThreshold); if (buttonTapHandler) QCOMPARE(buttonTapHandler->isPressed(), false); touchSeq.release(1, p1, window).commit(); -- cgit v1.2.3 From 734f5a31c7a72d87a99103051ed327addae0ab99 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 8 Feb 2019 21:02:52 +0100 Subject: Remove blacklisting of several tests that are passing ...based on statistics visible in Grafana. Task-number: QTBUG-41895 Task-number: QTBUG-38209 Task-number: QTBUG-65978 Task-number: QTBUG-36804 Task-number: QTBUG-45466 Task-number: QTBUG-29062 Change-Id: If62d2413ede234d33b411e0ecb4f93ec6e0f8062 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickanimations/BLACKLIST | 2 -- tests/auto/quick/qquickbehaviors/BLACKLIST | 2 -- tests/auto/quick/qquickflickable/BLACKLIST | 4 ---- tests/auto/quick/qquickgridview/BLACKLIST | 2 -- tests/auto/quick/qquickimage/BLACKLIST | 4 ---- tests/auto/quick/qquicklistview/BLACKLIST | 2 -- tests/auto/quick/qquicktextinput/BLACKLIST | 3 --- 7 files changed, 19 deletions(-) delete mode 100644 tests/auto/quick/qquickbehaviors/BLACKLIST delete mode 100644 tests/auto/quick/qquickgridview/BLACKLIST delete mode 100644 tests/auto/quick/qquickimage/BLACKLIST delete mode 100644 tests/auto/quick/qquicktextinput/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickanimations/BLACKLIST b/tests/auto/quick/qquickanimations/BLACKLIST index e011db46b7..29a022b4fe 100644 --- a/tests/auto/quick/qquickanimations/BLACKLIST +++ b/tests/auto/quick/qquickanimations/BLACKLIST @@ -1,6 +1,4 @@ # QTBUG-45466 QTBUG-29062 [simpleProperty] osx-10.9 developer-build -[simplePath] -windows gcc developer-build diff --git a/tests/auto/quick/qquickbehaviors/BLACKLIST b/tests/auto/quick/qquickbehaviors/BLACKLIST deleted file mode 100644 index 9be4da176d..0000000000 --- a/tests/auto/quick/qquickbehaviors/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[currentValue] -windows diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST index cc91754e68..5d8719db08 100644 --- a/tests/auto/quick/qquickflickable/BLACKLIST +++ b/tests/auto/quick/qquickflickable/BLACKLIST @@ -1,7 +1,3 @@ # QTBUG-26696 [rebound] osx -[stopAtBounds] -windows developer-build -[returnToBounds] -osx diff --git a/tests/auto/quick/qquickgridview/BLACKLIST b/tests/auto/quick/qquickgridview/BLACKLIST deleted file mode 100644 index 9eb9940aa5..0000000000 --- a/tests/auto/quick/qquickgridview/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[snapOneRow:horizontal, right to left] -windows diff --git a/tests/auto/quick/qquickimage/BLACKLIST b/tests/auto/quick/qquickimage/BLACKLIST deleted file mode 100644 index d15fae1b67..0000000000 --- a/tests/auto/quick/qquickimage/BLACKLIST +++ /dev/null @@ -1,4 +0,0 @@ -# QTBUG-65978 -[nullPixmapPaint] -b2qt - diff --git a/tests/auto/quick/qquicklistview/BLACKLIST b/tests/auto/quick/qquicklistview/BLACKLIST index 15aea4be19..e22d52294f 100644 --- a/tests/auto/quick/qquicklistview/BLACKLIST +++ b/tests/auto/quick/qquicklistview/BLACKLIST @@ -1,5 +1,3 @@ -[QTBUG_38209] -* [enforceRange_withoutHighlight] osx #QTBUG-53863 diff --git a/tests/auto/quick/qquicktextinput/BLACKLIST b/tests/auto/quick/qquicktextinput/BLACKLIST deleted file mode 100644 index e9f4f11c58..0000000000 --- a/tests/auto/quick/qquicktextinput/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -# QTBUG-41895 -[tripleClickSelectsAll] -windows -- cgit v1.2.3 From 24a686077579b04874f956a1dbb212a91836b64e Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sun, 10 Feb 2019 21:21:36 +0100 Subject: Un-blacklist tst_qquickflickable::rebound Fixes: QTBUG-26696 Change-Id: I32cebc9e0b63b55113f24fd40c06e7017b763aaf Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickflickable/BLACKLIST | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 tests/auto/quick/qquickflickable/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST deleted file mode 100644 index 5d8719db08..0000000000 --- a/tests/auto/quick/qquickflickable/BLACKLIST +++ /dev/null @@ -1,3 +0,0 @@ -# QTBUG-26696 -[rebound] -osx -- cgit v1.2.3 From f2cc7c8580f2a25554cf37426096935c62a5b7af Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Sun, 10 Feb 2019 21:17:53 +0100 Subject: Un-blacklist tst_qquickanimations macOS 10.9 is no longer supported. Fixes: QTBUG-45466 Change-Id: I44ce5e6c7d941cf21d937fb0cfe54ee418d28c4e Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickanimations/BLACKLIST | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/auto/quick/qquickanimations/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/qquickanimations/BLACKLIST b/tests/auto/quick/qquickanimations/BLACKLIST deleted file mode 100644 index 29a022b4fe..0000000000 --- a/tests/auto/quick/qquickanimations/BLACKLIST +++ /dev/null @@ -1,4 +0,0 @@ -# QTBUG-45466 QTBUG-29062 -[simpleProperty] -osx-10.9 developer-build - -- cgit v1.2.3 From a804f31ee2665501c1894cbae8302db181090bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 7 Feb 2019 13:22:49 +0100 Subject: Move initView() to tests/auto/quick/shared According to our "Coin - Flaky Tests" dashboard on our grafana, initView() in tst_qquickmousearea seems to have very few flakiness issues in actually exposing a QQuickView. It is therefore a good idea to share this implementation so that it can be used by other tests too. Change-Id: Ie83cbf7d00fa02bdd4699757471fa180945851e3 Reviewed-by: Shawn Rutledge --- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 109 ++++++++------------- tests/auto/quick/shared/viewtestutil.cpp | 27 +++++ tests/auto/quick/shared/viewtestutil.h | 4 + 3 files changed, 73 insertions(+), 67 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 558ca2e759..52d1458a53 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -43,31 +43,6 @@ #include #include -// Initialize view, set Url, center in available geometry, move mouse away if desired -static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage) -{ - v.setBaseSize(QSize(240,320)); - v.setSource(url); - while (v.status() == QQuickView::Loading) - QTest::qWait(10); - if (v.status() != QQuickView::Ready) { - foreach (const QQmlError &e, v.errors()) - errorMessage->append(e.toString().toLocal8Bit() + '\n'); - return false; - } - const QRect screenGeometry = v.screen()->availableGeometry(); - const QSize size = v.size(); - const QPoint offset = QPoint(size.width() / 2, size.height() / 2); - v.setFramePosition(screenGeometry.center() - offset); -#if QT_CONFIG(cursor) // Get the cursor out of the way. - if (moveMouseOut) - QCursor::setPos(v.geometry().topRight() + QPoint(100, 100)); -#else - Q_UNUSED(moveMouseOut) -#endif - return true; -} - class CircleMask : public QObject { Q_OBJECT @@ -235,7 +210,7 @@ void tst_QQuickMouseArea::dragProperties() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragproperties.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragproperties.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -333,7 +308,7 @@ void tst_QQuickMouseArea::resetDrag() QQuickView window; QByteArray errorMessage; window.rootContext()->setContextProperty("haveTarget", QVariant(true)); - QVERIFY2(initView(window, testFileUrl("dragreset.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragreset.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -363,7 +338,7 @@ void tst_QQuickMouseArea::dragging() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -428,7 +403,7 @@ void tst_QQuickMouseArea::dragSmoothed() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -482,7 +457,7 @@ void tst_QQuickMouseArea::dragThreshold() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -540,7 +515,7 @@ void tst_QQuickMouseArea::invalidDrag() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -589,7 +564,7 @@ void tst_QQuickMouseArea::cancelDragging() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -644,7 +619,7 @@ void tst_QQuickMouseArea::availableDistanceLessThanDragThreshold() { QQuickView view; QByteArray errorMessage; - QVERIFY2(initView(view, testFileUrl("availableDistanceLessThanDragThreshold.qml"), true, &errorMessage), + QVERIFY2(QQuickTest::initView(view, testFileUrl("availableDistanceLessThanDragThreshold.qml"), true, &errorMessage), errorMessage.constData()); view.show(); view.requestActivate(); @@ -672,7 +647,7 @@ void tst_QQuickMouseArea::setDragOnPressed() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("setDragOnPressed.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("setDragOnPressed.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -716,7 +691,7 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnClick() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("updateMousePosOnClick.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("updateMousePosOnClick.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -744,7 +719,7 @@ void tst_QQuickMouseArea::updateMouseAreaPosOnResize() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("updateMousePosOnResize.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("updateMousePosOnResize.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -780,7 +755,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() // We handle onPressAndHold, therefore no onClicked QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("clickandhold.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("clickandhold.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -812,7 +787,7 @@ void tst_QQuickMouseArea::noOnClickedWithPressAndHold() // We do not handle onPressAndHold, therefore we get onClicked QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("noclickandhold.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("noclickandhold.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -835,7 +810,7 @@ void tst_QQuickMouseArea::onMousePressRejected() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("rejectEvent.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("rejectEvent.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -882,7 +857,7 @@ void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("pressedCanceled.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("pressedCanceled.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -955,7 +930,7 @@ void tst_QQuickMouseArea::doubleClick() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -992,7 +967,7 @@ void tst_QQuickMouseArea::clickTwice() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("clicktwice.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("clicktwice.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1028,7 +1003,7 @@ void tst_QQuickMouseArea::invalidClick() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("doubleclick.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1061,7 +1036,7 @@ void tst_QQuickMouseArea::pressedOrdering() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("pressedOrdering.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("pressedOrdering.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1087,7 +1062,7 @@ void tst_QQuickMouseArea::preventStealing() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("preventstealing.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("preventstealing.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1161,7 +1136,7 @@ void tst_QQuickMouseArea::clickThrough() //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers QScopedPointer window(new QQuickView); QByteArray errorMessage; - QVERIFY2(initView(*window.data(), testFileUrl("clickThrough.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(*window.data(), testFileUrl("clickThrough.qml"), true, &errorMessage), errorMessage.constData()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != nullptr); @@ -1195,7 +1170,7 @@ void tst_QQuickMouseArea::clickThrough() window.reset(new QQuickView); //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored - QVERIFY2(initView(*window.data(), testFileUrl("clickThrough2.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(*window.data(), testFileUrl("clickThrough2.qml"), true, &errorMessage), errorMessage.constData()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != nullptr); @@ -1269,7 +1244,7 @@ void tst_QQuickMouseArea::clickThrough() window.reset(new QQuickView); //QTBUG-34368 - Shouldn't propagate to disabled mouse areas - QVERIFY2(initView(*window.data(), testFileUrl("qtbug34368.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(*window.data(), testFileUrl("qtbug34368.qml"), true, &errorMessage), errorMessage.constData()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != nullptr); @@ -1291,7 +1266,7 @@ void tst_QQuickMouseArea::clickThrough() window.reset(new QQuickView); //QTBUG-49100 - QVERIFY2(initView(*window.data(), testFileUrl("qtbug49100.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(*window.data(), testFileUrl("qtbug49100.qml"), true, &errorMessage), errorMessage.constData()); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); QVERIFY(window->rootObject() != nullptr); @@ -1306,7 +1281,7 @@ void tst_QQuickMouseArea::hoverPosition() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("hoverPosition.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("hoverPosition.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1325,7 +1300,7 @@ void tst_QQuickMouseArea::hoverPropagation() //QTBUG-18175, to behave like GV did. QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("hoverPropagation.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("hoverPropagation.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1352,7 +1327,7 @@ void tst_QQuickMouseArea::hoverVisible() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("hoverVisible.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("hoverVisible.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1380,7 +1355,7 @@ void tst_QQuickMouseArea::hoverAfterPress() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("hoverAfterPress.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("hoverAfterPress.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1406,7 +1381,7 @@ void tst_QQuickMouseArea::subtreeHoverEnabled() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("qtbug54019.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("qtbug54019.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1426,7 +1401,7 @@ void tst_QQuickMouseArea::disableAfterPress() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("dragging.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1529,7 +1504,7 @@ void tst_QQuickMouseArea::onWheel() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("wheel.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("wheel.qml"), true, &errorMessage), errorMessage.constData()); QQuickItem *root = window.rootObject(); QVERIFY(root != nullptr); @@ -1573,7 +1548,7 @@ void tst_QQuickMouseArea::transformedMouseArea() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("transformedMouseArea.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("transformedMouseArea.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject() != nullptr); @@ -1681,7 +1656,7 @@ void tst_QQuickMouseArea::pressedMultipleButtons() QQuickView view; QByteArray errorMessage; - QVERIFY2(initView(view, testFileUrl("simple.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(view, testFileUrl("simple.qml"), true, &errorMessage), errorMessage.constData()); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QVERIFY(view.rootObject() != nullptr); @@ -1712,7 +1687,7 @@ void tst_QQuickMouseArea::changeAxis() { QQuickView view; QByteArray errorMessage; - QVERIFY2(initView(view, testFileUrl("changeAxis.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(view, testFileUrl("changeAxis.qml"), true, &errorMessage), errorMessage.constData()); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QTRY_VERIFY(view.rootObject() != nullptr); @@ -1805,7 +1780,7 @@ void tst_QQuickMouseArea::moveAndReleaseWithoutPress() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("moveAndReleaseWithoutPress.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("moveAndReleaseWithoutPress.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -1845,7 +1820,7 @@ void tst_QQuickMouseArea::nestedStopAtBounds() QQuickView view; QByteArray errorMessage; - QVERIFY2(initView(view, testFileUrl("nestedStopAtBounds.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(view, testFileUrl("nestedStopAtBounds.qml"), true, &errorMessage), errorMessage.constData()); view.show(); view.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&view)); @@ -1898,7 +1873,7 @@ void tst_QQuickMouseArea::nestedFlickableStopAtBounds() { QQuickView view; QByteArray errorMessage; - QVERIFY2(initView(view, testFileUrl("nestedFlickableStopAtBounds.qml"), false, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(view, testFileUrl("nestedFlickableStopAtBounds.qml"), false, &errorMessage), errorMessage.constData()); view.show(); view.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&view)); @@ -2000,7 +1975,7 @@ void tst_QQuickMouseArea::containsPress() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("containsPress.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("containsPress.qml"), true, &errorMessage), errorMessage.constData()); window.show(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -2053,7 +2028,7 @@ void tst_QQuickMouseArea::ignoreBySource() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("ignoreBySource.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("ignoreBySource.qml"), true, &errorMessage), errorMessage.constData()); window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); QVERIFY(window.rootObject()); @@ -2194,7 +2169,7 @@ void tst_QQuickMouseArea::pressAndHold() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("pressAndHold.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("pressAndHold.qml"), true, &errorMessage), errorMessage.constData()); window.show(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -2239,7 +2214,7 @@ void tst_QQuickMouseArea::pressOneAndTapAnother() QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("twoMouseAreas.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("twoMouseAreas.qml"), true, &errorMessage), errorMessage.constData()); window.show(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&window)); @@ -2292,7 +2267,7 @@ void tst_QQuickMouseArea::mask() { QQuickView window; QByteArray errorMessage; - QVERIFY2(initView(window, testFileUrl("mask.qml"), true, &errorMessage), errorMessage.constData()); + QVERIFY2(QQuickTest::initView(window, testFileUrl("mask.qml"), true, &errorMessage), errorMessage.constData()); window.show(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowExposed(&window)); diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index 3bfa23173e..12d54c4bbe 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -451,3 +451,30 @@ namespace QQuickTouchUtils { } } + +namespace QQuickTest { + // Initialize view, set Url, center in available geometry, move mouse away if desired + bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage) + { + v.setBaseSize(QSize(240,320)); + v.setSource(url); + while (v.status() == QQuickView::Loading) + QTest::qWait(10); + if (v.status() != QQuickView::Ready) { + foreach (const QQmlError &e, v.errors()) + errorMessage->append(e.toString().toLocal8Bit() + '\n'); + return false; + } + const QRect screenGeometry = v.screen()->availableGeometry(); + const QSize size = v.size(); + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + v.setFramePosition(screenGeometry.center() - offset); + #if QT_CONFIG(cursor) // Get the cursor out of the way. + if (moveMouseOut) + QCursor::setPos(v.geometry().topRight() + QPoint(100, 100)); + #else + Q_UNUSED(moveMouseOut) + #endif + return true; + } +} diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h index 04e1771ef8..3b57a29777 100644 --- a/tests/auto/quick/shared/viewtestutil.h +++ b/tests/auto/quick/shared/viewtestutil.h @@ -185,6 +185,10 @@ namespace QQuickTouchUtils { void flush(QQuickWindow *window); } +namespace QQuickTest { + bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArray *errorMessage); +} + Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList) -- cgit v1.2.3 From eeedd26f35369a61d66283b8e2994a6e87c314fe Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 12 Feb 2019 09:33:03 +0100 Subject: Fix background color of some QML lancelot test scenes Avoid red since that is also used for marking visual diffs in the lancelot results. Replace with a great color. Change-Id: I1da4d1b6dc3cacbd3b5b2574720fcd3176f49a52 Reviewed-by: Paul Olav Tvete --- .../data/borderimages/borderimage_borders_exceed_height.qml | 2 +- .../data/borderimages/borderimage_borders_exceed_width.qml | 2 +- .../data/borderimages/borderimage_rotated_smoothed.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml | 2 +- .../borderimages/borderimage_rotated_unsmoothed_negative_borders.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_center.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_left.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_right.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_top.qml | 2 +- .../data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml index c4321d25bb..1e2885baed 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_height.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml index 328ff40008..437f10dd97 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_borders_exceed_width.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml index 804567cf19..12c600c4af 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_smoothed.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml index b10554ad66..c3d4e5b018 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml index 73cc53ed2b..5d645902ec 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_border_overlap.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml index 8356f02614..153b77d642 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_negative_borders.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml index 9213589648..687a54ee80 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_borders.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml index 615abdee20..70bd5c0f14 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_bottom.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml index 58ed4d44dc..98d2b867b8 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_center.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml index 7e0045bf24..64cd9d30cc 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_left.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml index 04c2d021f0..6d63475cfd 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml index 5210bab321..6d2193633a 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_right_left.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml index 2e89496c92..c3c8dfb7f4 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 diff --git a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml index 4388601f13..a32827cfc3 100644 --- a/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml +++ b/tests/manual/scenegraph_lancelot/data/borderimages/borderimage_rotated_unsmoothed_no_top_bottom.qml @@ -4,7 +4,7 @@ Rectangle { width: 320 height: 480 - color: "red" + color: "#C0FEFE" Item { x: 80 -- cgit v1.2.3 From 01f9c623ed2dc1645ac022d69062f720e3b50132 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 13 Feb 2019 09:17:10 +0100 Subject: Don't optimize global lookups if fast QML lookups are disabled If fast QML lookups are disabled, we generally want to look up by string. If the name then happens to be a member of the global JavaScript object, we still don't want to directly access that, as the name could have been overridden in a deeper context. Fixes: QTBUG-73750 Change-Id: Id16110969123d91501064ba46bfad4c2a39e4650 Reviewed-by: Simon Hausmann --- .../qqmlconnections/data/override-proxy-type.qml | 13 +++++++++++ .../qml/qqmlconnections/tst_qqmlconnections.cpp | 25 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/auto/qml/qqmlconnections/data/override-proxy-type.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml b/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml new file mode 100644 index 0000000000..80e459966b --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/override-proxy-type.qml @@ -0,0 +1,13 @@ +import QtQml 2.12 +import test.proxy 1.0 + +Proxy { + property int testEnum: 0; + id: proxy + property Connections connections: Connections { + target: proxy + onSomeSignal: testEnum = Proxy.EnumValue; + } + + Component.onCompleted: someSignal() +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index 8ef00f8080..dc29363fcf 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -55,6 +55,7 @@ private slots: void disabledAtStart(); void clearImplicitTarget(); void onWithoutASignal(); + void noAcceleratedGlobalLookup(); private: QQmlEngine engine; @@ -407,6 +408,30 @@ void tst_qqmlconnections::onWithoutASignal() QVERIFY(item == nullptr); // should parse error, and not give us an item (or crash). } +class Proxy : public QObject +{ + Q_OBJECT +public: + enum MyEnum { EnumValue = 20, AnotherEnumValue }; + Q_ENUM(MyEnum) + +signals: + void someSignal(); +}; + +void tst_qqmlconnections::noAcceleratedGlobalLookup() +{ + qRegisterMetaType(); + qmlRegisterType("test.proxy", 1, 0, "Proxy"); + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("override-proxy-type.qml")); + QVERIFY(c.isReady()); + QScopedPointer object(c.create()); + const QVariant val = object->property("testEnum"); + QCOMPARE(val.type(), QMetaType::Int); + QCOMPARE(val.toInt(), int(Proxy::EnumValue)); +} + QTEST_MAIN(tst_qqmlconnections) #include "tst_qqmlconnections.moc" -- cgit v1.2.3 From 1e3ed172f35abaa0e0af43ee22259bc3cd188ad8 Mon Sep 17 00:00:00 2001 From: Michal Policht Date: Wed, 6 Feb 2019 14:58:59 +0100 Subject: Connect quit() and exit() signals with queued connections Class QQmlApplicationEngine connects QQmlApplicationEngine::quit() signal to QCoreApplication::quit() and QQmlApplicationEngine::exit() signal to QCoreApplication::exit(), but it does so with AutoConnection. This causes in some circumstances problems, which are described in Qt documentation (see QCoreApplication::exit()). This change modifies type of connections to queued connections. [ChangeLog][QtQml][QQmlApplicationEngine] QQmlApplicationEngine connects quit() and exit() signals with queued connections to avoid problems with AutoConnection, when connecting to QCoreApplication slots. Task-number: QTBUG-73649 Change-Id: Ib27738b5af2f879efee8862b1ca01613a2e8dc4e Reviewed-by: Ulf Hermann --- .../qqmlapplicationengine/testapp/delayedExit.qml | 11 ++++++ .../qqmlapplicationengine/testapp/delayedQuit.qml | 11 ++++++ .../testapp/immediateExit.qml | 8 ++++ .../testapp/immediateQuit.qml | 8 ++++ .../qml/qqmlapplicationengine/testapp/main.cpp | 2 +- .../qml/qqmlapplicationengine/testapp/main.qml | 11 ------ .../qml/qqmlapplicationengine/testapp/main.qrc | 5 ++- .../tst_qqmlapplicationengine.cpp | 44 ++++++++++++++++------ 8 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml create mode 100644 tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml create mode 100644 tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml create mode 100644 tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml delete mode 100644 tests/auto/qml/qqmlapplicationengine/testapp/main.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml new file mode 100644 index 0000000000..3d67c958bb --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/delayedExit.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 + +QtObject { + id: root + property Timer t: Timer { interval: 1; running: true; onTriggered: Qt.exit(0); } + property Connections c: Connections { + target: Qt.application + onAboutToQuit: console.log("End"); + } + Component.onCompleted: console.log("Start: " + Qt.application.arguments[1]); +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml new file mode 100644 index 0000000000..c75485a7f7 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/delayedQuit.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 + +QtObject { + id: root + property Timer t: Timer { interval: 1; running: true; onTriggered: Qt.quit(); } + property Connections c: Connections { + target: Qt.application + onAboutToQuit: console.log("End"); + } + Component.onCompleted: console.log("Start: " + Qt.application.arguments[1]); +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml new file mode 100644 index 0000000000..46634f3f51 --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/immediateExit.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + console.log("End: " + Qt.application.arguments[1]); + Qt.exit(0) + } +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml b/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml new file mode 100644 index 0000000000..1da9d1201a --- /dev/null +++ b/tests/auto/qml/qqmlapplicationengine/testapp/immediateQuit.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +QtObject { + Component.onCompleted: { + console.log("End: " + Qt.application.arguments[1]); + Qt.quit() + } +} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp index a57889fe86..be0d98a2df 100644 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.cpp @@ -32,6 +32,6 @@ int main (int argc, char *argv[]) { QCoreApplication app(argc, argv); - QQmlApplicationEngine e(QUrl("qrc:///main.qml")); + QQmlApplicationEngine e(QUrl(QString("qrc:///") + argv[1])); return app.exec(); } diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qml b/tests/auto/qml/qqmlapplicationengine/testapp/main.qml deleted file mode 100644 index c75485a7f7..0000000000 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQml 2.0 - -QtObject { - id: root - property Timer t: Timer { interval: 1; running: true; onTriggered: Qt.quit(); } - property Connections c: Connections { - target: Qt.application - onAboutToQuit: console.log("End"); - } - Component.onCompleted: console.log("Start: " + Qt.application.arguments[1]); -} diff --git a/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc index 5f6483ac33..82b695bbd8 100644 --- a/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc +++ b/tests/auto/qml/qqmlapplicationengine/testapp/main.qrc @@ -1,5 +1,8 @@ - main.qml + immediateQuit.qml + immediateExit.qml + delayedQuit.qml + delayedExit.qml diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index daeb9b5455..ce654dc45e 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -46,6 +46,7 @@ private slots: void initTestCase(); void basicLoading(); void testNonResolvedPath(); + void application_data(); void application(); void applicationProperties(); void removeObjectsWhenDestroyed(); @@ -111,35 +112,56 @@ void tst_qqmlapplicationengine::testNonResolvedPath() } } +void tst_qqmlapplicationengine::application_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("expectedStdErr"); + + QTest::newRow("delayed quit") << QByteArray("delayedQuit.qml") + << QByteArray("qml: Start: delayedQuit.qml\nqml: End\n"); + QTest::newRow("delayed exit") << QByteArray("delayedExit.qml") + << QByteArray("qml: Start: delayedExit.qml\nqml: End\n"); + QTest::newRow("immediate quit") << QByteArray("immediateQuit.qml") + << QByteArray("qml: End: immediateQuit.qml\n"); + QTest::newRow("immediate exit") << QByteArray("immediateExit.qml") + << QByteArray("qml: End: immediateExit.qml\n"); +} + void tst_qqmlapplicationengine::application() { /* This test batches together some tests about running an external application written with QQmlApplicationEngine. The application tests the following functionality which is easier to do by watching a separate process: - -Loads relative paths from the working directory - -quits when quit is called - -emits aboutToQuit after quit is called - -has access to application command line arguments + - Loads relative paths from the working directory + - Quits when quit is called + - Exits when exit is called + - Emits aboutToQuit after quit is called + - Has access to application command line arguments Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ + + QFETCH(QByteArray, qmlFile); + QFETCH(QByteArray, expectedStdErr); + #if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; - args << QLatin1String("testData"); + args << qmlFile; // QML file passed as an argument is going to be run by testapp. testProcess->start(QLatin1String("testapp/testapp"), args); QVERIFY(testProcess->waitForFinished(5000)); QCOMPARE(testProcess->exitCode(), 0); - QByteArray test_stdout = testProcess->readAllStandardOutput(); - QByteArray test_stderr = testProcess->readAllStandardError(); - QByteArray test_stderr_target("qml: Start: testData\nqml: End\n"); + QByteArray testStdOut = testProcess->readAllStandardOutput(); + QByteArray testStdErr = testProcess->readAllStandardError(); #ifdef Q_OS_WIN - test_stderr_target.replace('\n', QByteArray("\r\n")); + expectedStdErr.replace('\n', QByteArray("\r\n")); #endif - QCOMPARE(test_stdout, QByteArray("")); - QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); + QCOMPARE(testStdOut, QByteArray("")); + QVERIFY2(QString(testStdErr).endsWith(QString(expectedStdErr)), + QByteArray("\nExpected ending:\n") + expectedStdErr + + QByteArray("\nActual output:\n") + testStdErr); delete testProcess; QDir::setCurrent(srcDir); #else // process -- cgit v1.2.3 From 68d0377736a541fa29d1aaba6b7aa4a4cf8781ef Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 13 Feb 2019 12:43:56 +0100 Subject: Make test more robust in case we have interleaved update events This could for instance happen if the window gets exposed under the cursor, and it sends a mouse move event that might interleave the press and release events, causing the eventCount variable to jump to 3. Change-Id: Icce59b2aa1a937a990baa83f503907633003e2bb Reviewed-by: Shawn Rutledge --- .../qquickpointerhandler/tst_qquickpointerhandler.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index feb356a7d5..2b6482465c 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -188,7 +188,10 @@ public: QQuickPointerHandler::handlePointerEventImpl(event); if (!enabled()) return; - ++eventCount; + if (event->isPressEvent()) + ++pressEventCount; + if (event->isReleaseEvent()) + ++releaseEventCount; EventItem *item = qmlobject_cast(target()); if (!item) { event->point(0)->setGrabberPointerHandler(this); @@ -218,7 +221,8 @@ public: static_cast(point->state()), stateChange, eventPos(point), point->scenePosition())); } - int eventCount = 0; + int pressEventCount = 0; + int releaseEventCount = 0; }; class tst_PointerHandlers : public QQmlDataTest @@ -646,9 +650,9 @@ void tst_PointerHandlers::handlerInWindow() QPoint p1(20, 20); QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); - QTRY_COMPARE(handler->eventCount, 1); + QTRY_COMPARE(handler->pressEventCount, 1); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); - QTRY_COMPARE(handler->eventCount, 2); + QTRY_COMPARE(handler->releaseEventCount, 1); } void tst_PointerHandlers::dynamicCreationInWindow() @@ -670,9 +674,9 @@ void tst_PointerHandlers::dynamicCreationInWindow() QPoint p1(20, 20); QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); - QTRY_COMPARE(handler->eventCount, 1); + QTRY_COMPARE(handler->pressEventCount, 1); QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); - QTRY_COMPARE(handler->eventCount, 2); + QTRY_COMPARE(handler->releaseEventCount, 1); } QTEST_MAIN(tst_PointerHandlers) -- cgit v1.2.3