diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-07-23 17:29:11 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-07-27 17:59:28 +0200 |
commit | c551d02cb0fec2f3d753beb4ec38c14843518c33 (patch) | |
tree | b034030f9802db8de16dff9b83e647c678207431 /tests | |
parent | fdbe0f21744a1cc1785cd10346437b03029fe65d (diff) |
QQmlInfo: print ancestor of object if it has no QML engine
This results in the following message for objects without a QML engine:
QML AttachedObject (parent or ancestor of Attached): Binding loop
detected for property "a"
for this QML file, named AttachedObject.qml:
import QtQuick 2.0
import org.qtproject.Test 1.0
Item {
Attached.a: Attached.a
}
This, in turn, allows the warning to be emitted via the
QQmlEngine::warnings signal, since QQmlEnginePrivate::warning() is now
passed a valid engine. This solves the awkward situation where a
binding loop warning can not be detected at all by auto tests involving
attached C++ objects (as message handlers do not receive these messages
either).
Change-Id: I07589974207bd5448d22a6086a52b9230d23e298
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 31c892118ce822ca2e7ded99ff261187ce4cf597)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlinfo/attached.cpp | 52 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinfo/attached.h | 53 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinfo/data/AttachedObject.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinfo/qqmlinfo.pro | 12 | ||||
-rw-r--r-- | tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp | 36 | ||||
-rw-r--r-- | tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 56 | ||||
-rw-r--r-- | tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp | 141 |
7 files changed, 261 insertions, 100 deletions
diff --git a/tests/auto/qml/qqmlinfo/attached.cpp b/tests/auto/qml/qqmlinfo/attached.cpp new file mode 100644 index 0000000000..f4b866a547 --- /dev/null +++ b/tests/auto/qml/qqmlinfo/attached.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "attached.h" + +Attached::Attached(QObject *parent) : + QObject(parent) +{ +} + +int Attached::a() const +{ + return mA; +} + +void Attached::setA(int a) +{ + // Intentionally omit the early return in order to force a binding loop. + + mA = a; + emit aChanged(); +} + +Attached *Attached::qmlAttachedProperties(QObject *object) +{ + return new Attached(object); +} diff --git a/tests/auto/qml/qqmlinfo/attached.h b/tests/auto/qml/qqmlinfo/attached.h new file mode 100644 index 0000000000..ece335ebbe --- /dev/null +++ b/tests/auto/qml/qqmlinfo/attached.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QtQml/qqml.h> + +class Attached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int a READ a WRITE setA NOTIFY aChanged) + QML_ELEMENT + QML_ATTACHED(Attached) + QML_UNCREATABLE("") + +public: + Attached(QObject *parent = nullptr); + + int a() const; + void setA(int a); + + static Attached *qmlAttachedProperties(QObject *object); + +signals: + void aChanged(); + void stuffChanged(); + +private: + int mA = 0; +}; diff --git a/tests/auto/qml/qqmlinfo/data/AttachedObject.qml b/tests/auto/qml/qqmlinfo/data/AttachedObject.qml new file mode 100644 index 0000000000..b714a10a1c --- /dev/null +++ b/tests/auto/qml/qqmlinfo/data/AttachedObject.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import org.qtproject.Test 1.0 + +Item { + Attached.a: Attached.a + + Rectangle { + width: height + 1 + height: width + 1 + } +} diff --git a/tests/auto/qml/qqmlinfo/qqmlinfo.pro b/tests/auto/qml/qqmlinfo/qqmlinfo.pro index 89b4abd00c..96ce4a5bd8 100644 --- a/tests/auto/qml/qqmlinfo/qqmlinfo.pro +++ b/tests/auto/qml/qqmlinfo/qqmlinfo.pro @@ -1,8 +1,16 @@ -CONFIG += testcase +CONFIG += testcase qmltypes TARGET = tst_qqmlinfo macx:CONFIG -= app_bundle -SOURCES += tst_qqmlinfo.cpp +QML_IMPORT_NAME = org.qtproject.Test +QML_IMPORT_MAJOR_VERSION = 1 + +HEADERS += \ + attached.h + +SOURCES += \ + attached.cpp \ + tst_qqmlinfo.cpp include (../../shared/util.pri) diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp index 5ff72de0a0..2704a8878d 100644 --- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp +++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include <qtest.h> +#include <QtTest/qsignalspy.h> #include <QQmlEngine> #include <QQmlComponent> #include <QTimer> @@ -34,6 +35,8 @@ #include <qqmlinfo.h> #include "../../shared/util.h" +#include "attached.h" + class tst_qqmlinfo : public QQmlDataTest { Q_OBJECT @@ -51,6 +54,7 @@ private slots: void chaining(); void messageTypes(); void component(); + void attachedObject(); private: QQmlEngine engine; @@ -230,6 +234,38 @@ void tst_qqmlinfo::component() qmlInfo(delegate) << "Delegate error"; } +Q_DECLARE_METATYPE(QList<QQmlError>) + +void tst_qqmlinfo::attachedObject() +{ + qRegisterMetaType<QList<QQmlError>>(); + + QQmlComponent component(&engine, testFileUrl("AttachedObject.qml")); + + QSignalSpy warningSpy(&engine, SIGNAL(warnings(const QList<QQmlError> &))); + QVERIFY(warningSpy.isValid()); + + const QString qmlBindingLoopMessage = "QML Rectangle: Binding loop detected for property \"width\""; + const QString qmlBindingLoopMessageFull = component.url().toString() + ":7:5: " + qmlBindingLoopMessage; + QTest::ignoreMessage(QtWarningMsg, qPrintable(qmlBindingLoopMessageFull)); + + const QString cppBindingLoopMessage = "QML AttachedObject (parent or ancestor of Attached): Binding loop detected for property \"a\""; + const QString cppBindingLoopMessageFull = component.url().toString() + ":4:1: " + cppBindingLoopMessage; + QTest::ignoreMessage(QtWarningMsg, qPrintable(cppBindingLoopMessageFull)); + + QScopedPointer<QObject> object(component.create()); + QVERIFY2(object != nullptr, qPrintable(component.errorString())); + QCOMPARE(warningSpy.count(), 2); + + // The Attached C++ type has no QML engine since it was created in C++, so we should see its parent instead. + const auto cppWarnings = warningSpy.at(0).first().value<QList<QQmlError>>(); + QCOMPARE(cppWarnings.first().description(), cppBindingLoopMessage); + + // The QML type has a QML engine, so we should see the normal message. + const auto qmlWarnings = warningSpy.at(1).first().value<QList<QQmlError>>(); + QCOMPARE(qmlWarnings.first().description(), qmlBindingLoopMessage); +} + QTEST_MAIN(tst_qqmlinfo) #include "tst_qqmlinfo.moc" diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index f1288c2dbe..b90c9c3c45 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -1084,131 +1084,131 @@ void tst_QQuickDrag::recursion_data() QTest::addColumn<QString>("script"); QTest::addColumn<int>("type"); QTest::addColumn<int>("moveEvents"); - QTest::addColumn<QByteArray>("warning"); + QTest::addColumn<QRegularExpression>("warning"); QTest::newRow("Drag.start() in Enter") << QString("Drag.start()") << int(QEvent::DragEnter) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + << QRegularExpression(".*start\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Enter") << QString("Drag.cancel()") << int(QEvent::DragEnter) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + << QRegularExpression(".*cancel\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Enter") << QString("Drag.drop()") << int(QEvent::DragEnter) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + << QRegularExpression(".*drop\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Enter") << QString("Drag.active = true") << int(QEvent::DragEnter) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("Drag.active = false in Enter") << QString("Drag.active = false") << int(QEvent::DragEnter) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + << QRegularExpression(".*active cannot be changed from within a drag event handler"); QTest::newRow("move in Enter") << QString("x = 23") << int(QEvent::DragEnter) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("Drag.start() in Move") << QString("Drag.start()") << int(QEvent::DragMove) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + << QRegularExpression(".*start\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Move") << QString("Drag.cancel()") << int(QEvent::DragMove) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + << QRegularExpression(".*cancel\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Move") << QString("Drag.drop()") << int(QEvent::DragMove) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + << QRegularExpression(".*drop\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Move") << QString("Drag.active = true") << int(QEvent::DragMove) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("Drag.active = false in Move") << QString("Drag.active = false") << int(QEvent::DragMove) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + << QRegularExpression(".*active cannot be changed from within a drag event handler"); QTest::newRow("move in Move") << QString("x = 23") << int(QEvent::DragMove) << 2 - << QByteArray(); + << QRegularExpression(); QTest::newRow("Drag.start() in Leave") << QString("Drag.start()") << int(QEvent::DragLeave) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + << QRegularExpression(".*start\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Leave") << QString("Drag.cancel()") << int(QEvent::DragLeave) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + << QRegularExpression(".*cancel\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Leave") << QString("Drag.drop()") << int(QEvent::DragLeave) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + << QRegularExpression(".*drop\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Leave") << QString("Drag.active = true") << int(QEvent::DragLeave) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + << QRegularExpression(".*active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Leave") << QString("Drag.active = false") << int(QEvent::DragLeave) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("move in Leave") << QString("x = 23") << int(QEvent::DragLeave) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("Drag.start() in Drop") << QString("Drag.start()") << int(QEvent::Drop) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + << QRegularExpression(".*start\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.cancel() in Drop") << QString("Drag.cancel()") << int(QEvent::Drop) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + << QRegularExpression(".*cancel\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.drop() in Drop") << QString("Drag.drop()") << int(QEvent::Drop) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + << QRegularExpression(".*drop\\(\\) cannot be called from within a drag event handler"); QTest::newRow("Drag.active = true in Drop") << QString("Drag.active = true") << int(QEvent::Drop) << 1 - << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + << QRegularExpression(".*active cannot be changed from within a drag event handler"); QTest::newRow("Drag.active = false in Drop") << QString("Drag.active = false") << int(QEvent::Drop) << 1 - << QByteArray(); + << QRegularExpression(); QTest::newRow("move in Drop") << QString("x = 23") << int(QEvent::Drop) << 1 - << QByteArray(); + << QRegularExpression(); } void tst_QQuickDrag::recursion() @@ -1216,10 +1216,10 @@ void tst_QQuickDrag::recursion() QFETCH(QString, script); QFETCH(int, type); QFETCH(int, moveEvents); - QFETCH(QByteArray, warning); + QFETCH(QRegularExpression, warning); - if (!warning.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, warning.constData()); + if (!warning.pattern().isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning); QQuickWindow window; RecursingDropTarget dropTarget(script, type, window.contentItem()); diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 66069c48cb..27bd8aae49 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -30,6 +30,7 @@ #include "../shared/viewtestutil.h" #include <qtest.h> +#include <QtCore/qregularexpression.h> #include <QtTest/QSignalSpy> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> @@ -1460,22 +1461,22 @@ void tst_qquickvisualdatamodel::remove() QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); } } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: remove: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*remove: index out of range")); evaluate<void>(visualModel, "items.remove(-8, 4)"); QCOMPARE(listview->count(), 7); QCOMPARE(visualModel->items()->count(), 7); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: remove: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*remove: index out of range")); evaluate<void>(visualModel, "items.remove(12, 2)"); QCOMPARE(listview->count(), 7); QCOMPARE(visualModel->items()->count(), 7); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: remove: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*remove: invalid count")); evaluate<void>(visualModel, "items.remove(5, 3)"); QCOMPARE(listview->count(), 7); QCOMPARE(visualModel->items()->count(), 7); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: remove: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*remove: invalid count")); evaluate<void>(visualModel, "items.remove(5, -2)"); QCOMPARE(listview->count(), 7); QCOMPARE(visualModel->items()->count(), 7); @@ -1597,37 +1598,37 @@ void tst_qquickvisualdatamodel::move() QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); } } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: invalid count")); evaluate<void>(visualModel, "items.move(5, 2, -2)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: from index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: from index out of range")); evaluate<void>(visualModel, "items.move(-6, 2, 1)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: from index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: from index out of range")); evaluate<void>(visualModel, "items.move(15, 2, 1)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: from index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: from index out of range")); evaluate<void>(visualModel, "items.move(11, 1, 3)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: to index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: to index out of range")); evaluate<void>(visualModel, "items.move(2, -5, 1)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: to index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: to index out of range")); evaluate<void>(visualModel, "items.move(2, 14, 1)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: move: to index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*move: to index out of range")); evaluate<void>(visualModel, "items.move(2, 11, 4)"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); @@ -1790,82 +1791,82 @@ void tst_qquickvisualdatamodel::groups() static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; VERIFY_GROUPS; } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: addGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*addGroups: invalid count")); evaluate<void>(visualModel, "items.addGroups(11, -4, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: addGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*addGroups: index out of range")); evaluate<void>(visualModel, "items.addGroups(-1, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: addGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*addGroups: index out of range")); evaluate<void>(visualModel, "items.addGroups(14, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: addGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*addGroups: invalid count")); evaluate<void>(visualModel, "items.addGroups(11, 5, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: setGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*setGroups: invalid count")); evaluate<void>(visualModel, "items.setGroups(11, -4, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: setGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*setGroups: index out of range")); evaluate<void>(visualModel, "items.setGroups(-1, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: setGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*setGroups: index out of range")); evaluate<void>(visualModel, "items.setGroups(14, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: setGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*setGroups: invalid count")); evaluate<void>(visualModel, "items.setGroups(11, 5, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: removeGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*removeGroups: invalid count")); evaluate<void>(visualModel, "items.removeGroups(11, -4, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: removeGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*removeGroups: index out of range")); evaluate<void>(visualModel, "items.removeGroups(-1, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: removeGroups: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*removeGroups: index out of range")); evaluate<void>(visualModel, "items.removeGroups(14, 3, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); QCOMPARE(visibleItems->count(), 9); QCOMPARE(selectedItems->count(), 2); } { - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: removeGroups: invalid count"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*removeGroups: invalid count")); evaluate<void>(visualModel, "items.removeGroups(11, 5, \"items\")"); QCOMPARE(listview->count(), 12); QCOMPARE(visualModel->items()->count(), 12); @@ -2466,7 +2467,7 @@ void tst_qquickvisualdatamodel::incompleteModel() QCOMPARE(itemsSpy.count(), 0); QCOMPARE(persistedItemsSpy.count(), 0); - QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML DelegateModelGroup: get: index out of range"); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(".*get: index out of range")); QVERIFY(evaluate<bool>(model, "items.get(0) === undefined")); component.completeCreate(); @@ -3660,73 +3661,73 @@ void tst_qquickvisualdatamodel::warnings_data() { QTest::addColumn<QUrl>("source"); QTest::addColumn<QString>("expression"); - QTest::addColumn<QString>("warning"); + QTest::addColumn<QRegularExpression>("warning"); QTest::addColumn<int>("count"); QTest::newRow("insert < 0") << testFileUrl("listmodelproperties.qml") << QString("items.insert(-2, {\"number\": \"eight\"})") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("insert: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("insert: index out of range")) << 4; QTest::newRow("insert > length") << testFileUrl("listmodelproperties.qml") << QString("items.insert(8, {\"number\": \"eight\"})") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("insert: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("insert: index out of range")) << 4; QTest::newRow("create < 0") << testFileUrl("listmodelproperties.qml") << QString("items.create(-2, {\"number\": \"eight\"})") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("create: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("create: index out of range")) << 4; QTest::newRow("create > length") << testFileUrl("listmodelproperties.qml") << QString("items.create(8, {\"number\": \"eight\"})") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("create: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("create: index out of range")) << 4; QTest::newRow("resolve from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(-2, 3)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve from > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(8, 3)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: from index out of range")) << 4; QTest::newRow("resolve to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, -2)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: to index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve to > length") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 8)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: to index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: to index out of range")) << 4; QTest::newRow("resolve from invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(\"two\", 3)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: from index invalid")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: from index invalid")) << 4; QTest::newRow("resolve to invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, \"two\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: to index invalid")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: to index invalid")) << 4; QTest::newRow("resolve already resolved item") << testFileUrl("listmodelproperties.qml") << QString("items.resolve(3, 2)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: from is not an unresolved item")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: from is not an unresolved item")) << 4; QTest::newRow("resolve already resolved item") @@ -3734,193 +3735,193 @@ void tst_qquickvisualdatamodel::warnings_data() << QString("{ items.insert(0, {\"number\": \"eight\"});" "items.insert(1, {\"number\": \"seven\"});" "items.resolve(0, 1)}") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("resolve: to is not a model item")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("resolve: to is not a model item")) << 6; QTest::newRow("remove index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(-2, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index == length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(4, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove index > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(9, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: index out of range")) << 4; QTest::newRow("remove invalid index") << testFileUrl("listmodelproperties.qml") << QString("items.remove(\"nine\", 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: invalid index")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: invalid index")) << 4; QTest::newRow("remove count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.remove(1, -2)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: invalid count")) << 4; QTest::newRow("remove index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.remove(2, 4, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("remove: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("remove: invalid count")) << 4; QTest::newRow("addGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("addGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("addGroups: index out of range")) << 4; QTest::newRow("addGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("addGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("addGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.addGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("addGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("addGroups: invalid count")) << 4; QTest::newRow("removeGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("removeGroups: index out of range")) << 4; QTest::newRow("removeGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("removeGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.removeGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("removeGroups: invalid count")) << 4; QTest::newRow("setGroups index < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(-2, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index == length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(4, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups index > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(9, 1, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("setGroups: index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("setGroups: index out of range")) << 4; QTest::newRow("setGroups count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(1, -2, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("setGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("setGroups index + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.setGroups(2, 4, \"selected\")") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("setGroups: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("setGroups: invalid count")) << 4; QTest::newRow("move from < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(-2, 1, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(4, 1, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move from > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(9, 1, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; QTest::newRow("move invalid from") << testFileUrl("listmodelproperties.qml") << QString("items.move(\"nine\", 1, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: invalid from index")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: invalid from index")) << 4; QTest::newRow("move to < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, -2, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to == length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 4, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move to > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 9, 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: to index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: to index out of range")) << 4; QTest::newRow("move invalid to") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, \"nine\", 1)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: invalid to index")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: invalid to index")) << 4; QTest::newRow("move count < 0") << testFileUrl("listmodelproperties.qml") << QString("items.move(1, 1, -2)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: invalid count")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: invalid count")) << 4; QTest::newRow("move from + count > length") << testFileUrl("listmodelproperties.qml") << QString("items.move(2, 1, 4)") - << ("<Unknown File>: QML DelegateModelGroup: " + QQmlDelegateModelGroup::tr("move: from index out of range")) + << QRegularExpression(".*" + QQmlDelegateModelGroup::tr("move: from index out of range")) << 4; } @@ -3928,7 +3929,7 @@ void tst_qquickvisualdatamodel::warnings() { QFETCH(QUrl, source); QFETCH(QString, expression); - QFETCH(QString, warning); + QFETCH(QRegularExpression, warning); QFETCH(int, count); QQuickWindow window; @@ -3946,7 +3947,7 @@ void tst_qquickvisualdatamodel::warnings() QObject *visualModel = evaluate<QObject *>(listView, "model"); QVERIFY(visualModel); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); + QTest::ignoreMessage(QtWarningMsg, warning); evaluate<void>(visualModel, expression); QCOMPARE(evaluate<int>(listView, "count"), count); |