summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-08-03 17:02:57 +0200
committerPaul Wicking <paul.wicking@qt.io>2019-09-03 14:37:42 +0200
commitcbb56d8dab2447ce8fda454e6c6cd6938dffacb1 (patch)
tree94aefcdc3a4286fa0784bbfd569229939307d40d
parentaec109127efe748b60e6e31ac9235b13f1c1fba7 (diff)
QDoc: Add test for QDocCommandLineParser
Add unit tests for what's left of QDocCommandLineParser (which is, admittedly, not a lot). Task-number: QTBUG-71176 Change-Id: I07594e10a6055afd2a663148a6c10bd48f022b08 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--tests/auto/qdoc/qdoc.pro1
-rw-r--r--tests/auto/qdoc/qdoccommandlineparser/qdoccommandlineparser.pro11
-rw-r--r--tests/auto/qdoc/qdoccommandlineparser/tst_arguments.txt22
-rw-r--r--tests/auto/qdoc/qdoccommandlineparser/tst_qdoccommandlineparser.cpp191
4 files changed, 225 insertions, 0 deletions
diff --git a/tests/auto/qdoc/qdoc.pro b/tests/auto/qdoc/qdoc.pro
index 74c6e7787..bb63be1f9 100644
--- a/tests/auto/qdoc/qdoc.pro
+++ b/tests/auto/qdoc/qdoc.pro
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
generatedoutput \
+ qdoccommandlineparser \
qdocglobals
diff --git a/tests/auto/qdoc/qdoccommandlineparser/qdoccommandlineparser.pro b/tests/auto/qdoc/qdoccommandlineparser/qdoccommandlineparser.pro
new file mode 100644
index 000000000..c84a38bc5
--- /dev/null
+++ b/tests/auto/qdoc/qdoccommandlineparser/qdoccommandlineparser.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+QT = core testlib
+TARGET = tst_qdoccommandlineparser
+INCLUDEPATH += $$PWD/../../../../src/qdoc
+
+HEADERS += \
+ $$PWD/../../../../src/qdoc/qdoccommandlineparser.h
+
+SOURCES += \
+ $$PWD/../../../../src/qdoc/qdoccommandlineparser.cpp \
+ tst_qdoccommandlineparser.cpp
diff --git a/tests/auto/qdoc/qdoccommandlineparser/tst_arguments.txt b/tests/auto/qdoc/qdoccommandlineparser/tst_arguments.txt
new file mode 100644
index 000000000..5797de394
--- /dev/null
+++ b/tests/auto/qdoc/qdoccommandlineparser/tst_arguments.txt
@@ -0,0 +1,22 @@
+-outputdir
+/src/qt5/qtbase/doc/qtgamepad
+-installdir
+/src/qt5/qtbase/doc
+/src/qt5/qtgamepad/src/gamepad/doc/qtgamepad.qdocconf
+-prepare
+-indexdir
+/src/qt5/qtbase/doc
+-no-link-errors
+-I.
+-I/src/qt5/qtbase/include
+-I/src/qt5/qtbase/include/QtGamepad
+-I/src/qt5/qtbase/include/QtGamepad/5.14.0
+-I/src/qt5/qtbase/include/QtGamepad/5.14.0/QtGamepad
+-I/src/qt5/qtbase/include/QtCore/5.14.0
+-I/src/qt5/qtbase/include/QtCore/5.14.0/QtCore
+-I/src/qt5/qtbase/include/QtGui
+-I/src/qt5/qtbase/include/QtCore
+-I.moc
+-isystem
+/usr/include/libdrm
+-I/src/qt5/qtbase/mkspecs/linux-g++
diff --git a/tests/auto/qdoc/qdoccommandlineparser/tst_qdoccommandlineparser.cpp b/tests/auto/qdoc/qdoccommandlineparser/tst_qdoccommandlineparser.cpp
new file mode 100644
index 000000000..d5e8483a1
--- /dev/null
+++ b/tests/auto/qdoc/qdoccommandlineparser/tst_qdoccommandlineparser.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "qdoccommandlineparser.h"
+
+#include <QtCore/qstringlist.h>
+#include <QtTest/QtTest>
+
+class tst_QDocCommandLineParser : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void defaultConstructor();
+ void process();
+ void argumentsFromCommandLineAndFile();
+};
+
+void tst_QDocCommandLineParser::defaultConstructor()
+{
+ QDocCommandLineParser parser;
+
+ QVERIFY2(parser.applicationDescription() == QStringLiteral("Qt documentation generator"),
+ "The application description is incorrect.");
+}
+
+void tst_QDocCommandLineParser::process()
+{
+ const QStringList arguments =
+ QStringLiteral("/src/qt5/qtbase/bin/qdoc "
+ "-outputdir "
+ "/src/qt5/qtbase/doc/qtgamepad "
+ "-installdir "
+ "/src/qt5/qtbase/doc "
+ "/src/qt5/qtgamepad/src/gamepad/doc/qtgamepad.qdocconf "
+ "-prepare "
+ "-indexdir "
+ "/src/qt5/qtbase/doc "
+ "-no-link-errors "
+ "-I. "
+ "-I/src/qt5/qtbase/include "
+ "-I/src/qt5/qtbase/include/QtGamepad "
+ "-I/src/qt5/qtbase/include/QtGamepad/5.14.0 "
+ "-I/src/qt5/qtbase/include/QtGamepad/5.14.0/QtGamepad "
+ "-I/src/qt5/qtbase/include/QtCore/5.14.0 "
+ "-I/src/qt5/qtbase/include/QtCore/5.14.0/QtCore "
+ "-I/src/qt5/qtbase/include/QtGui "
+ "-I/src/qt5/qtbase/include/QtCore "
+ "-I.moc "
+ "-isystem "
+ "/usr/include/libdrm "
+ "-I/src/qt5/qtbase/mkspecs/linux-g++"
+ ).split(QString(" "));
+ const QStringList expectedIncludePaths =
+ QStringLiteral(". "
+ "/src/qt5/qtbase/include "
+ "/src/qt5/qtbase/include/QtGamepad "
+ "/src/qt5/qtbase/include/QtGamepad/5.14.0 "
+ "/src/qt5/qtbase/include/QtGamepad/5.14.0/QtGamepad "
+ "/src/qt5/qtbase/include/QtCore/5.14.0 "
+ "/src/qt5/qtbase/include/QtCore/5.14.0/QtCore "
+ "/src/qt5/qtbase/include/QtGui "
+ "/src/qt5/qtbase/include/QtCore "
+ ".moc "
+ "/src/qt5/qtbase/mkspecs/linux-g++"
+ ).split(QString(" "));
+ const QStringList expectedSystemIncludePath(QStringLiteral("/usr/include/libdrm"));
+
+ QDocCommandLineParser parser;
+ parser.process(arguments);
+
+ QVERIFY(parser.isSet(parser.outputDirOption));
+ QCOMPARE(parser.value(parser.outputDirOption), QStringLiteral("/src/qt5/qtbase/doc/qtgamepad"));
+ QVERIFY(parser.isSet(parser.installDirOption));
+ QCOMPARE(parser.value(parser.installDirOption), QStringLiteral("/src/qt5/qtbase/doc"));
+ QVERIFY(parser.isSet(parser.prepareOption));
+ QVERIFY(parser.isSet(parser.indexDirOption));
+ QCOMPARE(parser.value(parser.indexDirOption), QStringLiteral("/src/qt5/qtbase/doc"));
+ QVERIFY(parser.isSet(parser.noLinkErrorsOption));
+ QVERIFY(parser.isSet(parser.includePathOption));
+ QCOMPARE(parser.values(parser.includePathOption), expectedIncludePaths);
+ QVERIFY(parser.isSet(parser.includePathSystemOption));
+ QCOMPARE(parser.values(parser.includePathSystemOption), expectedSystemIncludePath);
+
+ QVERIFY(!parser.isSet(parser.timestampsOption));
+ QVERIFY(!parser.isSet(parser.dependsOption));
+ QVERIFY(!parser.isSet(parser.highlightingOption));
+ QVERIFY(!parser.isSet(parser.showInternalOption));
+ QVERIFY(!parser.isSet(parser.redirectDocumentationToDevNullOption));
+ QVERIFY(!parser.isSet(parser.noExamplesOption));
+ QVERIFY(!parser.isSet(parser.obsoleteLinksOption));
+ QVERIFY(!parser.isSet(parser.autoLinkErrorsOption));
+ QVERIFY(!parser.isSet(parser.debugOption));
+ QVERIFY(!parser.isSet(parser.generateOption));
+ QVERIFY(!parser.isSet(parser.logProgressOption));
+ QVERIFY(!parser.isSet(parser.singleExecOption));
+ QVERIFY(!parser.isSet(parser.writeQaPagesOption));
+ QVERIFY(!parser.isSet(parser.frameworkOption));
+
+ const QStringList expectedPositionalArgument = {
+ QStringLiteral("/src/qt5/qtgamepad/src/gamepad/doc/qtgamepad.qdocconf")
+ };
+ QCOMPARE(parser.positionalArguments(), expectedPositionalArgument);
+}
+
+void tst_QDocCommandLineParser::argumentsFromCommandLineAndFile()
+{
+ const QStringList arguments =
+ QStringLiteral("/src/qt5/qtbase/bin/qdoc "
+ "@tst_arguments.txt").split(" ");
+
+ QDocCommandLineParser parser;
+ parser.process(arguments);
+
+ const QStringList expectedIncludePaths =
+ QStringLiteral(". "
+ "/src/qt5/qtbase/include "
+ "/src/qt5/qtbase/include/QtGamepad "
+ "/src/qt5/qtbase/include/QtGamepad/5.14.0 "
+ "/src/qt5/qtbase/include/QtGamepad/5.14.0/QtGamepad "
+ "/src/qt5/qtbase/include/QtCore/5.14.0 "
+ "/src/qt5/qtbase/include/QtCore/5.14.0/QtCore "
+ "/src/qt5/qtbase/include/QtGui "
+ "/src/qt5/qtbase/include/QtCore "
+ ".moc "
+ "/src/qt5/qtbase/mkspecs/linux-g++"
+ ).split(QString(" "));
+ const QStringList expectedSystemIncludePath(QStringLiteral("/usr/include/libdrm"));
+ const QStringList expectedPositionalArgument = {
+ QStringLiteral("/src/qt5/qtgamepad/src/gamepad/doc/qtgamepad.qdocconf")
+ };
+
+ QVERIFY(parser.isSet(parser.outputDirOption));
+ QCOMPARE(parser.value(parser.outputDirOption), QStringLiteral("/src/qt5/qtbase/doc/qtgamepad"));
+ QVERIFY(parser.isSet(parser.installDirOption));
+ QCOMPARE(parser.value(parser.installDirOption), QStringLiteral("/src/qt5/qtbase/doc"));
+ QVERIFY(parser.isSet(parser.prepareOption));
+ QVERIFY(parser.isSet(parser.indexDirOption));
+ QCOMPARE(parser.value(parser.indexDirOption), QStringLiteral("/src/qt5/qtbase/doc"));
+ QVERIFY(parser.isSet(parser.noLinkErrorsOption));
+ QVERIFY(parser.isSet(parser.includePathOption));
+ QCOMPARE(parser.values(parser.includePathOption), expectedIncludePaths);
+ QVERIFY(parser.isSet(parser.includePathSystemOption));
+ QCOMPARE(parser.values(parser.includePathSystemOption), expectedSystemIncludePath);
+
+ QVERIFY(!parser.isSet(parser.timestampsOption));
+ QVERIFY(!parser.isSet(parser.dependsOption));
+ QVERIFY(!parser.isSet(parser.highlightingOption));
+ QVERIFY(!parser.isSet(parser.showInternalOption));
+ QVERIFY(!parser.isSet(parser.redirectDocumentationToDevNullOption));
+ QVERIFY(!parser.isSet(parser.noExamplesOption));
+ QVERIFY(!parser.isSet(parser.obsoleteLinksOption));
+ QVERIFY(!parser.isSet(parser.autoLinkErrorsOption));
+ QVERIFY(!parser.isSet(parser.debugOption));
+ QVERIFY(!parser.isSet(parser.generateOption));
+ QVERIFY(!parser.isSet(parser.logProgressOption));
+ QVERIFY(!parser.isSet(parser.singleExecOption));
+ QVERIFY(!parser.isSet(parser.writeQaPagesOption));
+ QVERIFY(!parser.isSet(parser.frameworkOption));
+
+ QCOMPARE(parser.positionalArguments(), expectedPositionalArgument);
+}
+
+QTEST_APPLESS_MAIN(tst_QDocCommandLineParser)
+
+#include "tst_qdoccommandlineparser.moc"