aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmllint
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmllint')
-rw-r--r--tests/auto/qml/qmllint/CMakeLists.txt4
-rw-r--r--tests/auto/qml/qmllint/data/Cycle/MenuItem.qml3
-rw-r--r--tests/auto/qml/qmllint/data/Cycle/qmldir3
-rw-r--r--tests/auto/qml/qmllint/data/LazyAndDirect/Direct.qml5
-rw-r--r--tests/auto/qml/qmllint/data/LazyAndDirect/Lazy.qml8
-rw-r--r--tests/auto/qml/qmllint/data/LazyAndDirect/qmldir4
-rw-r--r--tests/auto/qml/qmllint/data/Qt5Compat/GraphicalEffects/private/qmldir2
-rw-r--r--tests/auto/qml/qmllint/data/Things/LintDirectly.qml4
-rw-r--r--tests/auto/qml/qmllint/data/Things/NotPartOfThings.qml3
-rw-r--r--tests/auto/qml/qmllint/data/accessibleId.qml14
-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/cachedDependency.qml23
-rw-r--r--tests/auto/qml/qmllint/data/connectionNoParent.qml5
-rw-r--r--tests/auto/qml/qmllint/data/cycleHead.qml7
-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/data/inaccessibleId.qml12
-rw-r--r--tests/auto/qml/qmllint/data/inaccessibleId2.qml10
-rw-r--r--tests/auto/qml/qmllint/data/invalidId1.qml5
-rw-r--r--tests/auto/qml/qmllint/data/missingBuiltinsNoCrash.qml3
-rw-r--r--tests/auto/qml/qmllint/data/missingQmltypes.qml4
-rw-r--r--tests/auto/qml/qmllint/data/multiGrouped.qml6
-rw-r--r--tests/auto/qml/qmllint/data/onBindingInGroupedProperty.qml10
-rw-r--r--tests/auto/qml/qmllint/data/prefixedAttachedProperty.qml5
-rw-r--r--tests/auto/qml/qmllint/data/qmodelIndex.qml6
-rw-r--r--tests/auto/qml/qmllint/data/requiredProperty.qml12
-rw-r--r--tests/auto/qml/qmllint/data/requiredPropertyInComponent.qml25
-rw-r--r--tests/auto/qml/qmllint/data/settings/bare/.qmllint.ini2
-rw-r--r--tests/auto/qml/qmllint/data/settings/bare/bare.qml3
-rw-r--r--tests/auto/qml/qmllint/data/settings/qmltypes/.qmllint.ini2
-rw-r--r--tests/auto/qml/qmllint/data/settings/qmltypes/custom.qmltypes11
-rw-r--r--tests/auto/qml/qmllint/data/settings/qmltypes/qmltypes.qml3
-rw-r--r--tests/auto/qml/qmllint/data/stringAsId.qml5
-rw-r--r--tests/auto/qml/qmllint/data/stringIdUsedInWarning.qml9
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp124
39 files changed, 361 insertions, 21 deletions
diff --git a/tests/auto/qml/qmllint/CMakeLists.txt b/tests/auto/qml/qmllint/CMakeLists.txt
index c69748cc60..15549a93b7 100644
--- a/tests/auto/qml/qmllint/CMakeLists.txt
+++ b/tests/auto/qml/qmllint/CMakeLists.txt
@@ -12,12 +12,10 @@ list(APPEND test_data ${test_data_glob})
qt_internal_add_test(tst_qmllint
SOURCES
- ../../shared/util.cpp ../../shared/util.h
tst_qmllint.cpp
- INCLUDE_DIRECTORIES
- ../../shared
PUBLIC_LIBRARIES
Qt::Gui
+ Qt::QuickTestUtilsPrivate
TESTDATA ${test_data}
)
diff --git a/tests/auto/qml/qmllint/data/Cycle/MenuItem.qml b/tests/auto/qml/qmllint/data/Cycle/MenuItem.qml
new file mode 100644
index 0000000000..b316a5432c
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Cycle/MenuItem.qml
@@ -0,0 +1,3 @@
+import QtQml
+
+MenuItem {}
diff --git a/tests/auto/qml/qmllint/data/Cycle/qmldir b/tests/auto/qml/qmllint/data/Cycle/qmldir
new file mode 100644
index 0000000000..6b0ba5519a
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Cycle/qmldir
@@ -0,0 +1,3 @@
+module Cycle
+
+MenuItem 1.0 MenuItem.qml
diff --git a/tests/auto/qml/qmllint/data/LazyAndDirect/Direct.qml b/tests/auto/qml/qmllint/data/LazyAndDirect/Direct.qml
new file mode 100644
index 0000000000..fcb08c1e80
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/LazyAndDirect/Direct.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ Component.onCompleted: Lazy.setDirect(this)
+}
diff --git a/tests/auto/qml/qmllint/data/LazyAndDirect/Lazy.qml b/tests/auto/qml/qmllint/data/LazyAndDirect/Lazy.qml
new file mode 100644
index 0000000000..1f69d0f16a
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/LazyAndDirect/Lazy.qml
@@ -0,0 +1,8 @@
+pragma Singleton
+import QtQml
+
+QtObject {
+ property Direct direct
+
+ function setDirect(newDirect : Direct) { direct = newDirect }
+}
diff --git a/tests/auto/qml/qmllint/data/LazyAndDirect/qmldir b/tests/auto/qml/qmllint/data/LazyAndDirect/qmldir
new file mode 100644
index 0000000000..ebc7f2a157
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/LazyAndDirect/qmldir
@@ -0,0 +1,4 @@
+module LazyAndDirect
+
+Direct 1.0 Direct.qml
+singleton Lazy 1.0 Lazy.qml
diff --git a/tests/auto/qml/qmllint/data/Qt5Compat/GraphicalEffects/private/qmldir b/tests/auto/qml/qmllint/data/Qt5Compat/GraphicalEffects/private/qmldir
new file mode 100644
index 0000000000..b13cdc9c3e
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Qt5Compat/GraphicalEffects/private/qmldir
@@ -0,0 +1,2 @@
+module Qt5Compat.GraphicalEffects.private
+typeinfo plugins.qmltypes
diff --git a/tests/auto/qml/qmllint/data/Things/LintDirectly.qml b/tests/auto/qml/qmllint/data/Things/LintDirectly.qml
new file mode 100644
index 0000000000..4384fa99f4
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Things/LintDirectly.qml
@@ -0,0 +1,4 @@
+Pane {
+ property var thing: NotPartOfThings {}
+ property var something: Something {}
+}
diff --git a/tests/auto/qml/qmllint/data/Things/NotPartOfThings.qml b/tests/auto/qml/qmllint/data/Things/NotPartOfThings.qml
new file mode 100644
index 0000000000..16fd397d1d
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/Things/NotPartOfThings.qml
@@ -0,0 +1,3 @@
+import QtQuick
+
+Component {}
diff --git a/tests/auto/qml/qmllint/data/accessibleId.qml b/tests/auto/qml/qmllint/data/accessibleId.qml
new file mode 100644
index 0000000000..904b856320
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/accessibleId.qml
@@ -0,0 +1,14 @@
+import QtQml
+
+QtObject {
+ id: a
+ property Component c: Component {
+ QtObject {
+ id: a
+ property QtObject o: QtObject {
+ property int a: 5
+ objectName: a.objectName
+ }
+ }
+ }
+}
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/cachedDependency.qml b/tests/auto/qml/qmllint/data/cachedDependency.qml
new file mode 100644
index 0000000000..5a15a66997
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/cachedDependency.qml
@@ -0,0 +1,23 @@
+import QtQuick.Controls.impl // Caches QtQuick as depedency, without QML names
+import QtQuick
+
+Item {
+ QtObject { id: object }
+ Item { id: item }
+ Rectangle { id: rectangle }
+
+ // Various ways to cast between types contained in QtQuick and QtQml
+ // The QML names of both have to be available for this to work
+
+ property QtObject objectAsObject: object as QtObject
+ property QtObject objectAsItem: object as Item
+ property QtObject objectAsRectangle: object as Rectangle
+
+ property QtObject itemAsObject: item as QtObject
+ property QtObject itemAsItem: item as Item
+ property QtObject itemAsRectangle: item as Rectangle
+
+ property QtObject rectangleAsObject: rectangle as QtObject
+ property QtObject rectangleAsItem: rectangle as Item
+ property QtObject rectangleAsRectangle: rectangle as Rectangle
+}
diff --git a/tests/auto/qml/qmllint/data/connectionNoParent.qml b/tests/auto/qml/qmllint/data/connectionNoParent.qml
new file mode 100644
index 0000000000..27f7e22cf3
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/connectionNoParent.qml
@@ -0,0 +1,5 @@
+import QtQuick
+
+Connections {
+ function onClicked() {}
+}
diff --git a/tests/auto/qml/qmllint/data/cycleHead.qml b/tests/auto/qml/qmllint/data/cycleHead.qml
new file mode 100644
index 0000000000..080eab381f
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/cycleHead.qml
@@ -0,0 +1,7 @@
+import Cycle
+import QtQuick
+
+Item {
+ property MenuItem item: a
+ MenuItem { id: a }
+}
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/data/inaccessibleId.qml b/tests/auto/qml/qmllint/data/inaccessibleId.qml
new file mode 100644
index 0000000000..a3489f4741
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/inaccessibleId.qml
@@ -0,0 +1,12 @@
+import QtQml
+
+QtObject {
+ id: a
+
+ property Component c: Component {
+ QtObject {
+ property int a: 5
+ objectName: a.objectName
+ }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/inaccessibleId2.qml b/tests/auto/qml/qmllint/data/inaccessibleId2.qml
new file mode 100644
index 0000000000..b8f381b0b7
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/inaccessibleId2.qml
@@ -0,0 +1,10 @@
+import QtQml
+
+QtObject {
+ id: a
+
+ component Handle: QtObject {
+ property int a: 5
+ objectName: a.objectName
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/invalidId1.qml b/tests/auto/qml/qmllint/data/invalidId1.qml
new file mode 100644
index 0000000000..61c45530f1
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/invalidId1.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ id: foo.bar
+}
diff --git a/tests/auto/qml/qmllint/data/missingBuiltinsNoCrash.qml b/tests/auto/qml/qmllint/data/missingBuiltinsNoCrash.qml
new file mode 100644
index 0000000000..a2f7d422b3
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/missingBuiltinsNoCrash.qml
@@ -0,0 +1,3 @@
+import QtQuick // This can't be found if --bare is specified and no paths are provided
+
+Item {}
diff --git a/tests/auto/qml/qmllint/data/missingQmltypes.qml b/tests/auto/qml/qmllint/data/missingQmltypes.qml
new file mode 100644
index 0000000000..19a6dbd10b
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/missingQmltypes.qml
@@ -0,0 +1,4 @@
+import QtQml
+import Qt5Compat.GraphicalEffects.private
+
+QtObject {}
diff --git a/tests/auto/qml/qmllint/data/multiGrouped.qml b/tests/auto/qml/qmllint/data/multiGrouped.qml
new file mode 100644
index 0000000000..ab6bd5bd02
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/multiGrouped.qml
@@ -0,0 +1,6 @@
+import QtQuick
+
+Item {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors { right: parent.left }
+}
diff --git a/tests/auto/qml/qmllint/data/onBindingInGroupedProperty.qml b/tests/auto/qml/qmllint/data/onBindingInGroupedProperty.qml
new file mode 100644
index 0000000000..186b8a557f
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/onBindingInGroupedProperty.qml
@@ -0,0 +1,10 @@
+import QtQuick
+
+Rectangle
+{
+ id: root
+ border
+ {
+ ColorAnimation on color { }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/prefixedAttachedProperty.qml b/tests/auto/qml/qmllint/data/prefixedAttachedProperty.qml
new file mode 100644
index 0000000000..1f9634e280
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/prefixedAttachedProperty.qml
@@ -0,0 +1,5 @@
+import QtQuick as T
+
+T.Item {
+ T.Accessible.name: "Example"
+}
diff --git a/tests/auto/qml/qmllint/data/qmodelIndex.qml b/tests/auto/qml/qmllint/data/qmodelIndex.qml
new file mode 100644
index 0000000000..e0df84b68b
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/qmodelIndex.qml
@@ -0,0 +1,6 @@
+import QtQml
+
+QtObject {
+ property ItemSelectionModel itemSelectionModel;
+ function row() { return itemSelectionModel.currentIndex.row; }
+}
diff --git a/tests/auto/qml/qmllint/data/requiredProperty.qml b/tests/auto/qml/qmllint/data/requiredProperty.qml
index 6e0eec54e7..f1e82bb402 100644
--- a/tests/auto/qml/qmllint/data/requiredProperty.qml
+++ b/tests/auto/qml/qmllint/data/requiredProperty.qml
@@ -1,7 +1,9 @@
-import QtQml 2.15
+import QtQuick 2.15
-QtObject {
- property int x
- required x
- x: 5
+Item {
+ component Required : QtObject {
+ property int x
+ required x
+ }
+ Required { x: 5 }
}
diff --git a/tests/auto/qml/qmllint/data/requiredPropertyInComponent.qml b/tests/auto/qml/qmllint/data/requiredPropertyInComponent.qml
new file mode 100644
index 0000000000..24ecf9d706
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/requiredPropertyInComponent.qml
@@ -0,0 +1,25 @@
+import QtQuick 2.0
+
+Row {
+ // explicit component
+ Component {
+ id: foo
+ Item {
+ required property int i
+ }
+ }
+
+ // implicit component, plain property
+ property Component com: Item {}
+
+ Repeater {
+ model: 3
+ // implicit component, default property
+ Text {
+ required property int index
+ height: 40
+ color: "black"
+ text: "I'm item " + index
+ }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/settings/bare/.qmllint.ini b/tests/auto/qml/qmllint/data/settings/bare/.qmllint.ini
new file mode 100644
index 0000000000..e419c37f3a
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/settings/bare/.qmllint.ini
@@ -0,0 +1,2 @@
+[Foo]
+DisableDefaultImports=true
diff --git a/tests/auto/qml/qmllint/data/settings/bare/bare.qml b/tests/auto/qml/qmllint/data/settings/bare/bare.qml
new file mode 100644
index 0000000000..852b8339b9
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/settings/bare/bare.qml
@@ -0,0 +1,3 @@
+import QtQuick // Should fail because Bare is specified with no import
+
+Item {}
diff --git a/tests/auto/qml/qmllint/data/settings/qmltypes/.qmllint.ini b/tests/auto/qml/qmllint/data/settings/qmltypes/.qmllint.ini
new file mode 100644
index 0000000000..95b02f2f37
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/settings/qmltypes/.qmllint.ini
@@ -0,0 +1,2 @@
+[General]
+OverwriteImportTypes=custom.qmltypes
diff --git a/tests/auto/qml/qmllint/data/settings/qmltypes/custom.qmltypes b/tests/auto/qml/qmllint/data/settings/qmltypes/custom.qmltypes
new file mode 100644
index 0000000000..b3839652dc
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/settings/qmltypes/custom.qmltypes
@@ -0,0 +1,11 @@
+import QtQuick.tooling 1.2
+Module {
+ dependencies: []
+ Component {
+ name: "Thing"
+ prototype: "QObject"
+ exports: [
+ "Custom/Thing 1.0",
+ ]
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/settings/qmltypes/qmltypes.qml b/tests/auto/qml/qmllint/data/settings/qmltypes/qmltypes.qml
new file mode 100644
index 0000000000..221ddff254
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/settings/qmltypes/qmltypes.qml
@@ -0,0 +1,3 @@
+import Custom
+
+Thing {}
diff --git a/tests/auto/qml/qmllint/data/stringAsId.qml b/tests/auto/qml/qmllint/data/stringAsId.qml
new file mode 100644
index 0000000000..58ea28cb17
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/stringAsId.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ id: "aString"
+}
diff --git a/tests/auto/qml/qmllint/data/stringIdUsedInWarning.qml b/tests/auto/qml/qmllint/data/stringIdUsedInWarning.qml
new file mode 100644
index 0000000000..672c00f39b
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/stringIdUsedInWarning.qml
@@ -0,0 +1,9 @@
+import QtQml
+
+QtObject {
+ id: "stringy"
+ property int i
+ property QtObject o: QtObject {
+ Component.onCompleted: console.log(i)
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 79225d92de..3cdba23872 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -30,13 +30,15 @@
#include <QtTest/QtTest>
#include <QProcess>
#include <QString>
-
-#include <util.h>
+#include <QtQuickTestUtils/private/qmlutils_p.h>
class TestQmllint: public QQmlDataTest
{
Q_OBJECT
+public:
+ TestQmllint();
+
private Q_SLOTS:
void initTestCase() override;
@@ -68,17 +70,27 @@ private Q_SLOTS:
void settingsFile();
+ void lazyAndDirect();
+
+ void missingBuiltinsNoCrash();
private:
QString runQmllint(const QString &fileToLint, std::function<void(QProcess &)> handleResult,
- const QStringList &extraArgs = QStringList(), bool ignoreSettings = true);
+ const QStringList &extraArgs = QStringList(), bool ignoreSettings = true,
+ bool addIncludeDirs = true);
QString runQmllint(const QString &fileToLint, bool shouldSucceed,
- const QStringList &extraArgs = QStringList(), bool ignoreSettings = true);
+ const QStringList &extraArgs = QStringList(), bool ignoreSettings = true,
+ bool addIncludeDirs = true);
QString m_qmllintPath;
QString m_qmljsrootgenPath;
QString m_qmltyperegistrarPath;
};
+TestQmllint::TestQmllint()
+ : QQmlDataTest(QT_QMLTEST_DATADIR)
+{
+}
+
void TestQmllint::initTestCase()
{
QQmlDataTest::initTestCase();
@@ -180,7 +192,7 @@ void TestQmllint::oldQmltypes()
QVERIFY(errors.contains(QStringLiteral("Warning: Found deprecated dependency specifications")));
// Checking for both lines separately so that we don't have to mess with the line endings.b
- QVERIFY(errors.contains(QStringLiteral("Meta object revision and export version differ, ignoring the revision.")));
+ QVERIFY(errors.contains(QStringLiteral("Meta object revision and export version differ.")));
QVERIFY(errors.contains(QStringLiteral("Revision 0 corresponds to version 0.0; it should be 1.0.")));
}
@@ -405,7 +417,7 @@ void TestQmllint::dirtyQmlCode_data()
<< false;
QTest::newRow("nanchors1")
<< QStringLiteral("nanchors1.qml")
- << QString()
+ << QString("unknown grouped property scope nanchors.")
<< QString()
<< false;
QTest::newRow("nanchors2")
@@ -428,6 +440,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 +487,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 "
@@ -590,6 +620,22 @@ void TestQmllint::dirtyQmlCode_data()
<< QStringLiteral("Method \"deprecatedInherited(c, d)\" is deprecated (Reason: This deprecation should be visible!)")
<< QString()
<< false;
+
+ QTest::newRow("string as id")
+ << QStringLiteral("stringAsId.qml")
+ << QStringLiteral("ids do not need quotation marks")
+ << QString()
+ << false;
+ QTest::newRow("stringIdUsedInWarning")
+ << QStringLiteral("stringIdUsedInWarning.qml")
+ << QStringLiteral("Component.onCompleted: console.log(stringy.i)")
+ << QString()
+ << false;
+ QTest::newRow("Invalid id (expression)")
+ << QStringLiteral("invalidId1.qml")
+ << QStringLiteral("Failed to parse id")
+ << QString()
+ << false;
QTest::newRow("multilineString")
<< QStringLiteral("multilineString.qml")
<< QStringLiteral("String contains unescaped line terminator which is deprecated. Use "
@@ -624,6 +670,27 @@ void TestQmllint::dirtyQmlCode_data()
QTest::newRow("nestedInlineComponents")
<< QStringLiteral("nestedInlineComponents.qml")
<< QStringLiteral("Nested inline components are not supported") << QString() << false;
+ QTest::newRow("cachedDependency")
+ << QStringLiteral("cachedDependency.qml")
+ << QStringLiteral("Unused import at %1:1:1")
+ << QStringLiteral("Cannot assign binding of type QQuickItem to QObject")
+ << true;
+ QTest::newRow("cycle in import")
+ << QStringLiteral("cycleHead.qml")
+ << QStringLiteral("MenuItem is part of an inheritance cycle: MenuItem -> MenuItem")
+ << QString() << false;
+ QTest::newRow("missingQmltypes")
+ << QStringLiteral("missingQmltypes.qml")
+ << QStringLiteral("QML types file does not exist")
+ << QString() << false;
+ QTest::newRow("inaccessibleId")
+ << QStringLiteral("inaccessibleId.qml")
+ << QStringLiteral("Property \"objectName\" not found on type \"int\"")
+ << QString() << false;
+ QTest::newRow("inaccessibleId2")
+ << QStringLiteral("inaccessibleId2.qml")
+ << QStringLiteral("Property \"objectName\" not found on type \"int\"")
+ << QString() << false;
}
void TestQmllint::dirtyQmlCode()
@@ -640,7 +707,6 @@ void TestQmllint::dirtyQmlCode()
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QEXPECT_FAIL("anchors3", "We don't see that QQuickItem cannot be assigned to QQuickAnchorLine", Abort);
- QEXPECT_FAIL("nanchors1", "Invalid grouped properties are not always detected", Abort);
QEXPECT_FAIL("TypePropertAccess", "We cannot discern between types and instances", Abort);
QEXPECT_FAIL("badAttachedPropertyTypeString",
"Script bindings do not perform property type matching", Abort);
@@ -765,6 +831,17 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("CustomParserUnqualifiedAccess")
<< QStringLiteral("customParserUnqualifiedAccess.qml");
QTest::newRow("ImportQMLModule") << QStringLiteral("importQMLModule.qml");
+ QTest::newRow("ImportDirectoryQmldir") << QStringLiteral("Things/LintDirectly.qml");
+ QTest::newRow("BindingsOnGroupAndAttachedProperties")
+ << QStringLiteral("goodBindingsOnGroupAndAttached.qml");
+ QTest::newRow("QQmlEasingEnums::Type") << QStringLiteral("animationEasing.qml");
+ QTest::newRow("required property in Component") << QStringLiteral("requiredPropertyInComponent.qml");
+ QTest::newRow("connectionNoParent") << QStringLiteral("connectionNoParent.qml"); // QTBUG-97600
+ QTest::newRow("on binding in grouped property") << QStringLiteral("onBindingInGroupedProperty.qml");
+ QTest::newRow("multipleGrouped") << QStringLiteral("multiGrouped.qml");
+ QTest::newRow("ID overrides property") << QStringLiteral("accessibleId.qml");
+ QTest::newRow("qmodelIndex") << QStringLiteral("qmodelIndex.qml");
+ QTest::newRow("prefixedAttachedProperty") << QStringLiteral("prefixedAttachedProperty.qml");
}
void TestQmllint::cleanQmlCode()
@@ -776,14 +853,18 @@ void TestQmllint::cleanQmlCode()
QString TestQmllint::runQmllint(const QString &fileToLint,
std::function<void(QProcess &)> handleResult,
- const QStringList &extraArgs, bool ignoreSettings)
+ const QStringList &extraArgs, bool ignoreSettings,
+ bool addIncludeDirs)
{
auto qmlImportDir = QLibraryInfo::path(QLibraryInfo::QmlImportsPath);
QStringList args;
- args << (QFileInfo(fileToLint).isAbsolute() ? fileToLint : testFile(fileToLint))
- << QStringLiteral("-I") << qmlImportDir
- << QStringLiteral("-I") << dataDirectory();
+ args << (QFileInfo(fileToLint).isAbsolute() ? fileToLint : testFile(fileToLint));
+
+ if (addIncludeDirs) {
+ args << QStringLiteral("-I") << qmlImportDir
+ << QStringLiteral("-I") << dataDirectory();
+ }
if (ignoreSettings)
QStringLiteral("--ignore-settings");
@@ -815,7 +896,8 @@ QString TestQmllint::runQmllint(const QString &fileToLint,
}
QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed,
- const QStringList &extraArgs, bool ignoreSettings)
+ const QStringList &extraArgs, bool ignoreSettings,
+ bool addIncludeDirs)
{
return runQmllint(
fileToLint,
@@ -828,7 +910,7 @@ QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed,
else
QVERIFY(process.exitCode() != 0);
},
- extraArgs, ignoreSettings);
+ extraArgs, ignoreSettings, addIncludeDirs);
}
void TestQmllint::requiredProperty()
@@ -869,6 +951,22 @@ void TestQmllint::settingsFile()
QVERIFY(runQmllint("settings/unusedImportWarning/unused.qml", false, QStringList(), false)
.contains(QStringLiteral("Warning: %1:2:1: Unused import at %1:2:1")
.arg(testFile("settings/unusedImportWarning/unused.qml"))));
+ QVERIFY(runQmllint("settings/bare/bare.qml", false, { "--bare" }, false, false)
+ .contains(QStringLiteral("Failed to find the following builtins: "
+ "builtins.qmltypes, jsroot.qmltypes")));
+ QVERIFY(runQmllint("settings/qmltypes/qmltypes.qml", true, QStringList(), false).isEmpty());
+}
+
+void TestQmllint::lazyAndDirect()
+{
+ QVERIFY(runQmllint("LazyAndDirect/Lazy.qml", true, {}, false).isEmpty());
+}
+
+void TestQmllint::missingBuiltinsNoCrash()
+{
+ QVERIFY(runQmllint("missingBuiltinsNoCrash.qml", false, { "--bare" }, false, false)
+ .contains(QStringLiteral("Failed to find the following builtins: "
+ "builtins.qmltypes, jsroot.qmltypes")));
}
QTEST_MAIN(TestQmllint)