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 68ea9c0227

Task-number: QTBUG-104858
Change-Id: Idb2da6d91afcdb664f325f23ec625947c9a7fac0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
Ivan Solovev 2022-08-17 15:54:16 +02:00
parent 2e69ef6af9
commit 56ec6a392a
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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<QPalette>(), 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<QPalette>(), oldPalette));
#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
QGuiApplication::setPalette(oldPalette);
@ -557,24 +557,32 @@ void tst_QGuiApplication::font()
int argc = 1;
char *argv[] = { const_cast<char*>("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