diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-04-29 13:24:58 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-05-06 10:44:58 +0200 |
commit | 22f9e5fb1ed643f284f50b9417bdbafdfb20566b (patch) | |
tree | 9c2616522ca98534e2ceb6e4f13a9ffe5c622b93 /tests/auto | |
parent | 1250d8b5b95eecac767a23563717e53faa5d3b8a (diff) |
Add a default message to QML_UNCREATABLE
[ChangeLog][QML][Feature] Add a default message to QML_UNCREATABLE when
proving an empty string as a reason
Fixes: QTBUG-83842
Change-Id: Ifd2044fa6c56c3a382d451ec47d5f92a1ac16b81
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmllanguage/testtypes.h | 7 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 8852bf7af9..9c2aaa9e30 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1527,6 +1527,13 @@ private: UncreatableSingleton() { setObjectName("uncreatable"); } }; +class UncreatableElementNoReason : public QObject +{ + Q_OBJECT + QML_ELEMENT + QML_UNCREATABLE("") +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 4ea8de5a40..3dbaa2ec4e 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -333,6 +333,7 @@ private slots: void arrayToContainer(); void qualifiedScopeInCustomParser(); + void checkUncreatableNoReason(); private: QQmlEngine engine; QStringList defaultImportPathList; @@ -5839,6 +5840,17 @@ void tst_qqmllanguage::qualifiedScopeInCustomParser() QVERIFY(!obj.isNull()); } +void tst_qqmllanguage::checkUncreatableNoReason() +{ + qmlRegisterTypesAndRevisions<UncreatableElementNoReason>("qt.uncreatable.noreason", 1, 0); + QQmlEngine engine; + QString qml = QString("import QtQuick 2.0\nimport qt.uncreatable.noreason 1.0\nUncreatableElementNoReason {}"); + QQmlComponent c(&engine); + c.setData(qml.toUtf8(), QUrl::fromLocalFile(QDir::currentPath())); + QCOMPARE(c.errors().count(), 1); + QCOMPARE(c.errors().first().description(), QString("Type cannot be created in QML.")); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |