From 56ec6a392a0301b733d0cb2f3d63453236ecdbff Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 17 Aug 2022 15:54:16 +0200 Subject: [PATCH] tst_qguiapplication: guard the usage of deprecated signals The paletteChanged() and fontChanged() signals were deprecated in Qt 6.0, but the test was still using them unconditionally. This patch guards the usage of the deprecated signals with the usual QT_DEPRECATED_SINCE(6, 0) check, so that the test can be built and run with QT_DISABLE_DEPRECATED_UP_TO >= 0x060000 This commit amends 68ea9c022701359b447be076888331a4f9d9085b Task-number: QTBUG-104858 Change-Id: Idb2da6d91afcdb664f325f23ec625947c9a7fac0 Reviewed-by: Edward Welbourne Reviewed-by: Sona Kurazyan --- tests/auto/gui/kernel/qguiapplication/CMakeLists.txt | 1 - .../kernel/qguiapplication/tst_qguiapplication.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt index a605657f86..e2bc3bb0f8 100644 --- a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt +++ b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt @@ -27,7 +27,6 @@ qt_internal_add_test(tst_qguiapplication ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case tst_qguiapplication.cpp DEFINES - QT_DISABLE_DEPRECATED_UP_TO=0x050E00 QT_QGUIAPPLICATIONTEST=1 INCLUDE_DIRECTORIES ../../../corelib/kernel/qcoreapplication diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index e8c283252e..f1851e72bc 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -532,16 +532,16 @@ void tst_QGuiApplication::palette() QVERIFY(palettesMatch(QGuiApplication::palette(), newPalette)); #if QT_DEPRECATED_SINCE(6, 0) QCOMPARE(signalSpy.count(), 1); -#endif QVERIFY(palettesMatch(signalSpy.at(0).at(0).value(), newPalette)); +#endif QCOMPARE(QGuiApplication::palette(), QPalette()); QGuiApplication::setPalette(oldPalette); QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette)); #if QT_DEPRECATED_SINCE(6, 0) QCOMPARE(signalSpy.count(), 2); -#endif QVERIFY(palettesMatch(signalSpy.at(1).at(0).value(), oldPalette)); +#endif QCOMPARE(QGuiApplication::palette(), QPalette()); QGuiApplication::setPalette(oldPalette); @@ -557,24 +557,32 @@ void tst_QGuiApplication::font() int argc = 1; char *argv[] = { const_cast("tst_qguiapplication") }; QGuiApplication app(argc, argv); +#if QT_DEPRECATED_SINCE(6, 0) QSignalSpy signalSpy(&app, SIGNAL(fontChanged(QFont))); +#endif QFont oldFont = QGuiApplication::font(); QFont newFont = QFont("BogusFont", 33); QGuiApplication::setFont(newFont); QCOMPARE(QGuiApplication::font(), newFont); +#if QT_DEPRECATED_SINCE(6, 0) QCOMPARE(signalSpy.count(), 1); QCOMPARE(signalSpy.at(0).at(0), QVariant(newFont)); +#endif QGuiApplication::setFont(oldFont); QCOMPARE(QGuiApplication::font(), oldFont); +#if QT_DEPRECATED_SINCE(6, 0) QCOMPARE(signalSpy.count(), 2); QCOMPARE(signalSpy.at(1).at(0), QVariant(oldFont)); +#endif QGuiApplication::setFont(oldFont); QCOMPARE(QGuiApplication::font(), oldFont); +#if QT_DEPRECATED_SINCE(6, 0) QCOMPARE(signalSpy.count(), 2); +#endif } class BlockableWindow : public QWindow