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/auto/quick/qquickdrag | |
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/auto/quick/qquickdrag')
-rw-r--r-- | tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
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()); |