diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-31 18:25:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-08-04 19:31:51 +0200 |
commit | bef57b317f2efc0e73f2275d594be9d69f5a75d0 (patch) | |
tree | fc277768e0812c65c5a860a2971b859a833c5088 /tests/auto/gui | |
parent | fe9c705e9aa0e25760646695820bd876de590893 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 4 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index f5fb92b32b..e4cee0e89c 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -2063,7 +2063,7 @@ void tst_QWindow::modalDialog() QGuiApplication::processEvents(); if (isPlatformOffscreenOrMinimal()) { - QWARN("Focus stays in normalWindow on offscreen/minimal platforms"); + qWarning("Focus stays in normalWindow on offscreen/minimal platforms"); QTRY_COMPARE(QGuiApplication::focusWindow(), &normalWindow); return; } @@ -2109,7 +2109,7 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal() QGuiApplication::processEvents(); if (isPlatformOffscreenOrMinimal()) { - QWARN("Focus is lost when closing modal dialog on offscreen/minimal platforms"); + qWarning("Focus is lost when closing modal dialog on offscreen/minimal platforms"); QTRY_COMPARE(QGuiApplication::focusWindow(), nullptr); return; } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index a028990a16..1679d5b8df 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -599,7 +599,7 @@ QImage tst_QPainter::getResImage( const QString &dir, const QString &addition, c QImage res; QString resFilename = dir + QLatin1String("/res_") + addition + QLatin1Char('.') + extension; if ( !res.load( resFilename ) ) { - QWARN(QString("Could not load result data %s %1").arg(resFilename).toLatin1()); + qWarning() << "Could not load result data" << resFilename; return QImage(); } return res; @@ -610,14 +610,14 @@ QBitmap tst_QPainter::getBitmap( const QString &dir, const QString &filename, bo QBitmap bm; QString bmFilename = dir + QLatin1Char('/') + filename + QLatin1String(".xbm"); if ( !bm.load( bmFilename ) ) { - QWARN(QString("Could not load bitmap '%1'").arg(bmFilename).toLatin1()); + qWarning() << "Could not load bitmap" << bmFilename; return QBitmap(); } if ( mask ) { QBitmap mask; QString maskFilename = dir + QLatin1Char('/') + filename + QLatin1String("-mask.xbm"); if (!mask.load(maskFilename)) { - QWARN(QString("Could not load mask '%1'").arg(maskFilename).toLatin1()); + qWarning() << "Could not load mask" << maskFilename; return QBitmap(); } bm.setMask( mask ); |