summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-04-22 11:21:17 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2021-05-03 20:32:42 +0200
commit98b4f4bc4d87aa2f2c30adbcb8fd42abcc88d6fb (patch)
treec543eaf56c9a7cb8507c904c70f3a74753323e2c /tests
parentd225c6afe765777bcd4f854e755f2e9c18febd7e (diff)
Q(Untyped)Bindable: Print warnings when operations fail
Instead of silently failing, we now print an explanatory warning to aid with debugging. Task-number: QTBUG-89512 Change-Id: I36dd2ce452af12d0523c19286919095e366bd390 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
index cdb68c7faa..b1f5a780a6 100644
--- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
+++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp
@@ -1065,6 +1065,25 @@ void tst_QProperty::quntypedBindableApi()
QCOMPARE(iprop.value(), 42);
QUntypedBindable propLess;
QVERIFY(propLess.takeBinding().isNull());
+
+ QUntypedBindable invalidBindable;
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "setBinding: Could not set binding via bindable interface. The QBindable is invalid.");
+#endif
+ invalidBindable.setBinding(Qt::makePropertyBinding(iprop));
+
+ QUntypedBindable readOnlyBindable(static_cast<const QProperty<int> *>(&iprop) );
+ QVERIFY(readOnlyBindable.isReadOnly());
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "setBinding: Could not set binding via bindable interface. The QBindable is read-only.");
+#endif
+ readOnlyBindable.setBinding(Qt::makePropertyBinding(iprop));
+
+ QProperty<float> fprop;
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "setBinding: Could not set binding as the property expects it to be of type int but got float instead.");
+#endif
+ bindable.setBinding(Qt::makePropertyBinding(fprop));
}
void tst_QProperty::readonlyConstQBindable()
@@ -1216,6 +1235,9 @@ void tst_QProperty::qobjectBindableSignalTakingNewValue()
void tst_QProperty::testNewStuff()
{
MyQObject testReadOnly;
+#ifndef QT_NO_DEBUG
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "setBinding: Could not set binding via bindable interface. The QBindable is read-only.");
+#endif
testReadOnly.bindableFoo().setBinding([](){return 42;});
auto bindable = const_cast<const MyQObject&>(testReadOnly).bindableFoo();
QVERIFY(bindable.hasBinding());