From 5b525e8e54384600b92415b08b5ec94020faf40c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 21 Sep 2021 16:30:03 +0200 Subject: Replace QTest::qWarn() with qWarning() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's the recommended replacement when file and line aren't known, and simplifies the code in any case, thanks to taking format and varargs. It incidentally also enables tests to tell QtTest's custom message logger to anticipate its warnings, when they arise. Fixes: QTBUG-67702 Change-Id: I10c883f4dd0b69dca6e59e0dbd55ab318f1938f4 Reviewed-by: Mitch Curtis Reviewed-by: Shawn Rutledge Reviewed-by: Tor Arne Vestbø --- src/testlib/qtestkeyboard.h | 4 ++-- src/testlib/qtestmouse.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h index 1c1b676e70..84b3e3f3c4 100644 --- a/src/testlib/qtestkeyboard.h +++ b/src/testlib/qtestkeyboard.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtTest module of the Qt Toolkit. @@ -197,7 +197,7 @@ namespace QTest if (press && qt_sendShortcutOverrideEvent(widget, a.timestamp(), code, modifier, text, repeat)) return; if (!qApp->notify(widget, &a)) - QTest::qWarn("Keyboard event not accepted by receiving widget"); + qWarning("Keyboard event not accepted by receiving widget"); } static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code, diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 3e43434a50..fe89f371ca 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtTest module of the Qt Toolkit. @@ -103,8 +103,8 @@ namespace QTest // pos is in window local coordinates const QSize windowSize = window->geometry().size(); if (windowSize.width() <= pos.x() || windowSize.height() <= pos.y()) { - QTest::qWarn(qPrintable(QString::fromLatin1("Mouse event at %1, %2 occurs outside of target window (%3x%4).") - .arg(pos.x()).arg(pos.y()).arg(windowSize.width()).arg(windowSize.height()))); + qWarning("Mouse event at %d, %d occurs outside target window (%dx%d).", + pos.x(), pos.y(), windowSize.width(), windowSize.height()); } if (delay == -1 || delay < defaultMouseDelay()) @@ -237,8 +237,8 @@ namespace QTest if (!qApp->notify(widget, &me)) { static const char *const mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" }; - QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget"); - QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast(action)])).toLatin1().data()); + qWarning("Mouse event \"%s\" not accepted by receiving widget", + mouseActionNames[static_cast(action)]); } #endif } -- cgit v1.2.3