aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-15 01:00:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-02-15 10:41:32 +0100
commit1ffb45a3682c864f8071b8b19da49c9a7761dd5e (patch)
treeb714f329d1e2a1ecccc0d5c13fb829f924f0d801 /tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
parent3dcc9dde65c780fb87ff9feef60dfb16d6748eb0 (diff)
parentd96a700cc3611480ff76023287cb06f455a37b02 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: src/qml/qml/qqmlpropertycache.cpp Change-Id: Ie7727499700b85cc0959ef3abb30d55dc728b659
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp')
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index 5abda7b854..07237c9157 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -50,6 +50,7 @@ private slots:
void signalHandlers();
void signalHandlersDerived();
void passForeignEnums();
+ void passQGadget();
void metaObjectSize_data();
void metaObjectSize();
void metaObjectChecksum();
@@ -362,6 +363,44 @@ void tst_qqmlpropertycache::passForeignEnums()
Q_DECLARE_METATYPE(MyEnum::Option1)
Q_DECLARE_METATYPE(MyEnum::ShortEnum)
+QT_BEGIN_NAMESPACE
+class SimpleGadget
+{
+ Q_GADGET
+ Q_PROPERTY(bool someProperty READ someProperty)
+public:
+ bool someProperty() const { return true; }
+};
+
+// Avoids NeedsCreation and NeedsDestruction flags
+Q_DECLARE_TYPEINFO(SimpleGadget, Q_PRIMITIVE_TYPE);
+QT_END_NAMESPACE
+
+class GadgetEmitter : public QObject
+{
+ Q_OBJECT
+signals:
+ void emitGadget(SimpleGadget);
+};
+
+void tst_qqmlpropertycache::passQGadget()
+{
+ qRegisterMetaType<SimpleGadget>();
+
+ GadgetEmitter emitter;
+ engine.rootContext()->setContextProperty("emitter", &emitter);
+ QQmlComponent component(&engine, testFile("passQGadget.qml"));
+ QVERIFY(component.isReady());
+
+ QScopedPointer<QObject> obj(component.create(engine.rootContext()));
+ QVariant before = obj->property("result");
+ QVERIFY(before.isNull());
+ emit emitter.emitGadget(SimpleGadget());
+ QVariant after = obj->property("result");
+ QCOMPARE(QMetaType::Type(after.type()), QMetaType::Bool);
+ QVERIFY(after.toBool());
+}
+
class TestClass : public QObject
{
Q_OBJECT