diff options
author | Marc Mutz <[email protected]> | 2024-03-18 07:44:07 +0100 |
---|---|---|
committer | Marc Mutz <[email protected]> | 2024-03-22 14:53:17 +0000 |
commit | 2cb5c184488fd476576966aa53f01539f8005d4a (patch) | |
tree | 831c049ad017d066dc012def4a3891decb97c001 | |
parent | f9e79171b6228de4a223c19c82b76ed1d5b4524b (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.
Manual conflict resolutions:
- Add using namespace Qt::StringLiterals, which, in 6.5, was not
yet present from some other, independent change.
Change-Id: Ia0ba888cce83529217642be0e7e321d9406ba386
Reviewed-by: David Faure <[email protected]>
Reviewed-by: MÃ¥rten Nordheim <[email protected]>
(cherry picked from commit ce913bff5df668787dc904469fca09763acf0f27)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit a6fba6154514fa6e786a7e6b187c5b970f90a8d3)
(cherry picked from commit e49fa7171805ca1c2b03c64e1c735fb5de85364b)
-rw-r--r-- | tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index 8b0319679fb..0e51eb0f981 100644 --- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp +++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp @@ -9,6 +9,8 @@ #include <qdatetime.h> +using namespace Qt::StringLiterals; + class tst_QSignalSpy : public QObject { Q_OBJECT @@ -460,27 +462,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()")); } |