From e49fa7171805ca1c2b03c64e1c735fb5de85364b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 18 Mar 2024 07:44:07 +0100 Subject: [PATCH] tst_QSignalSpy: check (thereby suppress) intended runtime warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.5 Change-Id: Ia0ba888cce83529217642be0e7e321d9406ba386 Reviewed-by: David Faure Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit ce913bff5df668787dc904469fca09763acf0f27) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit a6fba6154514fa6e786a7e6b187c5b970f90a8d3) --- tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index c01684177fa..ddba4d56c7f 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("message"); QTest::addColumn("object"); QTest::addColumn("signal"); QTest::addRow("Invalid object") + << "QSignalSpy: Cannot spy on a null object"_ba << static_cast(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()")); }