diff options
Diffstat (limited to 'tests/auto/qml/qmltc_qprocess')
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt index 04d2084d4f..d936e2c757 100644 --- a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt +++ b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt @@ -20,6 +20,8 @@ qt6_add_qml_module(tst_qmltc_qprocess AUTO_RESOURCE_PREFIX SOURCES cpptypes/testtype.h + DEPENDENCIES + QtQuick/auto QML_FILES data/dummy.qml data/inlineComponentInvalidAlias.qml @@ -30,6 +32,7 @@ qt6_add_qml_module(tst_qmltc_qprocess data/inlineComponentWithEnum.qml data/singletonUncreatable.qml data/uncreatable.qml + data/invalidSignalHandlers.qml ) set(common_libraries diff --git a/tests/auto/qml/qmltc_qprocess/cpptypes/testtype.h b/tests/auto/qml/qmltc_qprocess/cpptypes/testtype.h index 6082870c76..2130004def 100644 --- a/tests/auto/qml/qmltc_qprocess/cpptypes/testtype.h +++ b/tests/auto/qml/qmltc_qprocess/cpptypes/testtype.h @@ -7,6 +7,7 @@ #include <QtQmlIntegration/qqmlintegration.h> #include <QtCore/qobject.h> #include <QtQml/qqmlregistration.h> +#include <QtGui/qfont.h> class TypeWithVersionedAlias : public QObject { @@ -67,6 +68,19 @@ class NormalType : public QObject } }; +class TypeWithSignals : public QObject +{ + Q_OBJECT + QML_ELEMENT +public: +Q_SIGNALS: + void signalWithConstPointerToGadget(const QFont *); // not allowed + void signalWithConstPointerToGadgetConst(const QFont *const); // not allowed + void signalWithPointerToGadgetConst(QFont *const); // not allowed + void signalWithPointerToGadget(QFont *); // not allowed + void signalWithPrimitivePointer(int *); + void signalWithConstPrimitivePointer(const int *); +}; #endif // TESTTYPE_H diff --git a/tests/auto/qml/qmltc_qprocess/data/invalidSignalHandlers.qml b/tests/auto/qml/qmltc_qprocess/data/invalidSignalHandlers.qml new file mode 100644 index 0000000000..a2a100ab3b --- /dev/null +++ b/tests/auto/qml/qmltc_qprocess/data/invalidSignalHandlers.qml @@ -0,0 +1,10 @@ + +TypeWithSignals +{ + onSignalWithConstPointerToGadget: (x) => { console.log(x); } + onSignalWithConstPointerToGadgetConst: (x) => { console.log(x); } + onSignalWithPointerToGadgetConst: (x) => { console.log(x); } + onSignalWithPointerToGadget: (x) => { console.log(x); } + onSignalWithPrimitivePointer: (x) => { console.log(x); } + onSignalWithConstPrimitivePointer: (x) => { console.log(x); } +} diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp index 04b3426298..1cea44206f 100644 --- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp +++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp @@ -50,6 +50,7 @@ private slots: void invalidAliasRevision(); void topLevelComponent(); void dashesInFilename(); + void invalidSignalHandlers(); }; #ifndef TST_QMLTC_QPROCESS_RESOURCES @@ -241,5 +242,24 @@ void tst_qmltc_qprocess::dashesInFilename() } } +void tst_qmltc_qprocess::invalidSignalHandlers() +{ + { + const auto errors = runQmltc(u"invalidSignalHandlers.qml"_s, false); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:4:5: Type QFont of parameter in signal called signalWithConstPointerToGadget should be passed by value or const reference to be able to compile onSignalWithConstPointerToGadget. [signal-handler-parameters]"_s)); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:5:5: Type QFont of parameter in signal called signalWithConstPointerToGadgetConst should be passed by value or const reference to be able to compile onSignalWithConstPointerToGadgetConst. [signal-handler-parameters]"_s)); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:6:5: Type QFont of parameter in signal called signalWithPointerToGadgetConst should be passed by value or const reference to be able to compile onSignalWithPointerToGadgetConst. [signal-handler-parameters]"_s)); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:7:5: Type QFont of parameter in signal called signalWithPointerToGadget should be passed by value or const reference to be able to compile onSignalWithPointerToGadget. [signal-handler-parameters]"_s)); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:8:5: Type int of parameter in signal called signalWithPrimitivePointer should be passed by value or const reference to be able to compile onSignalWithPrimitivePointer. [signal-handler-parameters]"_s)); + QVERIFY(errors.contains( + u"invalidSignalHandlers.qml:9:5: Type int of parameter in signal called signalWithConstPrimitivePointer should be passed by value or const reference to be able to compile onSignalWithConstPrimitivePointer. [signal-handler-parameters]"_s)); + } +} + QTEST_MAIN(tst_qmltc_qprocess) #include "tst_qmltc_qprocess.moc" |