aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-03-07 12:28:19 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-05-12 14:07:36 +0200
commitb367b1c61952651fc64a1ad9bce819f0f92ea1c6 (patch)
tree1446655d81b0f393e140e4201b0cf34767dc07ae /tests
parent974fda409d45e3eff4405eaf7fca1eacf203e4a4 (diff)
QQmlAnyBinding: Honor interceptors if and only if requested
When installing a binding on a property which is intercepted, we can either ignore or honor the interceptor (depending on whether the newly added binding's value should be intercepted or not). This was previously only implemented for QmlAbstractBinding based bindings. This patch adds support for QProperty based bindings, and a corresponding test. Change-Id: Ib0a63426aa4a137cb7a375405843f2b0a97845d0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
index c23c0fb73f..7f81059b58 100644
--- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -36,6 +36,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlpropertyvalueinterceptor_p.h>
#include <private/qqmlengine_p.h>
+#include <private/qqmlanybinding_p.h>
#include "../../shared/util.h"
class tst_qqmlmetatype : public QQmlDataTest
@@ -377,6 +378,20 @@ void tst_qqmlmetatype::interceptorAPI()
auto interceptor = obj->property("i").value<ForwardAndLogInterceptor *>();
QVERIFY(interceptor->interceptedBindable);
QVERIFY(interceptor->interceptedWrite);
+
+ QQmlProperty objectName(obj.get(), "objectName");
+ QProperty<QString> hello(u"Hello, World!"_qs);
+ QQmlAnyBinding binding;
+ binding = Qt::makePropertyBinding(hello);
+ interceptor->interceptedBindable = false;
+ binding.installOn(objectName, QQmlAnyBinding::RespectInterceptors);
+ QVERIFY(interceptor->interceptedBindable);
+ binding = QQmlAnyBinding::takeFrom(objectName);
+ objectName.write("bar");
+ interceptor->interceptedBindable = false;
+ binding.installOn(objectName, QQmlAnyBinding::IgnoreInterceptors);
+ QVERIFY(!interceptor->interceptedBindable);
+ QCOMPARE(objectName.read().toString(), hello.value());
}
class Controller1 : public QObject