diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-12-04 01:00:40 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-12-04 01:00:41 +0100 |
commit | af9a96ca10e72517a7e8aa1ada7ec2d635e2a9ff (patch) | |
tree | 4b36daf460954c7c81f46acedae5409f3ac6a0a2 /tests | |
parent | 8c0fb7679c34281b7ed48e466a7eb72885c088e7 (diff) | |
parent | 705e80b702d752633828be9ac9467090e6541c66 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I4e4464d785c8c4a0d06ffaaff3e1cdd94e1c179a
Diffstat (limited to 'tests')
7 files changed, 318 insertions, 1 deletions
diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml new file mode 100644 index 0000000000..48b1dc86f0 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/mousearea_interop/data/dragTakeOverFromSibling.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + width: 640 + height: 480 + + Rectangle { + width: 200 + height: 200 + color: mouseArea.pressed ? "red" : "blue" + opacity: 0.6 + + MouseArea { + id: mouseArea + anchors.fill: parent + } + } + Rectangle { + y: 100 + z: -1 + width: 200 + height: 200 + color: dragHandler.active ? "orange" : "green" + opacity: 0.6 + + DragHandler { + id: dragHandler + } + } +} diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/mousearea_interop.pro b/tests/auto/quick/pointerhandlers/mousearea_interop/mousearea_interop.pro new file mode 100644 index 0000000000..0bf0ec86a9 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/mousearea_interop/mousearea_interop.pro @@ -0,0 +1,15 @@ +CONFIG += testcase + +TARGET = tst_mousearea_interop +QT += core-private gui-private qml-private quick-private testlib + +macos:CONFIG -= app_bundle + +SOURCES += tst_mousearea_interop.cpp + +include (../../../shared/util.pri) +include (../../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += data/dragTakeOverFromSibling.qml diff --git a/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp new file mode 100644 index 0000000000..03cff92f46 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/mousearea_interop/tst_mousearea_interop.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlproperty.h> +#include <QtQuick/private/qquickdraghandler_p.h> +#include <QtQuick/private/qquickmousearea_p.h> +#include <QtQuick/qquickitem.h> +#include <QtQuick/qquickview.h> + +#include "../../../shared/util.h" +#include "../../shared/viewtestutil.h" + +Q_LOGGING_CATEGORY(lcPointerTests, "qt.quick.pointer.tests") + +class tst_MouseAreaInterop : public QQmlDataTest +{ + Q_OBJECT +public: + tst_MouseAreaInterop() + : touchDevice(QTest::createTouchDevice()) + , touchPointerDevice(QQuickPointerDevice::touchDevice(touchDevice)) + {} + +private slots: + void dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse(); + void dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch(); + +private: + void createView(QScopedPointer<QQuickView> &window, const char *fileName); + QTouchDevice *touchDevice; + QQuickPointerDevice *touchPointerDevice; +}; + +void tst_MouseAreaInterop::createView(QScopedPointer<QQuickView> &window, const char *fileName) +{ + window.reset(new QQuickView); + window->setSource(testFileUrl(fileName)); + QTRY_COMPARE(window->status(), QQuickView::Ready); + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(window->rootObject() != nullptr); +} + +void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaMouse() +{ + const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "dragTakeOverFromSibling.qml"); + QQuickView * window = windowPtr.data(); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::genericMouseDevice()); + + QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); + QVERIFY(handler); + QQuickMouseArea *ma = window->rootObject()->findChild<QQuickMouseArea*>(); + QVERIFY(ma); + + QPoint p1(150, 150); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QCOMPARE(window->mouseGrabberItem(), ma); + QCOMPARE(ma->pressed(), true); + + // Start dragging + // DragHandler keeps monitoring, due to its passive grab, + // and eventually steals the exclusive grab from MA + int dragStoleGrab = 0; + for (int i = 0; i < 4; ++i) { + p1 += QPoint(dragThreshold / 2, 0); + QTest::mouseMove(window, p1); + if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler) + dragStoleGrab = i; + } + if (dragStoleGrab) + qCDebug(lcPointerTests, "DragHandler stole the grab after %d events", dragStoleGrab); + QVERIFY(dragStoleGrab > 1); + QCOMPARE(handler->active(), true); + QCOMPARE(ma->pressed(), false); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QCOMPARE(handler->active(), false); +} + +void tst_MouseAreaInterop::dragHandlerInSiblingStealingGrabFromMouseAreaViaTouch() // QTBUG-77624 +{ + const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); + QScopedPointer<QQuickView> windowPtr; + createView(windowPtr, "dragTakeOverFromSibling.qml"); + QQuickView * window = windowPtr.data(); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); + + QPointer<QQuickPointerHandler> handler = window->rootObject()->findChild<QQuickPointerHandler*>(); + QVERIFY(handler); + QQuickMouseArea *ma = window->rootObject()->findChild<QQuickMouseArea*>(); + QVERIFY(ma); + + QPoint p1(150, 150); + QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice); + + touch.press(1, p1).commit(); + QQuickTouchUtils::flush(window); + QTRY_VERIFY(pointerEvent->point(0)->passiveGrabbers().contains(handler)); + QCOMPARE(pointerEvent->point(0)->grabberItem(), ma); + QCOMPARE(window->mouseGrabberItem(), ma); + QCOMPARE(ma->pressed(), true); + + // Start dragging + // DragHandler keeps monitoring, due to its passive grab, + // and eventually steals the exclusive grab from MA + int dragStoleGrab = 0; + for (int i = 0; i < 4; ++i) { + p1 += QPoint(dragThreshold / 2, 0); + touch.move(1, p1).commit(); + QQuickTouchUtils::flush(window); + if (!dragStoleGrab && pointerEvent->point(0)->exclusiveGrabber() == handler) + dragStoleGrab = i; + } + if (dragStoleGrab) + qCDebug(lcPointerTests, "DragHandler stole the grab after %d events", dragStoleGrab); + QVERIFY(dragStoleGrab > 1); + QCOMPARE(handler->active(), true); + QCOMPARE(ma->pressed(), false); + + touch.release(1, p1).commit(); + QQuickTouchUtils::flush(window); + QCOMPARE(handler->active(), false); +} + +QTEST_MAIN(tst_MouseAreaInterop) + +#include "tst_mousearea_interop.moc" diff --git a/tests/auto/quick/pointerhandlers/pointerhandlers.pro b/tests/auto/quick/pointerhandlers/pointerhandlers.pro index 4d6311bdb2..7db28b6583 100644 --- a/tests/auto/quick/pointerhandlers/pointerhandlers.pro +++ b/tests/auto/quick/pointerhandlers/pointerhandlers.pro @@ -3,6 +3,7 @@ TEMPLATE = subdirs qtConfig(private_tests) { SUBDIRS += \ flickableinterop \ + mousearea_interop \ multipointtoucharea_interop \ qquickdraghandler \ qquickhoverhandler \ diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index fb5ae168e8..02c36c76ca 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -268,6 +268,7 @@ private slots: void QTBUG_61269_appendDuringScrollDown_data(); void QTBUG_50097_stickyHeader_positionViewAtIndex(); void QTBUG_63974_stickyHeader_positionViewAtIndex_Contain(); + void QTBUG_66163_setModelViewPortSizeChange(); void itemFiltered(); void releaseItems(); @@ -8855,6 +8856,62 @@ void tst_QQuickListView::QTBUG_63974_stickyHeader_positionViewAtIndex_Contain() QTRY_COMPARE(listview->contentY(), -headerSize); } +void tst_QQuickListView::QTBUG_66163_setModelViewPortSizeChange() +{ + QScopedPointer<QQuickView> window(createView()); + QQmlComponent comp(window->engine()); + comp.setData(R"( + import QtQuick 2.0 + + Item { + id: root + width: 400 + height: 400 + + ListView { + id: view + objectName: "view" + anchors.fill: parent + + model: 4 + highlightRangeMode: ListView.StrictlyEnforceRange + + delegate: Rectangle { + color: index % 2 ? "green" : "orange" + width: parent.width + height: 50 + } + + populate: Transition { + SequentialAnimation { + NumberAnimation { property: "y"; from: 100; duration: 1000 } + } + } + } + } + )", QUrl("testData")); + auto root {qobject_cast<QQuickItem*>(comp.create())}; + QVERIFY(root); + window->setContent(QUrl(), &comp, root); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + auto view = root->findChild<QQuickListView *>("view"); + QVERIFY(view); + QVERIFY(QQuickTest::qWaitForItemPolished(view)); + QSignalSpy spy(view, &QQuickListView::contentYChanged); + auto transition = view->property("populate").value<QQuickTransition*>(); + QVERIFY(transition); + QQmlProperty model(view, "model"); + QVERIFY(model.isValid()); + model.write(5); + // Animations inside a Transition do not emit a finished signal + // so we cannot wait for them in that way + QTest::qWait(1100); // animation takes 1000ms, + 10% extra delay + /* the viewport should not have changed, thus there should not have + been any contentYChanged signal*/ + QCOMPARE(spy.count(), 0); +} + void tst_QQuickListView::itemFiltered() { QStringListModel model(QStringList() << "one" << "two" << "three" << "four" << "five" << "six"); diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 1d12121a6f..e1da7e5795 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -6428,6 +6428,14 @@ void tst_qquicktextinput::setInputMask() QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create()); QVERIFY(textInput != nullptr); + // [QTBUG-80190] check if setting the same property value again doesn't emit an + // inputMaskChanged signal + QString unescapedMask = mask; // mask is escaped, because '\' is also escape in a JS string + unescapedMask.replace(QLatin1String("\\\\"), QLatin1String("\\")); // simple unescape + QSignalSpy spy(textInput, SIGNAL(inputMaskChanged(const QString &))); + textInput->setInputMask(unescapedMask); + QCOMPARE(spy.count(), 0); + // then either insert using insert() or keyboard if (insert_text) { textInput->insert(0, input); diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp index 86945e71a4..3cc83e94da 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp +++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp @@ -72,6 +72,7 @@ private: QString grabberPath; int consecutiveErrors; // Not test failures (image mismatches), but system failures (so no image at all) bool aborted; // This run given up because of too many system failures + bool usingRhi; }; @@ -105,6 +106,23 @@ void tst_Scenegraph::initTestCase() const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default")); QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend); +#if defined(Q_OS_WIN) + const char *defaultRhiBackend = "d3d11"; +#elif defined(Q_OS_DARWIN) + const char *defaultRhiBackend = "metal"; +#else + const char *defaultRhiBackend = "opengl"; +#endif + usingRhi = qEnvironmentVariableIntValue("QSG_RHI") != 0; + QString stack; + if (usingRhi) { + const QString rhiBackend = qEnvironmentVariable("QSG_RHI_BACKEND", QString::fromLatin1(defaultRhiBackend)); + stack = QString::fromLatin1("RHI_%1").arg(rhiBackend); + } else { + stack = qEnvironmentVariable("QT_QUICK_BACKEND", QString::fromLatin1("DirectGL")); + } + QBaselineTest::addClientProperty(QString::fromLatin1("GraphicsStack"), stack); + QByteArray msg; if (!QBaselineTest::connectToBaselineServer(&msg)) QSKIP(msg); @@ -134,7 +152,7 @@ void tst_Scenegraph::testNoTextRendering() void tst_Scenegraph::testRendering_data() { - setupTestSuite(); + setupTestSuite(usingRhi ? "shaders/" : ""); // on RHI, skip shader effects tests for now consecutiveErrors = 0; aborted = false; } |