diff options
author | Paul Wicking <paul.wicking@qt.io> | 2020-03-04 15:16:10 +0100 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2020-03-06 15:48:28 +0100 |
commit | d7273da9c62ab13f437c72fe7e37406ed1b2413b (patch) | |
tree | a3fa30412a487f6b810813250aadd509a1601dd5 | |
parent | fcd523048f02025e7563a4a6a17f6e5ff98ca6bb (diff) | |
download | qttools-d7273da9c62ab13f437c72fe7e37406ed1b2413b.tar.gz |
QDoc: Add unit tests for Utilities
Fixes: QTBUG-82687
Change-Id: I41219b8cdc45d7e779acfefbcd57ff352b56b88e
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r-- | tests/auto/qdoc/qdoc.pro | 3 | ||||
-rw-r--r-- | tests/auto/qdoc/utilities/tst_utilities.cpp | 89 | ||||
-rw-r--r-- | tests/auto/qdoc/utilities/utilities.pro | 12 |
3 files changed, 103 insertions, 1 deletions
diff --git a/tests/auto/qdoc/qdoc.pro b/tests/auto/qdoc/qdoc.pro index d2afba2bf..c7af516ae 100644 --- a/tests/auto/qdoc/qdoc.pro +++ b/tests/auto/qdoc/qdoc.pro @@ -2,4 +2,5 @@ TEMPLATE = subdirs SUBDIRS = \ config \ - generatedoutput + generatedoutput \ + utilities diff --git a/tests/auto/qdoc/utilities/tst_utilities.cpp b/tests/auto/qdoc/utilities/tst_utilities.cpp new file mode 100644 index 000000000..0f63b1daf --- /dev/null +++ b/tests/auto/qdoc/utilities/tst_utilities.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "utilities.h" + +#include <QtTest/QtTest> + +QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQdoc, "qt.test") +QT_END_NAMESPACE + +class tst_Utilities : public QObject +{ + Q_OBJECT + +private slots: + void loggingCategoryName(); + void loggingCategoryDefaults(); + void startDebugging(); + void stopDebugging(); + void debugging(); +}; + +void tst_Utilities::loggingCategoryName() +{ + const QString expected = "qt.test"; + QCOMPARE(lcQdoc().categoryName(), expected); +} + +void tst_Utilities::loggingCategoryDefaults() +{ + QVERIFY(lcQdoc().isCriticalEnabled()); + QVERIFY(lcQdoc().isWarningEnabled()); + QVERIFY(!lcQdoc().isDebugEnabled()); + QVERIFY(lcQdoc().isInfoEnabled()); +} + +void tst_Utilities::startDebugging() +{ + QVERIFY(!lcQdoc().isDebugEnabled()); + Utilities::startDebugging("test"); + QVERIFY(lcQdoc().isDebugEnabled()); +} + +void tst_Utilities::stopDebugging() +{ + Utilities::startDebugging("test"); + QVERIFY(lcQdoc().isDebugEnabled()); + Utilities::stopDebugging("test"); + QVERIFY(!lcQdoc().isDebugEnabled()); +} + +void tst_Utilities::debugging() +{ + QVERIFY(!lcQdoc().isDebugEnabled()); + QVERIFY(!Utilities::debugging()); + Utilities::startDebugging("test"); + QVERIFY(lcQdoc().isDebugEnabled()); + QVERIFY(Utilities::debugging()); +} + +QTEST_APPLESS_MAIN(tst_Utilities) + +#include "tst_utilities.moc" diff --git a/tests/auto/qdoc/utilities/utilities.pro b/tests/auto/qdoc/utilities/utilities.pro new file mode 100644 index 000000000..57489f2b1 --- /dev/null +++ b/tests/auto/qdoc/utilities/utilities.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +QT = core testlib +TARGET = tst_utilities +INCLUDEPATH += $$PWD/../../../../src/qdoc + +HEADERS += \ + $$PWD/../../../../src/qdoc/loggingcategory.h \ + $$PWD/../../../../src/qdoc/utilities.h + +SOURCES += \ + tst_utilities.cpp \ + $$PWD/../../../../src/qdoc/utilities.cpp |