diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-10 15:09:37 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-03-12 15:03:03 +0100 |
commit | 26c5243491f495194f04b449128dae36118e28da (patch) | |
tree | 7fb14678a6fc9e44a10c9224d005e2cbdc6bcb63 /tests/auto/quick | |
parent | 1c7d264e3b2e9a2f0021786ea6967185f8282af0 (diff) | |
parent | c24c5baeda4101b0058689adf9200b77a722c3a2 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Conflicts:
dependencies.yaml
src/qml/qml/qqmlengine.cpp
Change-Id: I6a73fd1064286f4a2232de85c2ce7f80452d4641
Diffstat (limited to 'tests/auto/quick')
37 files changed, 1235 insertions, 23 deletions
diff --git a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp index 9bcc21c77d..39f4c3c70a 100644 --- a/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp +++ b/tests/auto/quick/drawingmodes/tst_drawingmodes.cpp @@ -34,7 +34,7 @@ #include <QtQuick/qsggeometry.h> #include <QtQuick/qsgflatcolormaterial.h> #include <QtGui/qscreen.h> -#include <QtGui/qopenglcontext.h> +#include <qopenglcontext.h> #include "../../shared/util.h" diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml index 7b3601bea0..81fa20f3bb 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/draggables.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -26,7 +26,7 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.15 Item { id: root @@ -47,6 +47,7 @@ Item { DragHandler { id: dragHandler objectName: "DragHandler " + (index + 1) + cursorShape: Qt.ClosedHandCursor } Text { diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index 65c5ac9ef4..47cfd27817 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -249,8 +249,11 @@ void tst_DragHandler::mouseDrag() QPointF ballCenter = ball->clipRect().center(); QPointF scenePressPos = ball->mapToScene(ballCenter); QPoint p1 = scenePressPos.toPoint(); - QTest::mousePress(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1); + QTest::mousePress(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1, 500); QVERIFY(!dragHandler->active()); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif if (shouldDrag) { QCOMPARE(dragHandler->centroid().position(), ballCenter); QCOMPARE(dragHandler->centroid().pressPosition(), ballCenter); @@ -265,6 +268,9 @@ void tst_DragHandler::mouseDrag() QTRY_VERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 2); QVERIFY(!dragHandler->active()); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } p1 += QPoint(1, 0); QTest::mouseMove(window, p1); @@ -292,6 +298,9 @@ void tst_DragHandler::mouseDrag() QCOMPARE(dragHandler->translation().y(), 0.0); QVERIFY(dragHandler->centroid().velocity().x() > 0); QCOMPARE(centroidChangedSpy.count(), 4); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor); +#endif } QTest::mouseRelease(window, static_cast<Qt::MouseButton>(int(dragButton)), Qt::NoModifier, p1); QTRY_VERIFY(!dragHandler->active()); @@ -300,6 +309,10 @@ void tst_DragHandler::mouseDrag() QCOMPARE(ball->mapToScene(ballCenter).toPoint(), p1); QCOMPARE(translationChangedSpy.count(), shouldDrag ? 1 : 0); QCOMPARE(centroidChangedSpy.count(), shouldDrag ? 5 : 0); +#if QT_CONFIG(cursor) + QTest::mouseMove(window, p1 + QPoint(1, 0)); // TODO after fixing QTBUG-53987, don't send mouseMove + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_DragHandler::mouseDragThreshold_data() diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST b/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST new file mode 100644 index 0000000000..9bb35c4770 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/BLACKLIST @@ -0,0 +1,3 @@ +[movingItemWithHoverHandler] +macos # Can't move cursor (QTBUG-76312) + diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml index 011dc4e75f..38a19c57c5 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/data/lesHoverables.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -26,7 +26,7 @@ ** ****************************************************************************/ -import QtQuick 2.12 +import QtQuick 2.15 Rectangle { id: root @@ -52,6 +52,7 @@ Rectangle { id: buttonMA objectName: "buttonMA" hoverEnabled: true + cursorShape: Qt.UpArrowCursor anchors.fill: parent onClicked: console.log("clicked MA") } @@ -74,9 +75,12 @@ Rectangle { id: buttonHH objectName: "buttonHH" acceptedDevices: PointerDevice.AllDevices + cursorShape: tapHandler.pressed ? Qt.BusyCursor : Qt.PointingHandCursor } - TapHandler { } + TapHandler { + id: tapHandler + } Text { anchors.centerIn: parent @@ -127,6 +131,7 @@ Rectangle { HoverHandler { id: topSidebarHH objectName: "topSidebarHH" + cursorShape: Qt.OpenHandCursor } Loader { @@ -152,6 +157,7 @@ Rectangle { id: bottomSidebarMA objectName: "bottomSidebarMA" hoverEnabled: true + cursorShape: Qt.ClosedHandCursor anchors.fill: parent } diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp index 575139f851..61f2752dd2 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp @@ -104,30 +104,45 @@ void tst_HoverHandler::hoverHandlerAndUnderlyingHoverHandler() QCOMPARE(sidebarHoveredSpy.count(), 0); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor); +#endif QTest::mouseMove(window, buttonCenter); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonHH->isHovered(), true); QCOMPARE(buttonHoveredSpy.count(), 1); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::PointingHandCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor); +#endif QTest::mouseMove(window, outOfSidebar); QCOMPARE(topSidebarHH->isHovered(), false); QCOMPARE(sidebarHoveredSpy.count(), 2); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_HoverHandler::mouseAreaAndUnderlyingHoverHandler() @@ -153,30 +168,45 @@ void tst_HoverHandler::mouseAreaAndUnderlyingHoverHandler() QCOMPARE(sidebarHoveredSpy.count(), 0); QCOMPARE(buttonMA->hovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonMA->hovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor); +#endif QTest::mouseMove(window, buttonCenter); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonMA->hovered(), true); QCOMPARE(buttonHoveredSpy.count(), 1); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::UpArrowCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(topSidebarHH->isHovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonMA->hovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::OpenHandCursor); +#endif QTest::mouseMove(window, outOfSidebar); QCOMPARE(topSidebarHH->isHovered(), false); QCOMPARE(sidebarHoveredSpy.count(), 2); QCOMPARE(buttonMA->hovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_HoverHandler::hoverHandlerAndUnderlyingMouseArea() @@ -204,30 +234,45 @@ void tst_HoverHandler::hoverHandlerAndUnderlyingMouseArea() QCOMPARE(sidebarHoveredSpy.count(), 0); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(bottomSidebarMA->hovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 1); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 0); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor); +#endif QTest::mouseMove(window, buttonCenter); QCOMPARE(bottomSidebarMA->hovered(), false); QCOMPARE(sidebarHoveredSpy.count(), 2); QCOMPARE(buttonHH->isHovered(), true); QCOMPARE(buttonHoveredSpy.count(), 1); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::PointingHandCursor); +#endif QTest::mouseMove(window, rightOfButton); QCOMPARE(bottomSidebarMA->hovered(), true); QCOMPARE(sidebarHoveredSpy.count(), 3); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ClosedHandCursor); +#endif QTest::mouseMove(window, outOfSidebar); QCOMPARE(bottomSidebarMA->hovered(), false); QCOMPARE(sidebarHoveredSpy.count(), 4); QCOMPARE(buttonHH->isHovered(), false); QCOMPARE(buttonHoveredSpy.count(), 2); +#if QT_CONFIG(cursor) + QCOMPARE(window->cursor().shape(), Qt::ArrowCursor); +#endif } void tst_HoverHandler::movingItemWithHoverHandler() @@ -255,6 +300,7 @@ void tst_HoverHandler::movingItemWithHoverHandler() QVERIFY(QTest::qWaitForWindowExposed(window)); QTRY_COMPARE(paddleHH->isHovered(), true); + // TODO check the cursor shape after fixing QTBUG-53987 paddle->setX(100); QTRY_COMPARE(paddleHH->isHovered(), false); diff --git a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp index d0b3bc3d36..ca6463f365 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointhandler/tst_qquickpointhandler.cpp @@ -55,6 +55,7 @@ private slots: void initTestCase(); void singleTouch(); + void tabletStylus(); void simultaneousMultiTouch(); void pressedMultipleButtons_data(); void pressedMultipleButtons(); @@ -136,6 +137,65 @@ void tst_PointHandler::singleTouch() QCOMPARE(translationSpy.count(), 3); } +void tst_PointHandler::tabletStylus() +{ + qApp->setAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents, false); + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "pointTracker.qml"); + QQuickView * window = windowPtr.data(); + QQuickPointHandler *handler = window->rootObject()->findChild<QQuickPointHandler *>("pointHandler"); + QVERIFY(handler); + handler->setAcceptedDevices(QQuickPointerDevice::Stylus); + + QSignalSpy activeSpy(handler, SIGNAL(activeChanged())); + QSignalSpy pointSpy(handler, SIGNAL(pointChanged())); + QSignalSpy translationSpy(handler, SIGNAL(translationChanged())); + + QPoint point(100,100); + const qint64 stylusId = 1234567890; + + QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0.5, 25, 35, 0.6, 12.3, 3, stylusId, Qt::NoModifier); + QTRY_COMPARE(handler->active(), true); + QCOMPARE(activeSpy.count(), 1); + QCOMPARE(pointSpy.count(), 1); + QCOMPARE(handler->point().position().toPoint(), point); + QCOMPARE(handler->point().scenePosition().toPoint(), point); + QCOMPARE(handler->point().pressedButtons(), Qt::LeftButton); + QCOMPARE(handler->point().pressure(), 0.5); + QCOMPARE(handler->point().rotation(), 12.3); + QCOMPARE(handler->point().uniqueId().numericId(), stylusId); + QCOMPARE(handler->translation(), QVector2D()); + QCOMPARE(translationSpy.count(), 1); + + point += QPoint(10, 10); + QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0.45, 23, 33, 0.57, 15.6, 3.4, stylusId, Qt::NoModifier); + QTRY_COMPARE(pointSpy.count(), 2); + QCOMPARE(handler->active(), true); + QCOMPARE(activeSpy.count(), 1); + QCOMPARE(handler->point().position().toPoint(), point); + QCOMPARE(handler->point().scenePosition().toPoint(), point); + QCOMPARE(handler->point().pressPosition().toPoint(), QPoint(100, 100)); + QCOMPARE(handler->point().scenePressPosition().toPoint(), QPoint(100, 100)); + QCOMPARE(handler->point().pressedButtons(), Qt::LeftButton); + QCOMPARE(handler->point().pressure(), 0.45); + QCOMPARE(handler->point().rotation(), 15.6); + QCOMPARE(handler->point().uniqueId().numericId(), stylusId); + QVERIFY(handler->point().velocity().x() > 0); + QVERIFY(handler->point().velocity().y() > 0); + QCOMPARE(handler->translation(), QVector2D(10, 10)); + QCOMPARE(translationSpy.count(), 2); + + QWindowSystemInterface::handleTabletEvent(window, point, window->mapToGlobal(point), + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, stylusId, Qt::NoModifier); + QTRY_COMPARE(handler->active(), false); + QCOMPARE(activeSpy.count(), 2); + QCOMPARE(pointSpy.count(), 3); + QCOMPARE(handler->translation(), QVector2D()); + QCOMPARE(translationSpy.count(), 3); +} + void tst_PointHandler::simultaneousMultiTouch() { QScopedPointer<QQuickView> windowPtr; diff --git a/tests/auto/quick/pointerhandlers/qquickwheelhandler/BLACKLIST b/tests/auto/quick/pointerhandlers/qquickwheelhandler/BLACKLIST new file mode 100644 index 0000000000..2949d3371f --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickwheelhandler/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-81993 +[singleHandler] +macos ci diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 9f616c56e2..47d6008c28 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -34,8 +34,8 @@ #include <private/qquickitem_p.h> #include <QtCore/qscopedpointer.h> #include <QtGui/qpainter.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglfunctions.h> +#include <qopenglcontext.h> +#include <qopenglfunctions.h> #include <QtGui/qoffscreensurface.h> #include <QtQml/qqmlproperty.h> diff --git a/tests/auto/quick/qquickanimations/BLACKLIST b/tests/auto/quick/qquickanimations/BLACKLIST new file mode 100644 index 0000000000..a1b8557128 --- /dev/null +++ b/tests/auto/quick/qquickanimations/BLACKLIST @@ -0,0 +1,2 @@ +[simplePath] +macos ci diff --git a/tests/auto/quick/qquickbehaviors/data/targetProperty.qml b/tests/auto/quick/qquickbehaviors/data/targetProperty.qml new file mode 100644 index 0000000000..18abd46010 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/targetProperty.qml @@ -0,0 +1,16 @@ +import QtQuick 2.15 + +Item { + readonly property QtObject xBehaviorObject: xBehavior.targetProperty.object + readonly property string xBehaviorName: xBehavior.targetProperty.name + readonly property QtObject emptyBehaviorObject: emptyBehavior.targetProperty.object + readonly property string emptyBehaviorName: emptyBehavior.targetProperty.name + Behavior on x { + id: xBehavior + objectName: "xBehavior" + } + Behavior { + id: emptyBehavior + objectName: "emptyBehavior" + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index 64e32dcdfd..3b46019f64 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -75,6 +75,7 @@ private slots: void innerBehaviorOverwritten(); void oneWay(); void safeToDelete(); + void targetProperty(); }; void tst_qquickbehaviors::simpleBehavior() @@ -656,6 +657,27 @@ void tst_qquickbehaviors::safeToDelete() QVERIFY(c.create()); } +Q_DECLARE_METATYPE(QQmlProperty) +void tst_qquickbehaviors::targetProperty() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("targetProperty.qml")); + QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create())); + QVERIFY2(!item.isNull(), qPrintable(c.errorString())); + + QQuickBehavior* xBehavior = + qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("xBehavior")); + QCOMPARE(xBehavior->property("targetProperty").value<QQmlProperty>(), QQmlProperty(item.data(), "x")); + QCOMPARE(item->property("xBehaviorObject").value<QObject*>(), item.data()); + QCOMPARE(item->property("xBehaviorName").toString(), "x"); + + QQuickBehavior* emptyBehavior = + qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("emptyBehavior")); + QCOMPARE(emptyBehavior->property("targetProperty").value<QQmlProperty>().isValid(), false); + QCOMPARE(item->property("emptyBehaviorObject").value<QObject*>(), nullptr); + QCOMPARE(item->property("emptyBehaviorName").toString(), ""); +} + QTEST_MAIN(tst_qquickbehaviors) diff --git a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp index b44977bd5a..062a8b5c9a 100644 --- a/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp +++ b/tests/auto/quick/qquickdesignersupport/tst_qquickdesignersupport.cpp @@ -76,7 +76,10 @@ void tst_qquickdesignersupport::customData() QVERIFY(rootItem); - QScopedPointer<QObject> newItemScopedPointer(QQuickDesignerSupportItems::createPrimitive(QLatin1String("QtQuick/Item"), 2, 6, view->rootContext())); + QScopedPointer<QObject> newItemScopedPointer(QQuickDesignerSupportItems::createPrimitive( + QLatin1String("QtQuick/Item"), + QTypeRevision::fromVersion(2, 6), + view->rootContext())); QObject *newItem = newItemScopedPointer.data(); QVERIFY(newItem); diff --git a/tests/auto/quick/qquickflickable/data/visibleAreaBinding.qml b/tests/auto/quick/qquickflickable/data/visibleAreaBinding.qml new file mode 100644 index 0000000000..6f7bc89793 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/visibleAreaBinding.qml @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 QtQuick 2.14 + +Flickable { + id: flickable + // Deliberately has no size set. + + Text { + text: flickable.visibleArea.xPosition + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 5364530ca8..f3659290eb 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -205,6 +205,7 @@ private slots: void overshoot_reentrant(); void synchronousDrag_data(); void synchronousDrag(); + void visibleAreaBinding(); private: void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to); @@ -2540,6 +2541,16 @@ void tst_qquickflickable::synchronousDrag() QTest::touchEvent(window, touchDevice).release(0, p5, window); } +// QTBUG-81098: tests that a binding to visibleArea doesn't result +// in a division-by-zero exception (when exceptions are enabled). +void tst_qquickflickable::visibleAreaBinding() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("visibleAreaBinding.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + // Shouldn't crash. +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" diff --git a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp index 6aff66d61e..2327270b0f 100644 --- a/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp +++ b/tests/auto/quick/qquickframebufferobject/tst_qquickframebufferobject.cpp @@ -30,9 +30,9 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglframebufferobject.h> -#include <QtGui/qopenglfunctions.h> +#include <qopenglcontext.h> +#include <qopenglframebufferobject.h> +#include <qopenglfunctions.h> #include <QtQuick/QQuickFramebufferObject> diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp index 4da6da6043..aff081c4a8 100644 --- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp +++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp @@ -36,7 +36,7 @@ #include "../../shared/util.h" #if QT_CONFIG(opengl) -#include <QtGui/qopenglcontext.h> +#include <qopenglcontext.h> #include <QtGui/qsurfaceformat.h> #endif diff --git a/tests/auto/quick/qquickimage/data/ProPhoto.jpg b/tests/auto/quick/qquickimage/data/ProPhoto.jpg Binary files differnew file mode 100644 index 0000000000..481d35ca8e --- /dev/null +++ b/tests/auto/quick/qquickimage/data/ProPhoto.jpg diff --git a/tests/auto/quick/qquickimage/data/image.qml b/tests/auto/quick/qquickimage/data/image.qml new file mode 100644 index 0000000000..09a577cc6f --- /dev/null +++ b/tests/auto/quick/qquickimage/data/image.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Image { + source: "heart.png" +} diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index abc7cd86bd..f0b44743b9 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -51,6 +51,7 @@ #include "../../shared/testhttpserver.h" #include "../shared/visualtestutil.h" +// #define DEBUG_WRITE_OUTPUT using namespace QQuickVisualTestUtil; @@ -89,6 +90,8 @@ private slots: void imageCrash_QTBUG_32513(); void sourceSize_data(); void sourceSize(); + void sourceClipRect_data(); + void sourceClipRect(); void progressAndStatusChanges(); void sourceSizeChanges(); void correctStatus(); @@ -99,6 +102,7 @@ private slots: void urlInterceptor(); void multiFrame_data(); void multiFrame(); + void colorSpace(); private: QQmlEngine engine; @@ -879,6 +883,72 @@ void tst_qquickimage::sourceSizeChanges() delete img; } +void tst_qquickimage::sourceClipRect_data() +{ + QTest::addColumn<QRectF>("sourceClipRect"); + QTest::addColumn<QSize>("sourceSize"); + QTest::addColumn<QList<QPoint>>("redPixelLocations"); + QTest::addColumn<QList<QPoint>>("bluePixelLocations"); + + QTest::newRow("unclipped") << QRectF() << QSize() + << (QList<QPoint>() << QPoint(80, 80) << QPoint(150, 256)) + << (QList<QPoint>() << QPoint(28, 28) << QPoint(215, 215)); + QTest::newRow("upperLeft") << QRectF(10, 10, 100, 100) << QSize() + << (QList<QPoint>() << QPoint(99, 99)) + << (QList<QPoint>() << QPoint(100, 100) << QPoint(28, 28)); + QTest::newRow("lowerRight") << QRectF(200, 200, 20, 20) << QSize() + << (QList<QPoint>() << QPoint(0, 0)) + << (QList<QPoint>() << QPoint(14, 14)); + QTest::newRow("miniMiddle") << QRectF(20, 20, 60, 60) << QSize(100, 100) + << (QList<QPoint>() << QPoint(59, 0) << QPoint(6, 12) << QPoint(42, 42)) + << (QList<QPoint>() << QPoint(54, 54) << QPoint(15, 59)); +} + +void tst_qquickimage::sourceClipRect() +{ + QFETCH(QRectF, sourceClipRect); + QFETCH(QSize, sourceSize); + QFETCH(QList<QPoint>, redPixelLocations); + QFETCH(QList<QPoint>, bluePixelLocations); + + QScopedPointer<QQuickView> window(new QQuickView(nullptr)); + + window->setColor(Qt::blue); + window->setSource(testFileUrl("image.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickImage *image = qobject_cast<QQuickImage*>(window->rootObject()); + QVERIFY(image); + + image->setSourceSize(sourceSize); + QCOMPARE(image->implicitWidth(), sourceSize.isValid() ? sourceSize.width() : 300); + QCOMPARE(image->implicitHeight(), sourceSize.isValid() ? sourceSize.height() : 300); + image->setSourceClipRect(sourceClipRect); + QCOMPARE(image->implicitWidth(), sourceClipRect.isNull() ? 300 : sourceClipRect.width()); + QCOMPARE(image->implicitHeight(), sourceClipRect.isNull() ? 300 : sourceClipRect.height()); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage contents = window->grabWindow(); + if (contents.width() < sourceClipRect.width()) + QSKIP("Skipping due to grabWindow not functional"); +#ifdef DEBUG_WRITE_OUTPUT + contents.save("/tmp/sourceClipRect_" + QLatin1String(QTest::currentDataTag()) + ".png"); +#endif + for (auto p : redPixelLocations) { + QRgb color = contents.pixel(p); + QVERIFY(qRed(color) > 0xc0); + QVERIFY(qBlue(color) < 0x0f); + } + for (auto p : bluePixelLocations){ + QRgb color = contents.pixel(p); + QVERIFY(qBlue(color) > 0xc0); + QVERIFY(qRed(color) < 0x0f); + } +} + void tst_qquickimage::progressAndStatusChanges() { TestHTTPServer server; @@ -1190,6 +1260,34 @@ void tst_qquickimage::multiFrame() QVERIFY(qBlue(color) < 0xc0); } +void tst_qquickimage::colorSpace() +{ + QString componentStr1 = "import QtQuick 2.15\n" + "Image { source: srcImage; }"; + QQmlComponent component1(&engine); + component1.setData(componentStr1.toLatin1(), QUrl::fromLocalFile("")); + engine.rootContext()->setContextProperty("srcImage", testFileUrl("ProPhoto.jpg")); + + QScopedPointer<QQuickImage> object1 { qobject_cast<QQuickImage*>(component1.create())}; + QVERIFY(object1); + QTRY_COMPARE(object1->status(), QQuickImageBase::Ready); + QCOMPARE(object1->colorSpace(), QColorSpace(QColorSpace::ProPhotoRgb)); + + QString componentStr2 = "import QtQuick 2.15\n" + "Image {\n" + " source: srcImage;\n" + " colorSpace.namedColorSpace: ColorSpace.SRgb;\n" + "}"; + + QQmlComponent component2(&engine); + component2.setData(componentStr2.toLatin1(), QUrl::fromLocalFile("")); + + QScopedPointer<QQuickImage> object2 { qobject_cast<QQuickImage*>(component2.create())}; + QVERIFY(object2); + QTRY_COMPARE(object2->status(), QQuickImageBase::Ready); + QCOMPARE(object2->colorSpace(), QColorSpace(QColorSpace::SRgb)); +} + QTEST_MAIN(tst_qquickimage) #include "tst_qquickimage.moc" diff --git a/tests/auto/quick/qquickitem/data/hellotr_la.qm b/tests/auto/quick/qquickitem/data/hellotr_la.qm Binary files differnew file mode 100644 index 0000000000..25c0aad583 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/hellotr_la.qm diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 8aab13e095..137162099f 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -34,12 +34,16 @@ #include "private/qquickfocusscope_p.h" #include "private/qquickitem_p.h" #include <qpa/qwindowsysteminterface.h> +#ifdef Q_OS_WIN +#include <QOpenGLContext> +#endif #include <QDebug> #include <QTimer> #include <QQmlEngine> #include "../../shared/util.h" #include "../shared/viewtestutil.h" #include <QSignalSpy> +#include <QTranslator> #ifdef TEST_QTBUG_60123 #include <QWidget> @@ -70,6 +74,7 @@ public: ulong timestamp; QPoint lastWheelEventPos; QPoint lastWheelEventGlobalPos; + int languageChangeEventCount = 0; protected: virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } @@ -86,6 +91,12 @@ protected: lastWheelEventPos = event->position().toPoint(); lastWheelEventGlobalPos = event->globalPosition().toPoint(); } + bool event(QEvent *e) override + { + if (e->type() == QEvent::LanguageChange) + languageChangeEventCount++; + return QQuickItem::event(e); + } }; class TestWindow: public QQuickWindow @@ -198,6 +209,7 @@ private slots: #endif void setParentCalledInOnWindowChanged(); + void receivesLanguageChangeEvent(); private: @@ -2155,6 +2167,32 @@ void tst_qquickitem::setParentCalledInOnWindowChanged() QVERIFY(ensureFocus(&view)); // should not crash } +void tst_qquickitem::receivesLanguageChangeEvent() +{ + QQuickWindow window; + window.setFramePosition(QPoint(100, 100)); + window.resize(200, 200); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QScopedPointer<TestItem> child1(new TestItem); + child1->setObjectName(QStringLiteral("child1")); + child1->setSize(QSizeF(200, 100)); + child1->setParentItem(window.contentItem()); + + QScopedPointer<TestItem> child2(new TestItem); + child2->setObjectName(QStringLiteral("child2")); + child2->setSize(QSizeF(50, 50)); + child2->setParentItem(child1.data()); + + QTranslator t; + QVERIFY(t.load("hellotr_la.qm", dataDirectory())); + QVERIFY(QCoreApplication::installTranslator(&t)); + + QTRY_COMPARE(child1->languageChangeEventCount, 1); + QCOMPARE(child2->languageChangeEventCount, 1); +} + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml new file mode 100644 index 0000000000..042f408753 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.14 + +Item { + width: 400 + height: 200 + Item { + objectName: "hiddenChild" + focus: true + activeFocusOnTab: true + visible: false + } +} diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index a1b4a70217..45ecbfde11 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -64,6 +64,7 @@ private slots: void activeFocusOnTab8(); void activeFocusOnTab9(); void activeFocusOnTab10(); + void activeFocusOnTab_infiniteLoop_data(); void activeFocusOnTab_infiniteLoop(); void nextItemInFocusChain(); @@ -1027,12 +1028,20 @@ void tst_QQuickItem::activeFocusOnTab10() delete window; } +void tst_QQuickItem::activeFocusOnTab_infiniteLoop_data() +{ + QTest::addColumn<QUrl>("source"); + QTest::newRow("infiniteLoop") << testFileUrl("activeFocusOnTab_infiniteLoop.qml"); // QTBUG-68271 + QTest::newRow("infiniteLoop2") << testFileUrl("activeFocusOnTab_infiniteLoop2.qml");// QTBUG-81510 +} + void tst_QQuickItem::activeFocusOnTab_infiniteLoop() { - // see QTBUG-68271 + QFETCH(QUrl, source); + // create a window where the currently focused item is not visible QScopedPointer<QQuickView>window(new QQuickView()); - window->setSource(testFileUrl("activeFocusOnTab_infiniteLoop.qml")); + window->setSource(source); window->show(); auto *hiddenChild = findItem<QQuickItem>(window->rootObject(), "hiddenChild"); QVERIFY(hiddenChild); @@ -1041,6 +1050,8 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop() auto *item = hiddenChild->nextItemInFocusChain(); // focus is moved to the root object since there is no other candidate QCOMPARE(item, window->rootObject()); + item = hiddenChild->nextItemInFocusChain(false); + QCOMPARE(item, window->rootObject()); } void tst_QQuickItem::nextItemInFocusChain() diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 2f90632841..b45aa5d61c 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -31,8 +31,8 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> #include <QtQuick/qsgrendererinterface.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglfunctions.h> +#include <qopenglcontext.h> +#include <qopenglfunctions.h> #include "../../shared/util.h" diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml index 07af6a77ac..0732884c97 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml @@ -1100,5 +1100,36 @@ Item { waitForRendering(rootRect.layout) compare(rootRect.item1.width, 100) } + +//--------------------------- + Component { + id: rowlayoutWithTextItems_Component + RowLayout { + Text { + Layout.fillWidth: true + text: "OneWord" + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + Text { + Layout.fillWidth: true + text: "OneWord" + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + } + } + + // QTBUG-73683 + function test_rowlayoutWithTextItems() { + var layout = createTemporaryObject(rowlayoutWithTextItems_Component, container) + waitForRendering(layout) + for (var i = 0; i < 3; i++) { + ignoreWarning(/Qt Quick Layouts: Detected recursive rearrange. Aborting after two iterations./) + } + ignoreWarning(/Qt Quick Layouts: Polish loop detected. Aborting after two iterations./) + layout.width = layout.width - 2 // set the size to be smaller than its "minimum size" + waitForRendering(layout) // do not exit before all warnings have been received + + // DO NOT CRASH due to stack overflow (or loop endlessly due to updatePolish()/polish() loop) + } } } diff --git a/tests/auto/quick/qquicklistview/data/headerSnapToItem.qml b/tests/auto/quick/qquicklistview/data/headerSnapToItem.qml new file mode 100644 index 0000000000..1e5a811630 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/headerSnapToItem.qml @@ -0,0 +1,67 @@ +import QtQuick 2.12 + +Rectangle { + + width: 240 + height: 320 + color: "#ffffff" + + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: list.orientation == ListView.Vertical ? 240 : 20 + height: list.orientation == ListView.Vertical ? 20 : 240 + border.width: 1 + border.color: "black" + Text { + text: index + ":" + (list.orientation == ListView.Vertical ? parent.y : parent.x).toFixed(0) + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + } + } + + ListView { + id: list + objectName: "list" + focus: true + width: 240 + height: 200 + clip: true + snapMode: ListView.SnapToItem + headerPositioning: ListView.OverlayHeader + model: 30 + delegate: myDelegate + orientation: ListView.Vertical + verticalLayoutDirection: ListView.BottomToTop + + header: Rectangle { + width: list.orientation == Qt.Vertical ? 240 : 30 + height: list.orientation == Qt.Vertical ? 30 : 240 + objectName: "header"; + color: "green" + z: 11 + Text { + anchors.centerIn: parent + text: "header " + (list.orientation == ListView.Vertical ? parent.y : parent.x).toFixed(1) + } + } + } + + Rectangle { + color: "red" + opacity: 0.5 + width: txt.implicitWidth + 50 + height: txt.implicitHeight + anchors.bottom: parent.bottom + anchors.right: parent.right + + Text { + id: txt + anchors.centerIn: parent + text: "header position: " + (list.orientation == ListView.Vertical ? list.headerItem.y : list.headerItem.x).toFixed(1) + + "\ncontent position: " + (list.orientation == ListView.Vertical ? list.contentY : list.contentX).toFixed(1) + } + } +} diff --git a/tests/auto/quick/qquicklistview/data/requiredObjectListModel.qml b/tests/auto/quick/qquicklistview/data/requiredObjectListModel.qml new file mode 100644 index 0000000000..f6380ed5aa --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/requiredObjectListModel.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + required model + + delegate: Rectangle { + required color + required property string name + + height: 25 + width: 100 + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 9a8dfee9d2..49b68a8473 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -30,6 +30,7 @@ #include <QtCore/QStringListModel> #include <QtCore/QSortFilterProxyModel> #include <QtGui/QStandardItemModel> +#include <QtGui/QStyleHints> #include <QtQuick/qquickview.h> #include <QtQuickTest/QtQuickTest> #include <QtQml/qqmlengine.h> @@ -40,6 +41,7 @@ #include <QtQuick/private/qquicklistview_p.h> #include <QtQuick/private/qquickmousearea_p.h> #include <QtQuick/private/qquicktext_p.h> +#include <QtQuick/private/qquickrectangle_p.h> #include <QtQmlModels/private/qqmlobjectmodel_p.h> #include <QtQmlModels/private/qqmllistmodel_p.h> #include <QtQmlModels/private/qqmldelegatemodel_p.h> @@ -185,6 +187,8 @@ private slots: void creationContext(); void snapToItem_data(); void snapToItem(); + void headerSnapToItem_data(); + void headerSnapToItem(); void snapToItemWithSpacing_QTBUG_59852(); void snapOneItemResize_QTBUG_43555(); void snapOneItem_data(); @@ -291,6 +295,8 @@ private slots: void moveObjectModelItemToAnotherObjectModel(); void changeModelAndDestroyTheOldOne(); + void requiredObjectListModel(); + private: template <class T> void items(const QUrl &source); template <class T> void changed(const QUrl &source); @@ -5412,6 +5418,604 @@ void tst_QQuickListView::snapToItemWithSpacing_QTBUG_59852() releaseView(window); } +static void drag_helper(QWindow *window, QPoint *startPos, const QPoint &delta) +{ + QPoint pos = *startPos; + int dragDistance = delta.manhattanLength(); + Q_ASSERT(qAbs(delta.x()) >= 1 || qAbs(delta.y()) >= 1); + + const int stepSize = 8; + QPoint unitVector(0, 0); + if (delta.x()) + unitVector.setX(qBound(-1, delta.x(), 1)); + if (delta.y()) + unitVector.setY(qBound(-1, delta.y(), 1)); + QPoint dragStepSize = unitVector * stepSize; + int nDragSteps = qAbs(dragDistance/stepSize); + + for (int i = 0 ; i < nDragSteps; ++i) { + QTest::mouseMove(window, pos); + pos += dragStepSize; + } + // Move to the final position + pos = *startPos + delta; + QTest::mouseMove(window, pos); + *startPos = pos; +} + +static void dragtwice(QWindow *window, QPoint *startPos, const QPoint &delta1, const QPoint &delta2) +{ + const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); + QPoint &pos = *startPos; + QPoint unitVector(0, 0); + if (delta1.x()) + unitVector.setX(qBound(-1, delta1.x(), 1)); + if (delta1.y()) + unitVector.setY(qBound(-1, delta1.y(), 1)); + + // go just beyond the drag theshold + drag_helper(window, &pos, unitVector * (dragThreshold + 1)); + drag_helper(window, &pos, unitVector); + + // next drag will actually scroll the listview + if (delta1.manhattanLength() >= 1) + drag_helper(window, &pos, delta1); + if (delta2.manhattanLength() >= 1) + drag_helper(window, &pos, delta2); +} + +struct MyListView : public QQuickListView{ + qreal contentPosition() const + { + return (orientation() == QQuickListView::Horizontal ? contentX(): contentY()); + } + + qreal headerPosition() const + { + return (orientation() == QQuickListView::Horizontal ? headerItem()->x() : headerItem()->y()); + } +}; + +void tst_QQuickListView::headerSnapToItem() +{ + QFETCH(QQuickItemView::LayoutDirection, layoutDirection); + QFETCH(QQuickListView::HeaderPositioning, headerPositioning); + QFETCH(int, firstDragDistance); + QFETCH(int, secondDragDistance); + QFETCH(int, expectedContentPosition); + QFETCH(int, expectedHeaderPosition); + + QQuickView *window = getView(); + window->setSource(testFileUrl("headerSnapToItem.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + MyListView *listview = static_cast<MyListView *>(findItem<QQuickListView>(window->rootObject(), "list")); + QVERIFY(listview != nullptr); + + const bool horizontal = layoutDirection < QQuickItemView::VerticalTopToBottom; + listview->setOrientation(horizontal ? QQuickListView::Horizontal : QQuickListView::Vertical); + + if (horizontal) + listview->setLayoutDirection(static_cast<Qt::LayoutDirection>(layoutDirection)); + else + listview->setVerticalLayoutDirection(static_cast<QQuickItemView::VerticalLayoutDirection>(layoutDirection)); + + listview->setHeaderPositioning(headerPositioning); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != nullptr); + QQuickItem *header = findItem<QQuickItem>(contentItem, "header"); + QVERIFY(header != nullptr); + QCOMPARE(header, listview->headerItem()); + + QPoint startPos = (QPointF(listview->width(), listview->height())/2).toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, startPos, 200); + + QPoint firstDragDelta(0, firstDragDistance); + QPoint secondDragDelta = QPoint(0, secondDragDistance); + if (horizontal) { + firstDragDelta = firstDragDelta.transposed(); + secondDragDelta = secondDragDelta.transposed(); + } + + dragtwice(window, &startPos, firstDragDelta, secondDragDelta); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, startPos, 200); // Wait 200 ms before we release to avoid trigger a flick + + // wait for the "fixup" animation to finish + QTest::qWaitFor([&]() + { return !listview->isMoving();} + ); + + QCOMPARE(listview->contentPosition(), expectedContentPosition); + QCOMPARE(listview->headerPosition(), expectedHeaderPosition); +} + +void tst_QQuickListView::headerSnapToItem_data() +{ + QTest::addColumn<QQuickItemView::LayoutDirection>("layoutDirection"); + QTest::addColumn<QQuickListView::HeaderPositioning>("headerPositioning"); + QTest::addColumn<int>("firstDragDistance"); + QTest::addColumn<int>("secondDragDistance"); + QTest::addColumn<int>("expectedContentPosition"); + QTest::addColumn<int>("expectedHeaderPosition"); + + // -------------------- + // InlineHeader TopToBottom + QTest::newRow("InlineHeader TopToBottom -10") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -10 << 0 + << -30 << -30; + + QTest::newRow("InlineHeader TopToBottom -14") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -14 << 0 + << -30 << -30; + + QTest::newRow("InlineHeader TopToBottom -16") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -16 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader TopToBottom -30") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -30 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader TopToBottom -39") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -39 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader TopToBottom -41") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -41 << 0 + << 20 << -30; + + QTest::newRow("InlineHeader TopToBottom -65+10") << QQuickItemView::VerticalTopToBottom + << QQuickListView::InlineHeader + << -65 << 10 + << 20 << -30; + + // -------------------- + // InlineHeader BottomToTop + QTest::newRow("InlineHeader BottomToTop +10") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 10 << 0 + << -170 << 0; + + QTest::newRow("InlineHeader BottomToTop +14") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 14 << 0 + << -170 << 0; + + QTest::newRow("InlineHeader BottomToTop +16") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 16 << 0 + << -200 << 0; + + QTest::newRow("InlineHeader BottomToTop +30") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 30 << 0 + << -200 << 0; + + QTest::newRow("InlineHeader BottomToTop +39") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 39 << 0 + << -200 << 0; + + QTest::newRow("InlineHeader BottomToTop +41") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 41 << 0 + << -220 << 0; + + QTest::newRow("InlineHeader BottomToTop +65-10") << QQuickItemView::VerticalBottomToTop + << QQuickListView::InlineHeader + << 65 << -10 + << -220 << 0; + + // -------------------- + // InlineHeader LeftToRight + QTest::newRow("InlineHeader LeftToRight -10") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -10 << 0 + << -30 << -30; + + QTest::newRow("InlineHeader LeftToRight -14") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -14 << 0 + << -30 << -30; + + QTest::newRow("InlineHeader LeftToRight -16") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -16 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader LeftToRight -30") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -30 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader LeftToRight -39") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -39 << 0 + << 0 << -30; + + QTest::newRow("InlineHeader LeftToRight -41") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -41 << 0 + << 20 << -30; + + QTest::newRow("InlineHeader LeftToRight -65+10") << QQuickItemView::LeftToRight + << QQuickListView::InlineHeader + << -65 << 10 + << 20 << -30; + + // -------------------- + // InlineHeader RightToLeft + QTest::newRow("InlineHeader RightToLeft +10") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 10 << 0 + << -210 << 0; + + QTest::newRow("InlineHeader RightToLeft +14") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 14 << 0 + << -210 << 0; + + QTest::newRow("InlineHeader RightToLeft +16") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 16 << 0 + << -240 << 0; + + QTest::newRow("InlineHeader RightToLeft +30") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 30 << 0 + << -240 << 0; + + QTest::newRow("InlineHeader RightToLeft +39") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 39 << 0 + << -240 << 0; + + QTest::newRow("InlineHeader RightToLeft +41") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 41 << 0 + << -260 << 0; + + QTest::newRow("InlineHeader RightToLeft +65-10") << QQuickItemView::RightToLeft + << QQuickListView::InlineHeader + << 65 << -10 + << -260 << 0; + + // -------------------- + // OverlayHeader TopToBottom + QTest::newRow("OverlayHeader TopToBottom +9") << QQuickItemView::VerticalTopToBottom + << QQuickListView::OverlayHeader + << 9 << 0 + << -30 << -30; + + QTest::newRow("OverlayHeader TopToBottom -9") << QQuickItemView::VerticalTopToBottom + << QQuickListView::OverlayHeader + << -9 << 0 + << -30 << -30; + + QTest::newRow("OverlayHeader TopToBottom -11") << QQuickItemView::VerticalTopToBottom + << QQuickListView::OverlayHeader + << -11 << 0 + << -10 << -10; + + QTest::newRow("OverlayHeader TopToBottom -29") << QQuickItemView::VerticalTopToBottom + << QQuickListView::OverlayHeader + << -29 << 0 + << -10 << -10; + + QTest::newRow("OverlayHeader TopToBottom -31") << QQuickItemView::VerticalTopToBottom + << QQuickListView::OverlayHeader + << -31 << 0 + << 10 << 10; + + // -------------------- + // OverlayHeader BottomToTop + QTest::newRow("OverlayHeader BottomToTop -9") << QQuickItemView::VerticalBottomToTop + << QQuickListView::OverlayHeader + << -9 << 0 + << -170 << 0; + + QTest::newRow("OverlayHeader BottomToTop +9") << QQuickItemView::VerticalBottomToTop + << QQuickListView::OverlayHeader + << 9 << 0 + << -170 << 0; + + QTest::newRow("OverlayHeader BottomToTop +11") << QQuickItemView::VerticalBottomToTop + << QQuickListView::OverlayHeader + << 11 << 0 + << -190 << -20; + + QTest::newRow("OverlayHeader BottomToTop +29") << QQuickItemView::VerticalBottomToTop + << QQuickListView::OverlayHeader + << 29 << 0 + << -190 << -20; + + QTest::newRow("OverlayHeader BottomToTop +31") << QQuickItemView::VerticalBottomToTop + << QQuickListView::OverlayHeader + << 31 << 0 + << -210 << -40; + + // -------------------- + // OverlayHeader LeftToRight + QTest::newRow("OverlayHeader LeftToRight +9") << QQuickItemView::LeftToRight + << QQuickListView::OverlayHeader + << 9 << 0 + << -30 << -30; + + QTest::newRow("OverlayHeader LeftToRight -9") << QQuickItemView::LeftToRight + << QQuickListView::OverlayHeader + << -9 << 0 + << -30 << -30; + + QTest::newRow("OverlayHeader LeftToRight -11") << QQuickItemView::LeftToRight + << QQuickListView::OverlayHeader + << -11 << 0 + << -10 << -10; + + QTest::newRow("OverlayHeader LeftToRight -29") << QQuickItemView::LeftToRight + << QQuickListView::OverlayHeader + << -29 << 0 + << -10 << -10; + + QTest::newRow("OverlayHeader LeftToRight -31") << QQuickItemView::LeftToRight + << QQuickListView::OverlayHeader + << -31 << 0 + << 10 << 10; + + // -------------------- + // OverlayHeader RightToLeft + QTest::newRow("OverlayHeader RightToLeft -9") << QQuickItemView::RightToLeft + << QQuickListView::OverlayHeader + << -9 << 0 + << -210 << 0; + + QTest::newRow("OverlayHeader RightToLeft +9") << QQuickItemView::RightToLeft + << QQuickListView::OverlayHeader + << 9 << 0 + << -210 << 0; + + QTest::newRow("OverlayHeader RightToLeft +11") << QQuickItemView::RightToLeft + << QQuickListView::OverlayHeader + << 11 << 0 + << -230 << -20; + + QTest::newRow("OverlayHeader RightToLeft +29") << QQuickItemView::RightToLeft + << QQuickListView::OverlayHeader + << 29 << 0 + << -230 << -20; + + QTest::newRow("OverlayHeader RightToLeft +31") << QQuickItemView::RightToLeft + << QQuickListView::OverlayHeader + << 31 << 0 + << -250 << -40; + + // -------------------- + // PullbackHeader TopToBottom + QTest::newRow("PullbackHeader TopToBottom -2") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -2 << 0 + << -30 << -30; + + QTest::newRow("PullbackHeader TopToBottom -10") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -10 << 0 + << -30 << -30; + + QTest::newRow("PullbackHeader TopToBottom -11") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -11 << 0 + << -10 << -10; + + QTest::newRow("PullbackHeader TopToBottom -14") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -14 << 0 + << -10 << -10; + + QTest::newRow("PullbackHeader TopToBottom -16") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -16 << 0 + << 0 << -30; + + QTest::newRow("PullbackHeader TopToBottom -20") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -20 << 0 + << 0 << -30; + + QTest::newRow("PullbackHeader TopToBottom -65+10") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -65 << 10 + << 20 << -10; + + QTest::newRow("PullbackHeader TopToBottom -65+20") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -65 << 20 + << 10 << 10; + + // Should move header even if contentY doesn't move (its aligned with top) + QTest::newRow("PullbackHeader TopToBottom -55+5") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -55 << 5 + << 20 << -10; + + // Should move header even if contentY doesn't move (it's aligned with header) + QTest::newRow("PullbackHeader TopToBottom -76+16") << QQuickItemView::VerticalTopToBottom + << QQuickListView::PullBackHeader + << -76 << 16 + << 30 << 30; + + // -------------------- + // PullbackHeader BottomToTop + QTest::newRow("PullbackHeader BottomToTop +2") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +2 << 0 + << -170 << 0; + + QTest::newRow("PullbackHeader BottomToTop +9") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +9 << 0 + << -170 << 0; + + QTest::newRow("PullbackHeader BottomToTop +11") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +11 << 0 + << -190 << -20; + + QTest::newRow("PullbackHeader BottomToTop +14") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +14 << 0 + << -190 << -20; + + QTest::newRow("PullbackHeader BottomToTop +16") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +16 << 0 + << -200 << 0; + + QTest::newRow("PullbackHeader BottomToTop +20") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +20 << 0 + << -200 << 0; + + QTest::newRow("PullbackHeader BottomToTop +65-10") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +65 << -10 + << -220 << -20; + + QTest::newRow("PullbackHeader BottomToTop +65-20") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << +65 << -20 + << -210 << -40; + + // Should move header even if contentY doesn't move (it's aligned with top) + QTest::newRow("PullbackHeader BottomToTop +55-5") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << 55 << -5 + << -220 << -20; + + // Should move header even if contentY doesn't move (it's aligned with header) + QTest::newRow("PullbackHeader BottomToTop +76-16") << QQuickItemView::VerticalBottomToTop + << QQuickListView::PullBackHeader + << 76 << -16 + << -230 << -60; + + // -------------------- + // PullbackHeader LeftToRight + QTest::newRow("PullbackHeader LeftToRight -2") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -2 << 0 + << -30 << -30; + + QTest::newRow("PullbackHeader LeftToRight -10") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -10 << 0 + << -30 << -30; + + QTest::newRow("PullbackHeader LeftToRight -11") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -11 << 0 + << -10 << -10; + + QTest::newRow("PullbackHeader LeftToRight -14") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -14 << 0 + << -10 << -10; + + QTest::newRow("PullbackHeader LeftToRight -16") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -16 << 0 + << 0 << -30; + + QTest::newRow("PullbackHeader LeftToRight -20") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -20 << 0 + << 0 << -30; + + QTest::newRow("PullbackHeader LeftToRight -65+10") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -65 << 10 + << 20 << -10; + + QTest::newRow("PullbackHeader LeftToRight -65+20") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -65 << 20 + << 10 << 10; + + // Should move header even if contentX doesn't move (its aligned with top) + QTest::newRow("PullbackHeader LeftToRight -55+5") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -55 << 5 + << 20 << -10; + + // Should move header even if contentX doesn't move (it's aligned with header) + QTest::newRow("PullbackHeader LeftToRight -76+16") << QQuickItemView::LeftToRight + << QQuickListView::PullBackHeader + << -76 << 16 + << 30 << 30; + + // -------------------- + // PullbackHeader RightToLeft + QTest::newRow("PullbackHeader RightToLeft +2") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +2 << 0 + << -210 << 0; + + QTest::newRow("PullbackHeader RightToLeft +9") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +9 << 0 + << -210 << 0; + + QTest::newRow("PullbackHeader RightToLeft +11") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +11 << 0 + << -230 << -20; + + QTest::newRow("PullbackHeader RightToLeft +14") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +14 << 0 + << -230 << -20; + + QTest::newRow("PullbackHeader RightToLeft +16") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +16 << 0 + << -240 << 0; + + QTest::newRow("PullbackHeader RightToLeft +20") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +20 << 0 + << -240 << 0; + + QTest::newRow("PullbackHeader RightToLeft +65-10") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +65 << -10 + << -260 << -20; + + QTest::newRow("PullbackHeader RightToLeft +65-20") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << +65 << -20 + << -250 << -40; + + // Should move header even if contentX doesn't move (it's aligned with top) + QTest::newRow("PullbackHeader RightToLeft +55-5") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << 55 << -5 + << -260 << -20; + + // Should move header even if contentX doesn't move (it's aligned with header) + QTest::newRow("PullbackHeader RightToLeft +76-16") << QQuickItemView::RightToLeft + << QQuickListView::PullBackHeader + << 76 << -16 + << -270 << -60; + +} + void tst_QQuickListView::snapOneItemResize_QTBUG_43555() { QScopedPointer<QQuickView> window(createView()); @@ -9263,6 +9867,7 @@ void tst_QQuickListView::reuse_checkThatItemsAreReused() window->resize(640, 480); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QVERIFY(window->rootObject() != nullptr); QQuickListView *listView = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listView != nullptr); @@ -9431,6 +10036,60 @@ void tst_QQuickListView::changeModelAndDestroyTheOldOne() // QTBUG-80203 // no crash } +class DataObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString color READ color CONSTANT) + +public: + DataObject(QObject *parent = nullptr) : QObject(parent) {} + DataObject(const QString &name, const QString &color, QObject *parent = nullptr) + : QObject(parent), m_name(name), m_color(color) {} + + QString name() const { return m_name; } + QString color() const { return m_color; } + +private: + QString m_name; + QString m_color; +}; + +void tst_QQuickListView::requiredObjectListModel() +{ + QList<QObject *> dataList = { + new DataObject("Item 1", "red", this), + new DataObject("Item 2", "green", this), + new DataObject("Item 3", "blue", this), + new DataObject("Item 4", "yellow", this) + }; + + const auto deleter = qScopeGuard([&](){ qDeleteAll(dataList); }); + Q_UNUSED(deleter); + + QQuickView view; + view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }}); + view.setSource(testFileUrl("requiredObjectListModel.qml")); + view.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + const auto *root = qobject_cast<QQuickListView *>(view.rootObject()); + QVERIFY(root); + + QCOMPARE(root->count(), dataList.count()); + + for (int i = 0, end = dataList.count(); i != end; ++i) { + const auto *rect = qobject_cast<QQuickRectangle *>(root->itemAtIndex(i)); + QVERIFY(rect); + const auto *data = qobject_cast<DataObject *>(dataList.at(i)); + QVERIFY(data); + + QCOMPARE(rect->color(), QColor(data->color())); + QCOMPARE(rect->property("name").toString(), data->name()); + } +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquickloader/data/statusChanged.qml b/tests/auto/quick/qquickloader/data/statusChanged.qml new file mode 100644 index 0000000000..fe46bc7b24 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/statusChanged.qml @@ -0,0 +1,16 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 + +Window { + id: root + property int statusChangedCounter: 0 + property alias status: loader.status + visible: true; width: 640; height: 480 + Loader { + id: loader + anchors.fill: parent + asynchronous: true + source: "./RedRect.qml" + onStatusChanged: root.statusChangedCounter++ + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index e05b7ae9ce..91d0bcab2e 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -39,6 +39,7 @@ #include "testhttpserver.h" #include "../../shared/util.h" #include "../shared/geometrytestutil.h" +#include <QQmlApplicationEngine> Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests") @@ -128,6 +129,7 @@ private slots: void rootContext(); void sourceURLKeepComponent(); + void statusChangeOnlyEmittedOnce(); }; Q_DECLARE_METATYPE(QList<QQmlError>) @@ -1456,6 +1458,18 @@ void tst_QQuickLoader::sourceURLKeepComponent() } +// QTBUG-82002 +void tst_QQuickLoader::statusChangeOnlyEmittedOnce() +{ + QQmlApplicationEngine engine; + auto url = testFileUrl("statusChanged.qml"); + engine.load(url); + auto root = engine.rootObjects().at(0); + QVERIFY(root); + QTRY_COMPARE(QQuickLoader::Status(root->property("status").toInt()), QQuickLoader::Ready); + QCOMPARE(root->property("statusChangedCounter").toInt(), 2); // 1xLoading + 1xReady*/ +} + QTEST_MAIN(tst_QQuickLoader) #include "tst_qquickloader.moc" diff --git a/tests/auto/quick/qquickmousearea/BLACKLIST b/tests/auto/quick/qquickmousearea/BLACKLIST new file mode 100644 index 0000000000..089bb3a873 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/BLACKLIST @@ -0,0 +1,10 @@ +[pressAndHold] +macos ci + +# QTBUG-78153 +[nestedStopAtBounds] +opensuse-leap + +# QTBUG-82282 +[pressOneAndTapAnother] +opensuse-leap diff --git a/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp index 3bf61e8f17..a4cbaa453d 100644 --- a/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp +++ b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp @@ -32,7 +32,7 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> -#include <QtGui/qopenglcontext.h> +#include <qopenglcontext.h> #include <QtGui/qsurfaceformat.h> #include "../../shared/util.h" diff --git a/tests/auto/quick/qquicktextedit/BLACKLIST b/tests/auto/quick/qquicktextedit/BLACKLIST index 36c7f0042f..b8147a0ef9 100644 --- a/tests/auto/quick/qquicktextedit/BLACKLIST +++ b/tests/auto/quick/qquicktextedit/BLACKLIST @@ -4,3 +4,7 @@ opensuse-leap # QTBUG-78846 [mouseSelectionMode] opensuse-leap + +# QTBUG-82052 +[linkHover] +macos ci diff --git a/tests/auto/quick/qquicktextinput/BLACKLIST b/tests/auto/quick/qquicktextinput/BLACKLIST index ada7c57c75..6cd24de9a9 100644 --- a/tests/auto/quick/qquicktextinput/BLACKLIST +++ b/tests/auto/quick/qquicktextinput/BLACKLIST @@ -1,3 +1,7 @@ # QTBUG-78162 [mouseSelectionMode] opensuse-leap + +# QTBUG-82058 +[setInputMask] +macos ci diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 5b6b11c746..0bf83c267a 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1797,22 +1797,26 @@ void tst_qquickwindow::cursor() window.resize(320, 290); QQuickItem parentItem; + parentItem.setObjectName("parentItem"); parentItem.setPosition(QPointF(0, 0)); parentItem.setSize(QSizeF(180, 180)); parentItem.setParentItem(window.contentItem()); QQuickItem childItem; + childItem.setObjectName("childItem"); childItem.setPosition(QPointF(60, 90)); childItem.setSize(QSizeF(120, 120)); childItem.setParentItem(&parentItem); QQuickItem clippingItem; + clippingItem.setObjectName("clippingItem"); clippingItem.setPosition(QPointF(120, 120)); clippingItem.setSize(QSizeF(180, 180)); clippingItem.setClip(true); clippingItem.setParentItem(window.contentItem()); QQuickItem clippedItem; + clippedItem.setObjectName("clippedItem"); clippedItem.setPosition(QPointF(-30, -30)); clippedItem.setSize(QSizeF(120, 120)); clippedItem.setParentItem(&clippingItem); @@ -2856,7 +2860,7 @@ void tst_qquickwindow::pointerEventTypeAndPointCount() QList<QTouchEvent::TouchPoint>() << QTouchEvent::TouchPoint(1)); - QQuickPointerMouseEvent pme; + QQuickPointerMouseEvent pme(nullptr, QQuickPointerDevice::genericMouseDevice()); pme.reset(&me); QCOMPARE(pme.asMouseEvent(localPosition), &me); QVERIFY(pme.asPointerMouseEvent()); @@ -2868,7 +2872,7 @@ void tst_qquickwindow::pointerEventTypeAndPointCount() QCOMPARE(pme.asMouseEvent(localPosition)->localPos(), localPosition); QCOMPARE(pme.asMouseEvent(localPosition)->screenPos(), screenPosition); - QQuickPointerTouchEvent pte; + QQuickPointerTouchEvent pte(nullptr, QQuickPointerDevice::touchDevice(touchDevice)); pte.reset(&te); QCOMPARE(pte.asTouchEvent(), &te); QVERIFY(!pte.asPointerMouseEvent()); diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp index e75e9e30b9..961531db6d 100644 --- a/tests/auto/quick/rendernode/tst_rendernode.cpp +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -30,8 +30,8 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/qopenglfunctions.h> +#include <qopenglcontext.h> +#include <qopenglfunctions.h> #include <QtGui/qscreen.h> #include <private/qsgrendernode_p.h> |