aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltyperegistrar
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-04-14 12:56:39 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-04-16 13:52:11 +0200
commitf590202cb085e1463e61bd8b645e6f2cdb7d3fe8 (patch)
treeb8885c44364a66d8b2098afe68f623c861e33a17 /tests/auto/qml/qmltyperegistrar
parentac179e235ba0c01fff6dd5f4ad2cc9696fe78822 (diff)
qmltyperegistrar: Correctly handle foreign and super classes
Previously, if there were multiple super classes, revisions were only collected for the first one. Also, properties and enums declared in the type itself were ignored when QML.Foreign was specified. Finally, we would previously re-set resolvedClass and re-sort the revisions on each super and attached type. Change-Id: Iccb939cae66a5c4e2e5c312359e389463df80b4e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltyperegistrar')
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.h7
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp10
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h30
3 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.h b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
index d5e5a060b4..dc9fbc84a8 100644
--- a/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.h
@@ -30,6 +30,7 @@
#define FOREIGN_H
#include <QtCore/qobject.h>
+#include <QtCore/qsize.h>
class Foreign : public QObject
{
@@ -49,4 +50,10 @@ private:
int m_things = 0;
};
+class SizeGadget : public QSize
+{
+ Q_GADGET
+ Q_PROPERTY(int height READ height WRITE setHeight FINAL)
+};
+
#endif // FOREIGN_H
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
index b3304963d8..1cfcd689c6 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp
@@ -65,4 +65,14 @@ void tst_qmltyperegistrar::qmltypesHasFlags()
QVERIFY(qmltypesData.contains("isFlag: true"));
}
+void tst_qmltyperegistrar::superAndForeignTypes()
+{
+ QVERIFY(qmltypesData.contains("values: [\"Pixel\", \"Centimeter\", \"Inch\", \"Point\"]"));
+ QVERIFY(qmltypesData.contains("name: \"SizeGadget\""));
+ QVERIFY(qmltypesData.contains("prototype: \"SizeEnums\""));
+ QVERIFY(qmltypesData.contains("Property { name: \"height\"; type: \"int\" }"));
+ QVERIFY(qmltypesData.contains("Property { name: \"width\"; type: \"int\" }"));
+ QVERIFY(qmltypesData.contains("Method { name: \"sizeToString\"; type: \"string\" }"));
+}
+
QTEST_MAIN(tst_qmltyperegistrar)
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
index 07a28e1976..09485ab0b6 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h
@@ -33,6 +33,35 @@
#include <QtQml/qqml.h>
+class SizeEnums
+{
+ Q_GADGET
+ QML_NAMED_ELEMENT(SizeEnums)
+ QML_UNCREATABLE("Element is not creatable.")
+
+public:
+ enum Unit { Pixel, Centimeter, Inch, Point };
+ Q_ENUM(Unit)
+};
+
+class SizeValueType : public SizeEnums
+{
+ QSize v;
+ Q_GADGET
+ Q_PROPERTY(int width READ width WRITE setWidth FINAL)
+ QML_NAMED_ELEMENT(MySize)
+ QML_FOREIGN(SizeGadget)
+
+public:
+ Q_INVOKABLE QString sizeToString() const
+ {
+ return QString::fromLatin1("%1x%2").arg(v.width()).arg(v.height());
+ }
+
+ int width() const { return v.width(); }
+ void setWidth(int width) { v.setWidth(width); }
+};
+
class Local : public Foreign
{
Q_OBJECT
@@ -58,6 +87,7 @@ private slots:
void qmltypesHasHppClassAndNoext();
void qmltypesHasFileNames();
void qmltypesHasFlags();
+ void superAndForeignTypes();
private:
QByteArray qmltypesData;