aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-18 11:40:31 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-24 08:33:21 +0100
commit120eb155ef1f0da51c473b080880169a85e5ceb2 (patch)
treeb8bc85734d68f125d424b1f45f2576d20c885a43 /tests
parentae68d95b8c1c56ae907cbe88122dd79bafd20b72 (diff)
qmllint: Check for existence of property types
For each binding there should be a property and that property should have a type we recognize. Enums can be property types in C++. We support this by adding child scopes for such enums. The child scopes are then referenced by the QQmlJSMetaEnums and derive from int. The test then reveals that we were missing a few properties in QtQuick.tooling. Add those. Change-Id: I1deef94393ee0e17d34c2dc5980ebfbf25417f36 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 08c8e8ac3ba8eb23ae5c158990f5d029ac9988ed)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmllint/data/badBinding.qml5
-rw-r--r--tests/auto/qml/qmllint/data/badPropertyType.qml6
-rw-r--r--tests/auto/qml/qmllint/data/enumProperty.qml5
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp11
4 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/badBinding.qml b/tests/auto/qml/qmllint/data/badBinding.qml
new file mode 100644
index 0000000000..8e781710a2
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badBinding.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ doesNotExist: 12
+}
diff --git a/tests/auto/qml/qmllint/data/badPropertyType.qml b/tests/auto/qml/qmllint/data/badPropertyType.qml
new file mode 100644
index 0000000000..97484ea0bb
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badPropertyType.qml
@@ -0,0 +1,6 @@
+import QtQml
+
+QtObject {
+ property badtype bad
+ bad: "abc"
+}
diff --git a/tests/auto/qml/qmllint/data/enumProperty.qml b/tests/auto/qml/qmllint/data/enumProperty.qml
new file mode 100644
index 0000000000..d385346c87
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/enumProperty.qml
@@ -0,0 +1,5 @@
+import QtQuick.Layouts
+
+GridLayout {
+ flow: GridLayout.TopToBottom
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index a86c202790..db44193871 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -306,6 +306,16 @@ void TestQmllint::dirtyQmlCode_data()
<< QStringLiteral("badAttached.qml")
<< QStringLiteral("unknown attached property scope WrongAttached.")
<< QString();
+ QTest::newRow("BadBinding")
+ << QStringLiteral("badBinding.qml")
+ << QStringLiteral("Binding assigned to \"doesNotExist\", but no property "
+ "\"doesNotExist\" exists in the current element.")
+ << QString();
+ QTest::newRow("BadPropertyType")
+ << QStringLiteral("badPropertyType.qml")
+ << QStringLiteral("No type found for property \"bad\". This may be due to a missing "
+ "import statement or incomplete qmltypes files.")
+ << QString();
}
void TestQmllint::dirtyQmlCode()
@@ -371,6 +381,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("grouped scope failure") << QStringLiteral("groupedScope.qml");
QTest::newRow("layouts depends quick") << QStringLiteral("layouts.qml");
QTest::newRow("attached") << QStringLiteral("attached.qml");
+ QTest::newRow("enumProperty") << QStringLiteral("enumProperty.qml");
}
void TestQmllint::cleanQmlCode()