summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp96
1 files changed, 81 insertions, 15 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index 2e4740c8d9..deef9eecbf 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -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));