aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2021-08-11 15:34:08 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2021-08-19 14:27:25 +0200
commit479c79abaa83feca8c3a3c1770c9c2975e2bbb70 (patch)
tree8725022beca1f69cf5ed951085f492bdf057539e /tests
parent733f971757d4283ca007f52ebd0ee5d38e59f55e (diff)
qmlcompiler: handle script bindings on grouped/attached properties
The script bindings on grouped/attached properties were ignored before, basically allowing bogus QML to pass qmllint On top of fixing the property binding processing, better source locations are also used instead of fairly random ones Change-Id: I1f34ce33c35e64e31879e872a8d87038f10ea897 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 3dc31b257c98dee7627aec02d744c8a04a476203) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qmllint/data/animationEasing.qml5
-rw-r--r--tests/auto/qml/qmllint/data/badScript.attached.qml4
-rw-r--r--tests/auto/qml/qmllint/data/badScriptBinding.attached.qml6
-rw-r--r--tests/auto/qml/qmllint/data/badScriptBinding.attachedSignalHandler.qml7
-rw-r--r--tests/auto/qml/qmllint/data/badScriptBinding.group.qml4
-rw-r--r--tests/auto/qml/qmllint/data/goodAttachedPropertyAccess.qml3
-rw-r--r--tests/auto/qml/qmllint/data/goodBindingsOnGroupAndAttached.qml11
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp23
8 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/animationEasing.qml b/tests/auto/qml/qmllint/data/animationEasing.qml
new file mode 100644
index 0000000000..1b0c9ffea4
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/animationEasing.qml
@@ -0,0 +1,5 @@
+import QtQml
+import QtQuick
+NumberAnimation {
+ easing.type: Easing.InOutQuad
+}
diff --git a/tests/auto/qml/qmllint/data/badScript.attached.qml b/tests/auto/qml/qmllint/data/badScript.attached.qml
new file mode 100644
index 0000000000..f3183430fc
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badScript.attached.qml
@@ -0,0 +1,4 @@
+import QtQuick
+Text {
+ font.pixelSize: 10 + pointSize * 0.1 // pointSize does not exist in the scope of the binding
+}
diff --git a/tests/auto/qml/qmllint/data/badScriptBinding.attached.qml b/tests/auto/qml/qmllint/data/badScriptBinding.attached.qml
new file mode 100644
index 0000000000..a5ec7d9050
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badScriptBinding.attached.qml
@@ -0,0 +1,6 @@
+import QtQuick.Layouts
+RowLayout {
+ function returnTrue() { return true; }
+ Layout.fillWidth: returnTrue()
+ Layout.bogusProperty: returnTrue()
+}
diff --git a/tests/auto/qml/qmllint/data/badScriptBinding.attachedSignalHandler.qml b/tests/auto/qml/qmllint/data/badScriptBinding.attachedSignalHandler.qml
new file mode 100644
index 0000000000..56d89a81da
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badScriptBinding.attachedSignalHandler.qml
@@ -0,0 +1,7 @@
+import QtQuick
+Rectangle {
+ Keys.onBogusSignal: function(event) {
+ // the handler is good, but the signal doesn't exist
+ console.log(event);
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/badScriptBinding.group.qml b/tests/auto/qml/qmllint/data/badScriptBinding.group.qml
new file mode 100644
index 0000000000..d92feb81f0
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/badScriptBinding.group.qml
@@ -0,0 +1,4 @@
+import QtQuick
+Text {
+ font.bogusProperty: "foo" + "bar"
+}
diff --git a/tests/auto/qml/qmllint/data/goodAttachedPropertyAccess.qml b/tests/auto/qml/qmllint/data/goodAttachedPropertyAccess.qml
index c46370521a..b7f64d9acb 100644
--- a/tests/auto/qml/qmllint/data/goodAttachedPropertyAccess.qml
+++ b/tests/auto/qml/qmllint/data/goodAttachedPropertyAccess.qml
@@ -6,6 +6,9 @@ QtObject {
}
Component.onCompleted: {
+ // NB: this currently fails as TestType.object is recognized as QtObject
+ // *exactly*, ignoring the QML code above and thus there's no 'progress'
+ // property on TestType.object
console.log(TestType.object.progress);
}
}
diff --git a/tests/auto/qml/qmllint/data/goodBindingsOnGroupAndAttached.qml b/tests/auto/qml/qmllint/data/goodBindingsOnGroupAndAttached.qml
new file mode 100644
index 0000000000..7a89b82f6e
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/goodBindingsOnGroupAndAttached.qml
@@ -0,0 +1,11 @@
+import QtQuick
+Rectangle {
+ Text {
+ font.pixelSize: 42
+ }
+
+ Keys.enabled: false
+ Keys.onPressed: function(event) {
+ console.log(event);
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 8a54fa074f..ec1c4174f9 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -428,6 +428,9 @@ void TestQmllint::dirtyQmlCode_data()
<< QString("Warning: %1:5:21: Property \"stuff\" not found on type \"Empty\"")
<< QString()
<< false;
+ QTest::newRow("badScriptOnAttachedProperty")
+ << QStringLiteral("badScript.attached.qml")
+ << QString("Warning: %1:3:26: Unqualified access") << QString() << false;
QTest::newRow("brokenNamespace")
<< QStringLiteral("brokenNamespace.qml")
<< QString("Warning: %1:4:17: Type not found in namespace")
@@ -472,6 +475,21 @@ void TestQmllint::dirtyQmlCode_data()
"\"doesNotExist\" exists in the current element.")
<< QString()
<< false;
+ QTest::newRow("BadScriptBindingOnGroup")
+ << QStringLiteral("badScriptBinding.group.qml")
+ << QStringLiteral("Warning: %1:3:10: Binding assigned to \"bogusProperty\", but no "
+ "property \"bogusProperty\" exists in the current element.")
+ << QString() << false;
+ QTest::newRow("BadScriptBindingOnAttachedType")
+ << QStringLiteral("badScriptBinding.attached.qml")
+ << QStringLiteral("Warning: %1:5:12: Binding assigned to \"bogusProperty\", but no "
+ "property \"bogusProperty\" exists in the current element.")
+ << QString() << false;
+ QTest::newRow("BadScriptBindingOnAttachedSignalHandler")
+ << QStringLiteral("badScriptBinding.attachedSignalHandler.qml")
+ << QStringLiteral(
+ "Warning: %1:3:10: no matching signal found for handler \"onBogusSignal\"")
+ << QString() << false;
QTest::newRow("BadPropertyType")
<< QStringLiteral("badPropertyType.qml")
<< QStringLiteral("No type found for property \"bad\". This may be due to a missing "
@@ -624,6 +642,9 @@ void TestQmllint::dirtyQmlCode_data()
QTest::newRow("nestedInlineComponents")
<< QStringLiteral("nestedInlineComponents.qml")
<< QStringLiteral("Nested inline components are not supported") << QString() << false;
+ QTest::newRow("QQmlEasingEnums::Type")
+ << QStringLiteral("animationEasing.qml")
+ << QStringLiteral("No type found for property \"type\"") << QString() << false;
}
void TestQmllint::dirtyQmlCode()
@@ -766,6 +787,8 @@ void TestQmllint::cleanQmlCode_data()
<< QStringLiteral("customParserUnqualifiedAccess.qml");
QTest::newRow("ImportQMLModule") << QStringLiteral("importQMLModule.qml");
QTest::newRow("ImportDirectoryQmldir") << QStringLiteral("Things/LintDirectly.qml");
+ QTest::newRow("BindingsOnGroupAndAttachedProperties")
+ << QStringLiteral("goodBindingsOnGroupAndAttached.qml");
}
void TestQmllint::cleanQmlCode()