From bef57b317f2efc0e73f2275d594be9d69f5a75d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 31 Jul 2021 18:25:42 +0200 Subject: testlib: Deprecate QWARN() in favor of qWarning() The QtTest best practices documentations recommends using output mechanisms such as qDebug() and qWarning() for diagnostic messages, and this is also what most of our own tests do. The QWARN() macro and corresponding internal QTest::qWarn() function was added when QtTest was first implemented, but was likely meant as an internal implementation detail, like its cousin QTestLog::info(), which does not have any corresponding macro. This theory is backed by our own QtTest self-test (tst_silent) describing the output from QWARN() as "an internal testlib warning". The only difference between QWARN() and qWarning(), besides the much richer feature set of the latter, is that qWarning() will not pass on file and line number information in release mode, but QWARN() will. This is an acceptable loss of functionality, considering that the user can override this behavior by defining QT_MESSAGELOGCONTEXT. [ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning() Pick-to: 6.2 Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85 Reviewed-by: Thiago Macieira --- tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 2 +- tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp | 4 ++-- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 2 +- tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/auto/widgets/widgets') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 1c15f67bd3..4146a6632d 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -3460,7 +3460,7 @@ void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex() completer->setModel(model); if (QGuiApplication::platformName() == "offscreen") { - QWARN("Offscreen platform requires explicit activateWindow()"); + qWarning("Offscreen platform requires explicit activateWindow()"); cbox.activateWindow(); } diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index a3f4f353d1..dd67de2287 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -1045,7 +1045,7 @@ void tst_QDoubleSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isUndoAvailable()); QVERIFY(spin.lineEdit()->isRedoAvailable()); } else { - QWARN("Undo not tested because no key sequence associated to QKeySequence::Redo"); + qWarning("Undo not tested because no key sequence associated to QKeySequence::Redo"); } @@ -1058,7 +1058,7 @@ void tst_QDoubleSpinBox::undoRedo() QVERIFY(!spin.lineEdit()->isRedoAvailable()); QVERIFY(spin.lineEdit()->isUndoAvailable()); } else { - QWARN("Redo not tested because no key sequence associated to QKeySequence::Redo"); + qWarning("Redo not tested because no key sequence associated to QKeySequence::Redo"); } diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 0dc4c07069..e52df3c84c 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1811,7 +1811,7 @@ void tst_QMenu::menuSize_Scrolling() QSize s = size(); if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { - QWARN("Skipping test on minimal/offscreen platforms - QTBUG-73522"); + qWarning("Skipping test on minimal/offscreen platforms - QTBUG-73522"); QMenu::showEvent(e); return; } diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index bac7962c6a..1b8de0b75c 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -921,7 +921,7 @@ void tst_QMenuBar::check_escKey() if (!QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive) || !QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) { - QWARN("Skipping menu button test on minimal/offscreen platforms"); + qWarning("Skipping menu button test on minimal/offscreen platforms"); return; } -- cgit v1.2.3