aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-04-11 10:03:38 +0200
committerUlf Hermann <ulf.hermann@qt.io>2024-04-25 18:55:23 +0200
commit2bc9c4760898737bcd95a7c679ebee9620d04c45 (patch)
tree36124ecd366f68615905d2b97808a88fb91b2938 /tests/auto/qml
parente5d0441409491d84d8153c8650408ee1098e32ad (diff)
qmltyperegistrar: Check properties, methods, enums for missing types
If you have a property of an unknown type, that will create problems later on. The same holds for method arguments, return types and underlying types of enums. qmltyperegistrar now warns about those. When scanning the types, we consider a type potentially primitive if it is not the root type, but one of: a, a self-extending value type b, a type with a JavaScript extension c, a sequence type If those types are found to be "missing" later, we ignore them. All other missing types trigger warnings now. Since we use types from QPA headers in a few places, we now need to recognize QPA headers when looking for private Qt includes. Task-number: QTBUG-101143 Change-Id: Ic4350e8ed46212c0f4af6f10e86323514f710e1e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/birthdayparty.h1
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/CMakeLists.txt3
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/private/foreign_p.h (renamed from tests/auto/qml/qmltyperegistrar/foreign/foreign_p.h)1
-rw-r--r--tests/auto/qml/qmltyperegistrar/missingTypes.json59
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp17
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h2
6 files changed, 62 insertions, 21 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
index 2b6cc09c19..8dd640c67f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
+++ b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
@@ -52,7 +52,6 @@ private:
};
struct Foozle {
- Q_GADGET
int foo = 1;
};
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/CMakeLists.txt b/tests/auto/qml/qmltyperegistrar/foreign/CMakeLists.txt
index 5334225692..68223ae6a5 100644
--- a/tests/auto/qml/qmltyperegistrar/foreign/CMakeLists.txt
+++ b/tests/auto/qml/qmltyperegistrar/foreign/CMakeLists.txt
@@ -10,7 +10,8 @@
qt_internal_add_cmake_library(foreign
STATIC
SOURCES
- foreign.cpp foreign.h foreign_p.h
+ foreign.cpp foreign.h
+ private/foreign_p.h
PUBLIC_LIBRARIES
Qt::Core
)
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign_p.h b/tests/auto/qml/qmltyperegistrar/foreign/private/foreign_p.h
index 6245dad796..ed23d78284 100644
--- a/tests/auto/qml/qmltyperegistrar/foreign/foreign_p.h
+++ b/tests/auto/qml/qmltyperegistrar/foreign/private/foreign_p.h
@@ -7,7 +7,6 @@
#include <QtCore/qobject.h>
// qmltyperegistrar will assume this file is reachable under <private/foreign_p.h>
-// It's not true, but this is how it works on actual private headers in Qt.
// See the trick in tst_qmltyperegistrar's CMakeLists.txt to turn on the --private-includes option.
class ForeignPrivate : public QObject
{
diff --git a/tests/auto/qml/qmltyperegistrar/missingTypes.json b/tests/auto/qml/qmltyperegistrar/missingTypes.json
index 3b57ae3c55..dacec11c4c 100644
--- a/tests/auto/qml/qmltyperegistrar/missingTypes.json
+++ b/tests/auto/qml/qmltyperegistrar/missingTypes.json
@@ -5,6 +5,25 @@
"classInfos": [
{
"name": "QML.Element",
+ "value": "int"
+ },
+ {
+ "name": "QML.Extended",
+ "value": "QQmlIntForeign"
+ },
+ {
+ "name": "QML.Foreign",
+ "value": "int"
+ }
+ ],
+ "className": "QQmlIntForeign",
+ "gadget": true,
+ "qualifiedClassName": "QQmlIntForeign"
+ },
+ {
+ "classInfos": [
+ {
+ "name": "QML.Element",
"value": "auto"
}
],
@@ -28,6 +47,20 @@
"write": "setPalette"
}
],
+ "enums": [
+ {
+ "isClass": false,
+ "isFlag": false,
+ "name": "RestorationMode",
+ "type": "NotAnUnderlyingType",
+ "values": [
+ "RestoreNone",
+ "RestoreBinding",
+ "RestoreValue",
+ "RestoreBindingOrValue"
+ ]
+ }
+ ],
"qualifiedClassName": "ExcessiveVersion",
"signals": [
{
@@ -69,22 +102,20 @@
"revision": 260,
"scriptable": true,
"stored": true,
- "type": "int",
+ "type": "NotAPropertyType",
"user": false
- },
+ }
+ ],
+ "methods": [
{
- "constant": true,
- "designable": true,
- "final": false,
- "index": 1,
- "name": "insane",
- "read": "revisioned",
- "required": false,
- "revision": 65297,
- "scriptable": true,
- "stored": true,
- "type": "int",
- "user": false
+ "access": "public",
+ "arguments": [
+ {
+ "type": "NotAnArgumentType"
+ }
+ ],
+ "name": "createAThing",
+ "returnType": "NotAReturnType"
}
],
"qualifiedClassName": "AddedInLateVersion",
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index 563c88f850..a6377935be 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -441,11 +441,22 @@ void tst_qmltyperegistrar::consistencyWarnings()
QTest::ignoreMessage(QtWarningMsg, message);
};
- expectWarning("Warning: tst_qmltyperegistrar.h:: NotQObject is used but cannot be found.");
- expectWarning("Warning: tst_qmltyperegistrar.h:: NotQObject is used but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: "
+ "NotQObject is used as base type but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotQObject is used as base type "
+ "but cannot be found.");
expectWarning("Warning: tst_qmltyperegistrar.h:: Invisible is declared as foreign type, "
"but cannot be found.");
- expectWarning("Warning: tst_qmltyperegistrar.h:: NotQByteArray is used but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotQByteArray is used as sequence value type "
+ "but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotAPropertyType is used as property type "
+ "but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotAnArgumentType is used as argument type "
+ "but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotAReturnType is used as return type "
+ "but cannot be found.");
+ expectWarning("Warning: tst_qmltyperegistrar.h:: NotAnUnderlyingType is used as enum type "
+ "but cannot be found.");
processor.postProcessForeignTypes();
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index 5ebb9b6796..371fb840d1 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -5,7 +5,7 @@
#define TST_QMLTYPEREGISTRAR_H
#include "foreign.h"
-#include "foreign_p.h"
+#include "private/foreign_p.h"
#include <QtQmlTypeRegistrar/private/qqmltyperegistrar_p.h>