From d83132c62977cf839ff4958749d9b82e5f1ce05a Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Mon, 19 Apr 2021 14:54:47 +0200 Subject: QTest: improve the read-only property test helper Add a check that setting a binding on the read-only property has no effect, nor does trying to change its value via such a binding. Change-Id: Id7b55cd53256961faface7ef155225664cdee97a Reviewed-by: Edward Welbourne --- src/testlib/qpropertytesthelper_p.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/testlib') diff --git a/src/testlib/qpropertytesthelper_p.h b/src/testlib/qpropertytesthelper_p.h index c89ff58051..1a769bc3f0 100644 --- a/src/testlib/qpropertytesthelper_p.h +++ b/src/testlib/qpropertytesthelper_p.h @@ -280,6 +280,18 @@ void testReadOnlyPropertyBasics( testedObj.property(propertyName).template value(), initial, comparator, represent); + // Check that attempting to bind this read-only property to another property has no effect: + QProperty propSetter(initial); + QVERIFY(!bindable.hasBinding()); + bindable.setBinding(Qt::makePropertyBinding(propSetter)); + QVERIFY(!bindable.hasBinding()); + propSetter.setValue(changed); + QPROPERTY_TEST_COMPARISON_HELPER( + testedObj.property(propertyName).template value(), initial, comparator, + represent); + if (spy) + QCOMPARE(spy->count(), 0); + QProperty propObserver; propObserver.setBinding(bindable.makeBinding()); -- cgit v1.2.3