aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp')
-rw-r--r--tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp126
1 files changed, 125 insertions, 1 deletions
diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
index 7f12f29342..31c27c3cd7 100644
--- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
+++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/qtest.h>
@@ -51,6 +51,14 @@ private slots:
void topLevelComponent();
void dashesInFilename();
void invalidSignalHandlers();
+ void exports();
+ void qmlBaseFromAnotherModule();
+ void invalidTypeAnnotation();
+ void constructFromString();
+ void unboundRequiredPropertyInInlineComponent();
+ void componentDefinitionInnerRequiredProperty();
+ void componentDefinitionInnerRequiredPropertyFromOutside();
+ void innerLevelRequiredProperty();
};
#ifndef TST_QMLTC_QPROCESS_RESOURCES
@@ -92,6 +100,7 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile,
args << u"--resource"_s << resource;
args << u"--header"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".h"_s);
args << u"--impl"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".cpp"_s);
+ args << u"--module"_s << u"QmltcQProcessTestModule"_s;
args << extraArgs;
QString errors;
@@ -261,5 +270,120 @@ void tst_qmltc_qprocess::invalidSignalHandlers()
}
}
+void tst_qmltc_qprocess::qmlBaseFromAnotherModule()
+{
+ {
+ const auto errors = runQmltc(u"QmlBaseFromAnotherModule.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"QmlBaseFromAnotherModule.qml:6:1: Can't compile the QML property type \"ScrollBar\" to C++ because it lives in \"QtQuick.Controls.Basic\" instead of the current file's \"QmltcQProcessTestModule\" QML module."_s));
+ QVERIFY(errors.contains(
+ u"QmlBaseFromAnotherModule.qml:6:1: Can't compile the QML method return type \"ScrollBar\" to C++ because it lives in \"QtQuick.Controls.Basic\" instead of the current file's \"QmltcQProcessTestModule\" QML module."_s));
+ QVERIFY(errors.contains(
+ u"QmlBaseFromAnotherModule.qml:6:1: Can't compile the QML parameter type \"ScrollBar\" to C++ because it lives in \"QtQuick.Controls.Basic\" instead of the current file's \"QmltcQProcessTestModule\" QML module."_s));
+ // it should not complain about the usages of Item, a C++ defined QML element from another
+ // module
+ QVERIFY(!errors.contains(u"\"Item\""_s));
+ }
+}
+
+void tst_qmltc_qprocess::invalidTypeAnnotation()
+{
+ {
+ const auto errors = runQmltc(u"invalidTypeAnnotation.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"invalidTypeAnnotation.qml:5:17: \"Qt.point\" was not found for the return type of method \"f\"."_s));
+ QVERIFY(errors.contains(
+ u"invalidTypeAnnotation.qml:19:21: \"Qt.point\" was not found for the type of parameter \"a\" in method \"gamma\"."_s));
+ QVERIFY(!errors.contains(u"\"var\""_s));
+ QVERIFY(!errors.contains(u"\"void\""_s));
+ }
+}
+
+static QString fileToString(const QString &path)
+{
+ QFile f(path);
+ if (f.open(QIODevice::ReadOnly))
+ return QString::fromLatin1(f.readAll());
+ return QString();
+}
+
+void tst_qmltc_qprocess::exports()
+{
+ const QString fileName = u"dummy.qml"_s;
+ QStringList extraArgs;
+ extraArgs << "--export"
+ << "MYLIB_EXPORT_MACRO"
+ << "--exportInclude"
+ << "exportheader.h";
+ const auto errors = runQmltc(fileName, true, extraArgs);
+
+ const QString headerName = m_tmpPath + u"/"_s + QFileInfo(fileName).baseName() + u".h"_s;
+ const QString header = fileToString(headerName);
+ const QString implementationName =
+ m_tmpPath + u"/"_s + QFileInfo(fileName).baseName() + u".cpp"_s;
+ const QString implementation = fileToString(implementationName);
+
+ QCOMPARE(errors.size(), 0);
+
+ QVERIFY(header.contains(u"class MYLIB_EXPORT_MACRO dummy : public QObject\n"_s));
+ QVERIFY(!implementation.contains(u"MYLIB_EXPORT_MACRO"_s));
+
+ QVERIFY(header.contains(u"#include \"exportheader.h\"\n"_s));
+ QVERIFY(!implementation.contains(u"exportheader.h"_s));
+}
+
+void tst_qmltc_qprocess::constructFromString()
+{
+ const auto errors = runQmltc(u"constructFromString.qml"_s, false);
+ const QString warningMessage =
+ u"constructFromString.qml:%1:%2: Binding is not supported: Type %3 should be"
+ u" constructed using QML_STRUCTURED_VALUE's construction mechanism, instead of a"
+ u" string."_s;
+ QVERIFY(errors.contains(warningMessage.arg(4).arg(23).arg(u"QPointF")));
+ QVERIFY(errors.contains(warningMessage.arg(5).arg(23).arg(u"QRectF")));
+ QVERIFY(errors.contains(warningMessage.arg(6).arg(23).arg(u"QSizeF")));
+}
+
+void tst_qmltc_qprocess::unboundRequiredPropertyInInlineComponent()
+{
+ {
+ const auto errors = runQmltc(u"unboundRequiredPropertyInInlineComponent.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"unboundRequiredPropertyInInlineComponent.qml:9:5: Component is missing required property foo from InlineComponent [required]"_s
+ ));
+ }
+}
+
+void tst_qmltc_qprocess::componentDefinitionInnerRequiredProperty()
+{
+ {
+ const auto errors = runQmltc(u"componentDefinitionInnerRequiredProperty.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"componentDefinitionInnerRequiredProperty.qml:11:13: Component is missing required property bar from here [required]"
+ ));
+ }
+}
+
+void tst_qmltc_qprocess::componentDefinitionInnerRequiredPropertyFromOutside()
+{
+ {
+ const auto errors =
+ runQmltc(u"componentDefinitionInnerRequiredPropertyFromOutside.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"componentDefinitionInnerRequiredPropertyFromOutside.qml:15:13: Component is missing required property requiredProperty from TypeWithRequiredProperty [required]"
+ ));
+ }
+}
+
+void tst_qmltc_qprocess::innerLevelRequiredProperty()
+{
+ {
+ const auto errors = runQmltc(u"innerLevelRequiredProperty.qml"_s, false);
+ QVERIFY(errors.contains(
+ u"innerLevelRequiredProperty.qml:7:5: Component is missing required property foo from here [required]"
+ ));
+ }
+}
+
QTEST_MAIN(tst_qmltc_qprocess)
#include "tst_qmltc_qprocess.moc"