aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-04-26 15:05:14 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-04-27 05:22:25 +0000
commit3d80bbb6b47bc524f8243de26ff181026e8fc52d (patch)
treeb714a387e20053f4aa7a3bc0e55fa571dc1c59ba /tests
parentf6bbeeb417102c61e8bf23f41e412ed9753a348d (diff)
Fix qmlInfo and friends for anonymous components
When used on for example delegates we can and should also print the line number and column where the component is declared. Change-Id: I0f02c675425700cde119352d0001895cc31a4c73 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlinfo/data/Component.qml8
-rw-r--r--tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp14
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlinfo/data/Component.qml b/tests/auto/qml/qqmlinfo/data/Component.qml
new file mode 100644
index 0000000000..fefbbfae76
--- /dev/null
+++ b/tests/auto/qml/qqmlinfo/data/Component.qml
@@ -0,0 +1,8 @@
+import QtQml 2.0
+
+QtObject {
+ property Component delegate: Component {
+ QtObject {
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
index ada3f9e37b..5ff72de0a0 100644
--- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
+++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
@@ -50,6 +50,7 @@ private slots:
void types();
void chaining();
void messageTypes();
+ void component();
private:
QQmlEngine engine;
@@ -216,6 +217,19 @@ void tst_qqmlinfo::messageTypes()
qmlWarning(nullptr) << QLatin1String("warning");
}
+void tst_qqmlinfo::component()
+{
+ QQmlComponent component(&engine, testFileUrl("Component.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != nullptr);
+ QQmlComponent *delegate = qobject_cast<QQmlComponent*>(object->property("delegate").value<QObject*>());
+ QVERIFY(delegate);
+
+ QString message = component.url().toString() + ":4:34: QML Component: Delegate error";
+ QTest::ignoreMessage(QtInfoMsg, qPrintable(message));
+ qmlInfo(delegate) << "Delegate error";
+}
+
QTEST_MAIN(tst_qqmlinfo)
#include "tst_qqmlinfo.moc"