From 120eb155ef1f0da51c473b080880169a85e5ceb2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 18 Feb 2021 11:40:31 +0100 Subject: 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 (cherry picked from commit 08c8e8ac3ba8eb23ae5c158990f5d029ac9988ed) --- tests/auto/qml/qmllint/data/badBinding.qml | 5 +++++ tests/auto/qml/qmllint/data/badPropertyType.qml | 6 ++++++ tests/auto/qml/qmllint/data/enumProperty.qml | 5 +++++ tests/auto/qml/qmllint/tst_qmllint.cpp | 11 +++++++++++ 4 files changed, 27 insertions(+) create mode 100644 tests/auto/qml/qmllint/data/badBinding.qml create mode 100644 tests/auto/qml/qmllint/data/badPropertyType.qml create mode 100644 tests/auto/qml/qmllint/data/enumProperty.qml (limited to 'tests/auto') 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() -- cgit v1.2.3