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>
bb10
Sona Kurazyan 2021-04-19 14:54:47 +02:00
parent 855f8a3f98
commit d83132c629
1 changed files with 12 additions and 0 deletions

View File

@ -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());