diff options
Diffstat (limited to 'tests')
9 files changed, 117 insertions, 19 deletions
diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp index 33b16ed8e5..81d02f93cf 100644 --- a/tests/auto/corelib/global/qlogging/app/main.cpp +++ b/tests/auto/corelib/global/qlogging/app/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -73,6 +73,7 @@ int main(int argc, char **argv) qSetMessagePattern("[%{type}] %{message}"); qDebug("qDebug"); + qInfo("qInfo"); qWarning("qWarning"); qCritical("qCritical"); diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index c35a373d3f..b3beefa2fb 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> ** Contact: http://www.qt-project.org/legal ** @@ -730,10 +730,11 @@ void tst_qmessagehandler::qMessagePattern_data() << "static destructor" << "debug tst_qlogging 65 MyClass::myFunction from_a_function 34" << "debug tst_qlogging 75 main qDebug" - << "warning tst_qlogging 76 main qWarning" - << "critical tst_qlogging 77 main qCritical" - << "warning tst_qlogging 80 main qDebug with category" - << "debug tst_qlogging 84 main qDebug2"); + << "info tst_qlogging 76 main qInfo" + << "warning tst_qlogging 77 main qWarning" + << "critical tst_qlogging 78 main qCritical" + << "warning tst_qlogging 81 main qDebug with category" + << "debug tst_qlogging 85 main qDebug2"); QTest::newRow("invalid") << "PREFIX: %{unknown} %{message}" << false << (QList<QByteArray>() @@ -877,6 +878,7 @@ void tst_qmessagehandler::setMessagePattern() //qDebug() << output; QByteArray expected = "static constructor\n" "[debug] qDebug\n" + "[info] qInfo\n" "[warning] qWarning\n" "[critical] qCritical\n" "[warning] qDebug with category\n"; @@ -908,10 +910,13 @@ void tst_qmessagehandler::formatLogMessage_data() << QtDebugMsg << BA("main.cpp") << 1 << BA("func") << BA("") << "msg"; // test the if conditions - QString format = "[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}"; + QString format = "[%{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{if-category}%{category}: %{endif}%{message}"; QTest::newRow("if-debug") << format << "[D] msg" << QtDebugMsg << BA("") << 0 << BA("func") << QByteArray() << "msg"; + QTest::newRow("if_info") + << format << "[I] msg" + << QtInfoMsg << BA("") << 0 << BA("func") << QByteArray() << "msg"; QTest::newRow("if_warning") << format << "[W] msg" << QtWarningMsg << BA("") << 0 << BA("func") << QByteArray() << "msg"; diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index 2e4740c8d9..dc0081f7ac 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -57,6 +57,7 @@ QByteArray qMyMessageFormatString(QtMsgType type, const QMessageLogContext &cont message.append(context.category); switch (type) { case QtDebugMsg: message.append(".debug"); break; + case QtInfoMsg: message.append(".info"); break; case QtWarningMsg: message.append(".warning"); break; case QtCriticalMsg:message.append(".critical"); break; case QtFatalMsg: message.append(".fatal"); break; @@ -339,6 +340,11 @@ private slots: qDebug("%s", "Check debug with no filter active"); QCOMPARE(logMessage, buf); + // Check default info + buf = QStringLiteral("default.info: Check info with no filter active"); + qInfo("%s", "Check info with no filter active"); + QCOMPARE(logMessage, buf); + // Check default warning buf = QStringLiteral("default.warning: Check warning with no filter active"); qWarning("%s", "Check warning with no filter active"); @@ -407,6 +413,13 @@ private slots: qCDebug(defaultCategory, "Check debug with no filter active"); QCOMPARE(logMessage, buf); + // Check default info + buf = QStringLiteral("default.info: Check info with no filter active"); + qCInfo(defaultCategory) << "Check info with no filter active"; + QCOMPARE(logMessage, buf); + qCInfo(defaultCategory, "Check info with no filter active"); + QCOMPARE(logMessage, buf); + // Check default warning buf = QStringLiteral("default.warning: Check warning with no filter active"); qCWarning(defaultCategory) << "Check warning with no filter active"; @@ -432,6 +445,11 @@ private slots: qCDebug(customCategory) << "Check debug with no filter active"; QCOMPARE(logMessage, buf); + // Check custom info + buf = QStringLiteral("custom.info: Check info with no filter active"); + qCInfo(customCategory) << "Check info with no filter active"; + QCOMPARE(logMessage, buf); + // Check custom warning buf = QStringLiteral("custom.warning: Check warning with no filter active"); qCWarning(customCategory) << "Check warning with no filter active"; @@ -493,7 +511,7 @@ private slots: usedefaultformat = false; } - // Check the Debug, Warning and critical without having category active. should be active. + // Check the Debug, Info, Warning and critical without having category active. should be active. void checkNoCategoryLogActive() { // Check default debug @@ -501,6 +519,11 @@ private slots: qDebug() << "Check default Debug with no log active"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + // Check default info + buf = QStringLiteral("default.info: Check default Info with no log active"); + qInfo() << "Check default Info with no log active"; + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + // Check default warning buf = QStringLiteral("default.warning: Check default Warning with no log active"); qWarning() << "Check default Warning with no log active"; @@ -514,8 +537,11 @@ private slots: // Check category debug buf = QStringLiteral("tst.log.debug: Check category Debug with no log active"); qCDebug(TST_LOG) << "Check category Debug with no log active"; - QCOMPARE(logMessage, buf); + // Check category info + buf = QStringLiteral("tst.log.info: Check category Info with no log active"); + qCInfo(TST_LOG) << "Check category Info with no log active"; + QCOMPARE(logMessage, buf); // Check default warning buf = QStringLiteral("tst.log.warning: Check category Warning with no log active"); @@ -550,6 +576,9 @@ private slots: qCDebug(TST_LOG) << "DebugType"; buf = QStringLiteral("tst.log.debug: DebugType"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qCInfo(TST_LOG) << "InfoType"; + buf = QStringLiteral("tst.log.info: InfoType"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qCWarning(TST_LOG) << "WarningType"; buf = QStringLiteral("tst.log.warning: WarningType"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -561,11 +590,13 @@ private slots: void checkLegacyLogs() { logMessage = ""; + // all are on by default qDebug() << "DefaultDebug"; QString buf = QStringLiteral("default.debug: DefaultDebug"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); - - // debug off by default, warning and critical are on + qInfo() << "DefaultInfo"; + buf = QStringLiteral("default.info: DefaultInfo"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning"; buf = QStringLiteral("default.warning: DefaultWarning"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -573,12 +604,16 @@ private slots: buf = QStringLiteral("default.critical: DefaultCritical"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); - // Enable debug - _config->addKey("default.debug", true); + // Disable debug + _config->addKey("default.debug", false); QLoggingCategory::setFilterRules(_config->array()); + logMessage = "no change"; qDebug() << "DefaultDebug1"; - buf = QStringLiteral("default.debug: DefaultDebug1"); + buf = QStringLiteral("no change"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qInfo() << "DefaultInfo1"; + buf = QStringLiteral("default.info: DefaultInfo1"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning1"; buf = QStringLiteral("default.warning: DefaultWarning1"); @@ -587,7 +622,11 @@ private slots: buf = QStringLiteral("default.critical: DefaultCritical1"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); - // Disable warning + _config->clear(); + QLoggingCategory::setFilterRules(_config->array()); + + // Disable info, warning + _config->addKey("default.info", false); _config->addKey("default.warning", false); QLoggingCategory::setFilterRules(_config->array()); @@ -595,6 +634,9 @@ private slots: buf = QStringLiteral("default.debug: DefaultDebug2"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); logMessage = "no change"; + qInfo() << "DefaultInfo2"; + buf = QStringLiteral("no change"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning2"; buf = QStringLiteral("no change"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -611,6 +653,8 @@ private slots: qDebug() << "DefaultDebug3"; buf = QStringLiteral("no change"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qInfo() << "DefaultInfo3"; + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning3"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qCritical() << "DefaultCritical3"; @@ -619,6 +663,7 @@ private slots: // Enable default logs _config->addKey("default.critical", true); _config->addKey("default.warning", true); + _config->addKey("default.info", true); _config->addKey("default.debug", true); QLoggingCategory::setFilterRules(_config->array()); @@ -626,6 +671,9 @@ private slots: qDebug() << "DefaultDebug4"; buf = QStringLiteral("default.debug: DefaultDebug4"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qInfo() << "DefaultInfo4"; + buf = QStringLiteral("default.info: DefaultInfo4"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning4"; buf = QStringLiteral("default.warning: DefaultWarning4"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -642,6 +690,8 @@ private slots: buf = QStringLiteral("no change"); qDebug() << "DefaultDebug5"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qDebug() << "DefaultInfo5"; + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qWarning() << "DefaultWarning5"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qCritical() << "DefaultCritical5"; @@ -711,6 +761,7 @@ private slots: QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); logMessage = "no change"; buf = QStringLiteral("no change"); + qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 4"; qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 4"; qCCritical(Digia_Berlin_Office_com) << "Critical: Digia.Berlin.Office.com 4"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -723,6 +774,9 @@ private slots: qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 5"; buf = QStringLiteral("Digia.Oslo.Office.com.debug: Debug: Digia.Oslo.Office.com 5"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 5"; + buf = QStringLiteral("Digia.Oulu.Office.com.info: Info: Digia.Oulu.Office.com 5"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 5"; buf = QStringLiteral("Digia.Oulu.Office.com.warning: Warning: Digia.Oulu.Office.com 5"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -737,6 +791,7 @@ private slots: logMessage = "no change"; buf = QStringLiteral("no change"); qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 6"; + qCInfo(Digia_Oslo_Office_com) << "Info: Digia.Oslo.Office.com 6"; qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 6"; qCCritical(Digia_Berlin_Office_com) << "Critical: Digia.Berlin.Office.com 6"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -747,6 +802,9 @@ private slots: qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 7"; buf = QStringLiteral("Digia.Oslo.Office.com.debug: Debug: Digia.Oslo.Office.com 7"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 7"; + buf = QStringLiteral("Digia.Oulu.Office.com.info: Info: Digia.Oulu.Office.com 7"); + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 7"; buf = QStringLiteral("Digia.Oulu.Office.com.warning: Warning: Digia.Oulu.Office.com 7"); QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -770,6 +828,10 @@ private slots: qCDebug(mycategoryobject) << "My Category Object"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + buf = QStringLiteral("LoggingCategoryObject.info: My Category Object"); + qCInfo(mycategoryobject) << "My Category Object"; + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + buf = QStringLiteral("LoggingCategoryObject.warning: My Category Object"); qCWarning(mycategoryobject) << "My Category Object"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); @@ -787,6 +849,10 @@ private slots: qCWarning(mycategoryobject) << "My Category Object"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + buf = QStringLiteral("LoggingCategoryObject.info: My Category Object"); + qCInfo(mycategoryobject) << "My Category Object"; + QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); + buf = QStringLiteral("LoggingCategoryObject.critical: My Category Object"); qCCritical(mycategoryobject) << "My Category Object"; QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf)); diff --git a/tests/auto/testlib/selftests/expected_warnings.lightxml b/tests/auto/testlib/selftests/expected_warnings.lightxml index 31b3d842aa..afbbf5b5e2 100644 --- a/tests/auto/testlib/selftests/expected_warnings.lightxml +++ b/tests/auto/testlib/selftests/expected_warnings.lightxml @@ -20,6 +20,12 @@ <Message type="qdebug" file="" line="0"> <Description><![CDATA[Debug]]></Description> </Message> +<Message type="qinfo" file="" line="0"> + <Description><![CDATA[Info]]></Description> +</Message> +<Message type="qinfo" file="" line="0"> + <Description><![CDATA[Info]]></Description> +</Message> <Message type="qdebug" file="" line="0"> <Description><![CDATA[Baba]]></Description> </Message> diff --git a/tests/auto/testlib/selftests/expected_warnings.txt b/tests/auto/testlib/selftests/expected_warnings.txt index bb77257b79..9f7393e90f 100644 --- a/tests/auto/testlib/selftests/expected_warnings.txt +++ b/tests/auto/testlib/selftests/expected_warnings.txt @@ -5,6 +5,8 @@ QWARN : tst_Warnings::testWarnings() Warning QWARN : tst_Warnings::testWarnings() Warning QDEBUG : tst_Warnings::testWarnings() Debug QDEBUG : tst_Warnings::testWarnings() Debug +QINFO : tst_Warnings::testWarnings() Info +QINFO : tst_Warnings::testWarnings() Info QDEBUG : tst_Warnings::testWarnings() Baba QDEBUG : tst_Warnings::testWarnings() Baba QDEBUG : tst_Warnings::testWarnings() Bubublabla diff --git a/tests/auto/testlib/selftests/expected_warnings.xml b/tests/auto/testlib/selftests/expected_warnings.xml index a3821f84df..7023e35e0c 100644 --- a/tests/auto/testlib/selftests/expected_warnings.xml +++ b/tests/auto/testlib/selftests/expected_warnings.xml @@ -22,6 +22,12 @@ <Message type="qdebug" file="" line="0"> <Description><![CDATA[Debug]]></Description> </Message> +<Message type="qinfo" file="" line="0"> + <Description><![CDATA[Info]]></Description> +</Message> +<Message type="qinfo" file="" line="0"> + <Description><![CDATA[Info]]></Description> +</Message> <Message type="qdebug" file="" line="0"> <Description><![CDATA[Baba]]></Description> </Message> diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.xunitxml index 7ea66522c6..5cca215f12 100644 --- a/tests/auto/testlib/selftests/expected_warnings.xunitxml +++ b/tests/auto/testlib/selftests/expected_warnings.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="15" failures="4" tests="6" name="tst_Warnings"> +<testsuite errors="17" failures="4" tests="6" name="tst_Warnings"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -11,6 +11,8 @@ <!-- message="Warning" type="qwarn" --> <!-- message="Debug" type="qdebug" --> <!-- message="Debug" type="qdebug" --> + <!-- message="Info" type="qinfo" --> + <!-- message="Info" type="qinfo" --> <!-- message="Baba" type="qdebug" --> <!-- message="Baba" type="qdebug" --> <!-- message="Bubublabla" type="qdebug" --> @@ -39,6 +41,8 @@ <![CDATA[Warning]]> <![CDATA[Debug]]> <![CDATA[Debug]]> +<![CDATA[Info]]> +<![CDATA[Info]]> <![CDATA[Baba]]> <![CDATA[Baba]]> <![CDATA[Bubublabla]]> diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp index 545f7d3420..335411e466 100644 --- a/tests/auto/testlib/selftests/silent/tst_silent.cpp +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -83,6 +83,7 @@ void tst_Silent::messages() QWARN("This is an internal testlib warning that should not appear in silent test output"); qDebug("This is a debug message that should not appear in silent test output"); qCritical("This is a critical message that should not appear in silent test output"); + qInfo("This is an info message that should not appear in silent test output"); QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); qFatal("This is a fatal error message that should still appear in silent test output"); } diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp index b000f37687..9266b83934 100644 --- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp +++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -63,6 +63,13 @@ void tst_Warnings::testWarnings() qDebug("Debug"); + qInfo("Info"); + + QTest::ignoreMessage(QtInfoMsg, "Info"); + qInfo("Info"); + + qInfo("Info"); + QTest::ignoreMessage(QtDebugMsg, "Bubu"); qDebug("Baba"); qDebug("Bubu"); |