aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-08-05 16:17:07 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-09-01 22:12:32 +0200
commitd9add5c2d477792669fcff380a6c41ec72c7a050 (patch)
treeaac22cb0c045ebe04ed44d542817422dd269df6c /tests/auto/qml/qmltc
parent2879c7c3411955b1d4f795436f803abd960c176d (diff)
qmltc: test support for generalized group properties
Test support for generalized group properties in qmltc. Also, force group property bindings to be deferred when they belong to a generalized grouped property, while "not-generalized" grouped properties never are deferred. Fixes: QTBUG-105378 Change-Id: Iadc64d7033f9446ccf53e305d8831c7d348f257c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltc')
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt1
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp11
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h24
-rw-r--r--tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml22
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.cpp49
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.h1
6 files changed, 107 insertions, 1 deletions
diff --git a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
index 9785ffa0c6..15f0fff346 100644
--- a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
+++ b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt
@@ -99,6 +99,7 @@ set(qml_sources
valueTypeListProperty.qml
translations.qml
translationsById.qml
+ generalizedGroupedProperty.qml
# support types:
DefaultPropertySingleChild.qml
diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp
index eb18c87fae..410aae1528 100644
--- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp
+++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.cpp
@@ -63,8 +63,17 @@ void TestTypeGrouped::setStr(const QString &s)
}
QmlGroupPropertyTestType::QmlGroupPropertyTestType(QObject *parent) : QObject(parent) { }
-
TestTypeGrouped *QmlGroupPropertyTestType::getGroup()
{
return &m_group;
}
+
+QmlGeneralizedGroupPropertyTestType::QmlGeneralizedGroupPropertyTestType(QObject *parent)
+ : QObject(parent)
+{
+}
+
+TestTypeGrouped *QmlGeneralizedGroupPropertyTestType::getGroup()
+{
+ return &m_group;
+}
diff --git a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h
index 996585870b..f895f19531 100644
--- a/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h
+++ b/tests/auto/qml/qmltc/QmltcTests/cpptypes/testgroupedtype.h
@@ -61,4 +61,28 @@ public:
TestTypeGrouped *getGroup();
};
+class QmlGeneralizedGroupPropertyTestType : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_CLASSINFO("ImmediatePropertyNames", "myInt,group")
+
+ Q_PROPERTY(TestTypeGrouped *group READ getGroup)
+
+ TestTypeGrouped m_group;
+
+public:
+ QmlGeneralizedGroupPropertyTestType(QObject *parent = nullptr);
+
+ TestTypeGrouped *getGroup();
+};
+
+class MyImmediateQtObject : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_CLASSINFO("ImmediatePropertyNames", "myInt");
+};
+
#endif // TESTGROUPEDTYPE_H
diff --git a/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml b/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml
new file mode 100644
index 0000000000..a037776a52
--- /dev/null
+++ b/tests/auto/qml/qmltc/QmltcTests/generalizedGroupedProperty.qml
@@ -0,0 +1,22 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import QtQml
+import QtQuick
+import QmltcTests
+
+QmlGeneralizedGroupPropertyTestType {
+ id: root
+
+ property int myInt: 5
+
+ group.count: myInt
+ group.formula: 3 + 5
+ group.str: "Hello World!"
+ group.object: MyImmediateQtObject {
+ property int myInt: 42
+ root.group.count: myInt
+ root.group.formula: 3 - 5
+ root.group.str: "Goodbye World!"
+ }
+}
diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp
index c0bfb0436d..3150f4e2eb 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.cpp
+++ b/tests/auto/qml/qmltc/tst_qmltc.cpp
@@ -74,6 +74,7 @@
#include "translations.h"
#include "translationsbyid.h"
#include "defaultalias.h"
+#include "generalizedgroupedproperty.h"
#include "testprivateproperty.h"
@@ -2516,4 +2517,52 @@ void tst_qmltc::translations()
}
}
+void tst_qmltc::generalizedGroupedProperty()
+{
+ QQmlEngine e;
+ {
+ PREPEND_NAMESPACE(generalizedGroupedProperty) fromQmltc(&e);
+
+ QCOMPARE(fromQmltc.getGroup()->getCount(), 5);
+ fromQmltc.setMyInt(42);
+ QCOMPARE(fromQmltc.getGroup()->getCount(), 42);
+ fromQmltc.getGroup()->setCount(55);
+ QCOMPARE(fromQmltc.getGroup()->getCount(), 55);
+ QCOMPARE(fromQmltc.myInt(), 42);
+
+ QCOMPARE(fromQmltc.getGroup()->getFormula(), 8);
+ QCOMPARE(fromQmltc.getGroup()->getStr(), "Hello World!");
+
+ qmlExecuteDeferred(&fromQmltc);
+
+ QCOMPARE(fromQmltc.getGroup()->getCount(), 55);
+ QCOMPARE(fromQmltc.getGroup()->getFormula(), 8);
+ QCOMPARE(fromQmltc.getGroup()->getStr(), "Hello World!");
+ }
+ {
+ QQmlComponent component(&e, "qrc:/qt/qml/QmltcTests/generalizedGroupedProperty.qml");
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> fromEngine(component.create());
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("count"), 5);
+ fromEngine->setProperty("myInt", 43);
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("count"), 43);
+ fromEngine->property("group").value<QObject *>()->setProperty("count", 56);
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("count"), 56);
+ QCOMPARE(fromEngine->property("myInt").value<int>(), 43);
+
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("formula").value<int>(),
+ 8);
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("str").toString(),
+ "Hello World!");
+
+ qmlExecuteDeferred(fromEngine.data());
+
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("count"), 56);
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("formula").value<int>(),
+ 8);
+ QCOMPARE(fromEngine->property("group").value<QObject *>()->property("str").toString(),
+ "Hello World!");
+ }
+}
+
QTEST_MAIN(tst_qmltc)
diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h
index 0f862170c4..4d08e7b34b 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.h
+++ b/tests/auto/qml/qmltc/tst_qmltc.h
@@ -85,4 +85,5 @@ private slots:
void trickyPropertyChangeAndSignalHandlers();
void valueTypeListProperty();
void translations();
+ void generalizedGroupedProperty();
};