diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-04-19 14:54:47 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-04-20 20:34:53 +0200 |
commit | d83132c62977cf839ff4958749d9b82e5f1ce05a (patch) | |
tree | c8d0fede3e0c3d8d2b94b6afd08a80631ccaadfb /src/testlib/qpropertytesthelper_p.h | |
parent | 855f8a3f98f366b26eecba556cdfb2e509081a29 (diff) |
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qpropertytesthelper_p.h')
-rw-r--r-- | src/testlib/qpropertytesthelper_p.h | 12 |
1 files changed, 12 insertions, 0 deletions
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<PropertyType>(), initial, comparator, represent); + // Check that attempting to bind this read-only property to another property has no effect: + QProperty<PropertyType> 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<PropertyType>(), initial, comparator, + represent); + if (spy) + QCOMPARE(spy->count(), 0); + QProperty<PropertyType> propObserver; propObserver.setBinding(bindable.makeBinding()); |