diff options
author | Paul Wicking <paul.wicking@qt.io> | 2019-09-26 14:25:10 +0200 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2020-03-05 15:32:08 +0100 |
commit | a65303b133e47b98c5a3d561def6597aebba56df (patch) | |
tree | 0637dd1be65701a4f0a480d22f87105275aedf6b | |
parent | 94ee5927f5551d32876f5854c8b0f630b68b4659 (diff) | |
download | qttools-a65303b133e47b98c5a3d561def6597aebba56df.tar.gz |
QDoc: Add basic unit test for Config
Starting point for unit testing Config.
Fixes: QTBUG-82672
Change-Id: If9e6300d3388173a08545609aca74c8e6a588041
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | tests/auto/qdoc/config/config.pro | 16 | ||||
-rw-r--r-- | tests/auto/qdoc/config/tst_config.cpp | 85 | ||||
-rw-r--r-- | tests/auto/qdoc/qdoc.pro | 1 |
3 files changed, 102 insertions, 0 deletions
diff --git a/tests/auto/qdoc/config/config.pro b/tests/auto/qdoc/config/config.pro new file mode 100644 index 000000000..b6cb9a32d --- /dev/null +++ b/tests/auto/qdoc/config/config.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +QT = core testlib +TARGET = tst_config +INCLUDEPATH += $$PWD/../../../../src/qdoc + +HEADERS += \ + $$PWD/../../../../src/qdoc/config.h \ + $$PWD/../../../../src/qdoc/location.h \ + $$PWD/../../../../src/qdoc/qdoccommandlineparser.h \ + $$PWD/../../../../src/qdoc/loggingcategory.h + +SOURCES += \ + tst_config.cpp \ + $$PWD/../../../../src/qdoc/config.cpp \ + $$PWD/../../../../src/qdoc/location.cpp \ + $$PWD/../../../../src/qdoc/qdoccommandlineparser.cpp diff --git a/tests/auto/qdoc/config/tst_config.cpp b/tests/auto/qdoc/config/tst_config.cpp new file mode 100644 index 000000000..1e9383fb9 --- /dev/null +++ b/tests/auto/qdoc/config/tst_config.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 "config.h" + +#include <QtCore/qhash.h> +#include <QtCore/qstringlist.h> +#include <QtTest/QtTest> + +QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQdoc, "qt.test") +QT_END_NAMESPACE + +class tst_Config : public QObject +{ + Q_OBJECT + +private slots: + void classMembersInitializeToFalseOrEmpty(); + void includePathsFromCommandLine(); +}; + +void tst_Config::classMembersInitializeToFalseOrEmpty() +{ + QStringList commandLineArgs = { QStringLiteral("./qdoc") }; + + Config::instance().init("QDoc Test", commandLineArgs); + auto &config = Config::instance(); + QCOMPARE(config.singleExec(), false); + + QVERIFY(config.defines().isEmpty()); + QVERIFY(config.includePaths().isEmpty()); + QVERIFY(config.dependModules().isEmpty()); + QVERIFY(config.indexDirs().isEmpty()); + QVERIFY(config.currentDir().isEmpty()); + QVERIFY(config.previousCurrentDir().isEmpty()); +} + +void tst_Config::includePathsFromCommandLine() +{ + const auto mockIncludePath1 = QString("-I" + QDir().absoluteFilePath("/qt5/qtdoc/doc/.")); + const auto mockIncludePath2 = QString("-I" + QDir().absoluteFilePath("/qt5/qtbase/mkspecs/linux-g++")); + const QStringList commandLineArgs = { + QStringLiteral("./qdoc"), + mockIncludePath1, + mockIncludePath2 + }; + + Config::instance().init("QDoc Test", commandLineArgs); + auto &config = Config::instance(); + + const QStringList expected = { mockIncludePath1, mockIncludePath2 }; + const QStringList actual = config.includePaths(); + + QCOMPARE(actual, expected); +} + +QTEST_APPLESS_MAIN(tst_Config) + +#include "tst_config.moc" diff --git a/tests/auto/qdoc/qdoc.pro b/tests/auto/qdoc/qdoc.pro index 97117dc6f..d2afba2bf 100644 --- a/tests/auto/qdoc/qdoc.pro +++ b/tests/auto/qdoc/qdoc.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ + config \ generatedoutput |