aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes41
-rw-r--r--tests/auto/qml/qmllint/data/StaticTest/qmldir2
-rw-r--r--tests/auto/qml/qmllint/data/multiExtension.qml6
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp10
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h46
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h62
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp21
8 files changed, 189 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes
new file mode 100644
index 0000000000..9a2ed24482
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes
@@ -0,0 +1,41 @@
+import QtQuick.tooling 1.2
+
+// This file describes the plugin-supplied types contained in the library.
+// It is used for QML tooling purposes only.
+//
+// This file was auto-generated by qmltyperegistrar.
+
+Module {
+ Component {
+ file: "testtypes.h"
+ name: "ExtensionA"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ Property { name: "a"; type: "int"; isReadonly: true; read: "a" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "ExtensionB"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ Property { name: "b"; type: "int"; isReadonly: true; read: "b" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "MultiExtension"
+ accessSemantics: "reference"
+ prototype: "MultiExtensionParent"
+ exports: ["StaticTest/MultiExtension 1.0"]
+ exportMetaObjectRevisions: [256]
+ extension: "ExtensionB"
+ Property { name: "e"; type: "int"; isReadonly: true; read: "e" }
+ }
+ Component {
+ file: "testtypes.h"
+ name: "MultiExtensionParent"
+ accessSemantics: "reference"
+ prototype: "QObject"
+ extension: "ExtensionA"
+ Property { name: "p"; type: "int"; isReadonly: true; read: "p" }
+ }
+}
diff --git a/tests/auto/qml/qmllint/data/StaticTest/qmldir b/tests/auto/qml/qmllint/data/StaticTest/qmldir
new file mode 100644
index 0000000000..4702175b79
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/StaticTest/qmldir
@@ -0,0 +1,2 @@
+module StaticTest
+typeinfo multi.qmltypes
diff --git a/tests/auto/qml/qmllint/data/multiExtension.qml b/tests/auto/qml/qmllint/data/multiExtension.qml
new file mode 100644
index 0000000000..12b36dbb4f
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/multiExtension.qml
@@ -0,0 +1,6 @@
+import StaticTest
+
+MultiExtension {
+ property int t: a + b + e + p
+}
+
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 895953c2f7..b874d3cc6f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -337,6 +337,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("goodAliasObject") << QStringLiteral("goodAliasObject.qml");
QTest::newRow("jsmoduleimport") << QStringLiteral("jsmoduleimport.qml");
QTest::newRow("overridescript") << QStringLiteral("overridescript.qml");
+ QTest::newRow("multiExtension") << QStringLiteral("multiExtension.qml");
}
void TestQmllint::cleanQmlCode()
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index f7a29948a0..b752c4d6c1 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -161,4 +161,14 @@ void tst_qmltyperegistrar::metaTypesRegistered()
verifyMetaType("Ccc*", "Ccc");
}
+void tst_qmltyperegistrar::multiExtensions()
+{
+ QVERIFY(qmltypesData.contains("name: \"MultiExtension\""));
+ QVERIFY(qmltypesData.contains("prototype: \"MultiExtensionParent\""));
+ QVERIFY(qmltypesData.contains("name: \"MultiExtensionParent\""));
+ QVERIFY(qmltypesData.contains("extension: \"ExtensionA\""));
+ QVERIFY(qmltypesData.contains("extension: \"ExtensionB\""));
+ QVERIFY(qmltypesData.contains("interfaces: [\"Interface3\"]"));
+}
+
QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index 6267868375..40569879ec 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -37,10 +37,12 @@
class Interface {};
class Interface2 {};
+class Interface3 {};
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(Interface, "io.qt.bugreports.Interface");
Q_DECLARE_INTERFACE(Interface2, "io.qt.bugreports.Interface2");
+Q_DECLARE_INTERFACE(Interface3, "io.qt.bugreports.Interface3");
QT_END_NAMESPACE
@@ -150,6 +152,49 @@ public:
DerivedFromForeign(QObject *parent) : QTimeLine(1000, parent) {}
};
+class ExtensionA : public QObject
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ Q_PROPERTY(int a READ a CONSTANT)
+public:
+ ExtensionA(QObject *parent = nullptr) : QObject(parent) {}
+ int a() const { return 'a'; }
+};
+
+class ExtensionB : public QObject
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ Q_PROPERTY(int b READ b CONSTANT)
+public:
+ ExtensionB(QObject *parent = nullptr) : QObject(parent) {}
+ int b() const { return 'b'; }
+};
+
+class MultiExtensionParent : public QObject, public Interface3
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ QML_EXTENDED(ExtensionA)
+ QML_IMPLEMENTS_INTERFACES(Interface3)
+ Q_PROPERTY(int p READ p CONSTANT)
+public:
+ MultiExtensionParent(QObject *parent = nullptr) : QObject(parent) {}
+ int p() const { return 'p'; }
+};
+
+class MultiExtension : public MultiExtensionParent
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_EXTENDED(ExtensionB)
+ Q_PROPERTY(int e READ e CONSTANT)
+public:
+ MultiExtension(QObject *parent = nullptr) : MultiExtensionParent(parent) {}
+ int e() const { return 'e'; }
+};
+
class tst_qmltyperegistrar : public QObject
{
Q_OBJECT
@@ -170,6 +215,7 @@ private slots:
void namespacedElement();
void derivedFromForeign();
void metaTypesRegistered();
+ void multiExtensions();
private:
QByteArray qmltypesData;
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 758b9e2f62..77f09a232c 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1638,6 +1638,68 @@ private:
WrapperSingleton() = default;
};
+class ExtensionA : public QObject
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ Q_PROPERTY(int a READ a CONSTANT)
+ Q_PROPERTY(int c READ c CONSTANT)
+ Q_PROPERTY(int d READ d CONSTANT)
+ Q_PROPERTY(int f READ f CONSTANT)
+ Q_PROPERTY(int g READ g CONSTANT)
+public:
+ ExtensionA(QObject *parent = nullptr) : QObject(parent) {}
+ int a() const { return 'a'; }
+ int c() const { return 11; }
+ int d() const { return 21; }
+ int f() const { return 31; }
+ int g() const { return 41; }
+};
+
+class ExtensionB : public QObject
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ Q_PROPERTY(int b READ b CONSTANT)
+ Q_PROPERTY(int c READ c CONSTANT)
+ Q_PROPERTY(int d READ d CONSTANT)
+public:
+ ExtensionB(QObject *parent = nullptr) : QObject(parent) {}
+ int b() const { return 'b'; }
+ int c() const { return 12; }
+ int d() const { return 22; }
+};
+
+class MultiExtensionParent : public QObject
+{
+ Q_OBJECT
+ QML_ANONYMOUS
+ QML_EXTENDED(ExtensionA)
+ Q_PROPERTY(int p READ p CONSTANT)
+ Q_PROPERTY(int c READ c CONSTANT)
+ Q_PROPERTY(int f READ f CONSTANT)
+public:
+ MultiExtensionParent(QObject *parent = nullptr) : QObject(parent) {}
+ int p() const { return 'p'; }
+ int c() const { return 13; }
+ int f() const { return 33; }
+};
+
+class MultiExtension : public MultiExtensionParent
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_EXTENDED(ExtensionB)
+ Q_PROPERTY(int e READ e CONSTANT)
+ Q_PROPERTY(int c READ c CONSTANT)
+ Q_PROPERTY(int g READ g CONSTANT)
+public:
+ MultiExtension(QObject *parent = nullptr) : MultiExtensionParent(parent) {}
+ int e() const { return 'e'; }
+ int c() const { return 14; }
+ int g() const { return 44; }
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 454ae59ad3..5e40387ceb 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -347,6 +347,8 @@ private slots:
void extendedSingleton();
void qtbug_85932();
+ void multiExtension();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -6128,6 +6130,25 @@ void tst_qqmllanguage::qtbug_85932()
QCOMPARE(allWarnings.at(1).toString(), warning2);
}
+void tst_qqmllanguage::multiExtension()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import StaticTest\nMultiExtension {}", QUrl());
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QCOMPARE(o->property("a").toInt(), int('a'));
+ QCOMPARE(o->property("b").toInt(), int('b'));
+ QCOMPARE(o->property("p").toInt(), int('p'));
+ QCOMPARE(o->property("e").toInt(), int('e'));
+
+ // Extension properties override base object properties
+ QCOMPARE(o->property("c").toInt(), 12);
+ QCOMPARE(o->property("d").toInt(), 22);
+ QCOMPARE(o->property("f").toInt(), 31);
+ QCOMPARE(o->property("g").toInt(), 44);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"