aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-04-14 11:07:19 +0200
committerAndrei Golubev <andrei.golubev@qt.io>2022-05-09 11:55:05 +0000
commitd1a28bd3731e188f5ce3c3f7d41d141d5ad0c17d (patch)
tree6121250216e4797bf4331117f63063005fa43557 /tests/auto/qml
parent324fd7d58f88e814abf347eb43d5ed628318f9b7 (diff)
qmltc: Support setting Gradient property of Rectangle
Fixes: QTBUG-102560 Change-Id: I7c339d2807a723f38e18e06b944362449d89ad7a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit e98faf1df401268dc6966b39963547a4de6f9171) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qmltc/data/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp13
-rw-r--r--tests/auto/qml/qmltc/data/cpptypes/typewithproperties.h10
-rw-r--r--tests/auto/qml/qmltc/data/gradients.qml11
-rw-r--r--tests/auto/qml/qmltc/data/qjsvalueAssignments.qml6
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.cpp36
-rw-r--r--tests/auto/qml/qmltc/tst_qmltc.h2
7 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltc/data/CMakeLists.txt b/tests/auto/qml/qmltc/data/CMakeLists.txt
index 1ba3ee8ac1..73da55d30a 100644
--- a/tests/auto/qml/qmltc/data/CMakeLists.txt
+++ b/tests/auto/qml/qmltc/data/CMakeLists.txt
@@ -24,6 +24,8 @@ set(qml_sources
importNamespace.qml
ComponentType.qml
componentTypes.qml
+ gradients.qml
+ qjsvalueAssignments.qml
signalHandlers.qml
javaScriptFunctions.qml
diff --git a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp
index fe4fc41020..d0ea6c4c9f 100644
--- a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp
+++ b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp
@@ -45,6 +45,11 @@ int TypeWithProperties::d() const
return m_d;
}
+QJSValue TypeWithProperties::jsvalue() const
+{
+ return m_jsvalue;
+}
+
void TypeWithProperties::setA(double a_)
{
m_a = a_;
@@ -70,6 +75,10 @@ void TypeWithProperties::setD(int d_)
Q_EMIT dSignal(u"d changed"_qs, d_);
}
}
+void TypeWithProperties::setJsValue(const QJSValue &value)
+{
+ m_jsvalue = value;
+}
QBindable<double> TypeWithProperties::bindableA()
{
@@ -79,3 +88,7 @@ QBindable<int> TypeWithProperties::bindableD()
{
return QBindable<int>(&m_d);
}
+QBindable<QJSValue> TypeWithProperties::bindableJsValue()
+{
+ return QBindable<QJSValue>(&m_jsvalue);
+} \ No newline at end of file
diff --git a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.h b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.h
index 64625103f4..689f667643 100644
--- a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.h
+++ b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.h
@@ -34,6 +34,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
#include <QtQml/qqmlregistration.h>
+#include <QtQml/qjsvalue.h>
class TypeWithProperties : public QObject
{
@@ -45,10 +46,14 @@ class TypeWithProperties : public QObject
Q_PROPERTY(QVariant c READ c WRITE setC NOTIFY cWeirdSignal)
Q_PROPERTY(int d READ d WRITE setD NOTIFY dSignal BINDABLE bindableD)
+ // special
+ Q_PROPERTY(QJSValue jsvalue READ jsvalue WRITE setJsValue BINDABLE bindableJsValue)
+
QProperty<double> m_a { 0.0 };
QString m_b;
QProperty<QVariant> m_c;
QProperty<int> m_d;
+ QProperty<QJSValue> m_jsvalue;
public:
TypeWithProperties(QObject *parent = nullptr) : QObject(parent) { }
@@ -58,13 +63,18 @@ public:
QVariant c() const;
int d() const;
+ QJSValue jsvalue() const;
+
void setA(double);
void setB(const QString &);
void setC(const QVariant &);
void setD(int);
+ void setJsValue(const QJSValue &);
+
QBindable<double> bindableA();
QBindable<int> bindableD();
+ QBindable<QJSValue> bindableJsValue();
Q_SIGNALS:
void bChanged();
diff --git a/tests/auto/qml/qmltc/data/gradients.qml b/tests/auto/qml/qmltc/data/gradients.qml
new file mode 100644
index 0000000000..008b0431da
--- /dev/null
+++ b/tests/auto/qml/qmltc/data/gradients.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.12
+
+Item
+{
+ Rectangle{
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "black" }
+ GradientStop { position: 1.0; color: "yellow" }
+ }
+ }
+}
diff --git a/tests/auto/qml/qmltc/data/qjsvalueAssignments.qml b/tests/auto/qml/qmltc/data/qjsvalueAssignments.qml
new file mode 100644
index 0000000000..5ac909e1eb
--- /dev/null
+++ b/tests/auto/qml/qmltc/data/qjsvalueAssignments.qml
@@ -0,0 +1,6 @@
+import QtQuick
+import QmltcTests 1.0
+
+TypeWithProperties {
+ jsvalue: true
+}
diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp
index 74e1ebeea7..47b802a21b 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.cpp
+++ b/tests/auto/qml/qmltc/tst_qmltc.cpp
@@ -44,6 +44,8 @@
#include "deferredproperties_group.h"
#include "deferredproperties_attached.h"
#include "deferredproperties_complex.h"
+#include "gradients.h"
+#include "qjsvalueassignments.h"
#include "signalhandlers.h"
#include "javascriptfunctions.h"
@@ -656,6 +658,40 @@ void tst_qmltc::deferredProperties()
}
}
+// QTBUG-102560
+void tst_qmltc::gradients()
+{
+ QQmlEngine e;
+ PREPEND_NAMESPACE(gradients) created(&e);
+ QQmlListReference children(&created, "data");
+ QCOMPARE(children.size(), 1);
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle *>(children.at(0));
+ QVERIFY(rect);
+ QVERIFY(rect->gradient().isQObject());
+
+ QQuickGradient *gradient = qobject_cast<QQuickGradient *>(rect->gradient().toQObject());
+ QVERIFY(gradient);
+ QQmlListProperty<QQuickGradientStop> stops = gradient->stops();
+ QCOMPARE(stops.count(&stops), 2);
+ QQuickGradientStop *stop0 = stops.at(&stops, 0);
+ QVERIFY(stop0);
+ QQuickGradientStop *stop1 = stops.at(&stops, 1);
+ QVERIFY(stop1);
+
+ QCOMPARE(stop0->position(), 0.0);
+ QCOMPARE(stop1->position(), 1.0);
+ QCOMPARE(stop0->color(), QColor("black"));
+ QCOMPARE(stop1->color(), QColor("yellow"));
+}
+
+void tst_qmltc::jsvalueAssignments()
+{
+ QQmlEngine e;
+ PREPEND_NAMESPACE(qjsvalueAssignments) created(&e);
+ QVERIFY(created.jsvalue().isBool());
+ QVERIFY(created.jsvalue().toBool());
+}
+
void tst_qmltc::signalHandlers()
{
QQmlEngine e;
diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h
index 5ce8a189da..b92c8eed18 100644
--- a/tests/auto/qml/qmltc/tst_qmltc.h
+++ b/tests/auto/qml/qmltc/tst_qmltc.h
@@ -54,6 +54,8 @@ private slots:
void importNamespace();
void componentTypes();
void deferredProperties();
+ void gradients(); // QTBUG-102560
+ void jsvalueAssignments();
void signalHandlers();
void jsFunctions();