diff options
author | Marc Mutz <marc.mutz@qt.io> | 2024-03-18 07:44:07 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2024-03-19 21:09:37 +0100 |
commit | ce913bff5df668787dc904469fca09763acf0f27 (patch) | |
tree | d608c5a75b6878089f73351f14653bb1242baa78 | |
parent | 7565034aadf955537be908a94e4cef16096a041f (diff) |
tst_QSignalSpy: check (thereby suppress) intended runtime warnings
Use QTest::ignoreMessage() to prevent the runtime warnings being
printed, cleaning up the test log, and to document that they're
intended.
Pick-to: 6.7 6.6 6.5
Change-Id: Ia0ba888cce83529217642be0e7e321d9406ba386
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index 847986a673..40dc83ec28 100644 --- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp +++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp @@ -464,27 +464,33 @@ void tst_QSignalSpy::spyOnMetaMethod() Q_DECLARE_METATYPE(QMetaMethod); void tst_QSignalSpy::spyOnMetaMethod_invalid() { + QFETCH(const QByteArray, message); QFETCH(QObject*, object); QFETCH(QMetaMethod, signal); + QTest::ignoreMessage(QtWarningMsg, message.data()); QSignalSpy spy(object, signal); QVERIFY(!spy.isValid()); } void tst_QSignalSpy::spyOnMetaMethod_invalid_data() { + QTest::addColumn<QByteArray>("message"); QTest::addColumn<QObject*>("object"); QTest::addColumn<QMetaMethod>("signal"); QTest::addRow("Invalid object") + << "QSignalSpy: Cannot spy on a null object"_ba << static_cast<QObject*>(nullptr) << QMetaMethod(); QTest::addRow("Empty signal") + << "QSignalSpy: Not a valid signal: ''"_ba << new QObject(this) << QMetaMethod(); QTest::addRow("Method is not a signal") + << "QSignalSpy: Not a valid signal: 'deleteLater()'"_ba << new QObject(this) << QObject::staticMetaObject.method(QObject::staticMetaObject.indexOfMethod("deleteLater()")); } |