summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp')
-rw-r--r--tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp130
1 files changed, 107 insertions, 23 deletions
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
index 3fa2c954f..4cab6a8fd 100644
--- a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
+++ b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include <QProcess>
#include <QTemporaryDir>
+#include <QDirIterator>
#include <QtTest>
class tst_generatedOutput : public QObject
@@ -37,31 +38,42 @@ private slots:
void initTestCase();
void init();
+ // HTML generator
void htmlFromQDocFile();
void htmlFromCpp();
void htmlFromQml();
void htmlFromCppBug80259();
+ // WebXML generator
void webXmlFromQDocFile();
void webXmlFromCpp();
void webXmlFromQml();
void webXmlFromCppBug80259();
+ // DocBook generator
+ void docBookFromQDocFile();
+ void docBookFromCpp();
+ void docBookFromQml();
+
+ // Output format independent tests
void examplesManifestXml();
+ void ignoresinceVariable();
+ void templateParameters();
+ void scopedEnum();
+ void dontDocument();
void inheritedQmlPropertyGroups();
+ void crossModuleLinking();
void includeFromExampleDirs();
private:
QScopedPointer<QTemporaryDir> m_outputDir;
QString m_qdoc;
- void removeFullPathStrings(QString& str);
void runQDocProcess(const QStringList &arguments);
void compareLineByLine(const QStringList &expectedFiles);
- void testAndCompare(const char *input,
- const char *outNames,
- const char *extraParams = nullptr,
+ void testAndCompare(const char *input, const char *outNames, const char *extraParams = nullptr,
const char *outputPathPrefix = nullptr);
+ void copyIndexFiles();
};
void tst_generatedOutput::initTestCase()
@@ -77,7 +89,7 @@ void tst_generatedOutput::init()
m_outputDir.reset(new QTemporaryDir());
if (!m_outputDir->isValid()) {
const QString errorMessage =
- "Couldn't create temporary directory: " + m_outputDir->errorString();
+ "Couldn't create temporary directory: " + m_outputDir->errorString();
QFAIL(qPrintable(errorMessage));
}
}
@@ -105,13 +117,6 @@ void tst_generatedOutput::runQDocProcess(const QStringList &arguments)
QFAIL("Running QDoc failed. See output above.");
}
-void tst_generatedOutput::removeFullPathStrings(QString &str)
-{
- QRegularExpression re("(location|path|filepath)=\"[^\"]+\"");
- QRegularExpressionMatch match = re.match(str);
- str.replace(re, match.captured(1) + "=\"REMOVED_BY_TEST\"");
-}
-
void tst_generatedOutput::compareLineByLine(const QStringList &expectedFiles)
{
for (const auto &file : expectedFiles) {
@@ -135,20 +140,16 @@ void tst_generatedOutput::compareLineByLine(const QStringList &expectedFiles)
QString prefix = file + delim + QString::number(lineNumber) + delim;
QString expectedLine = prefix + expectedIn.readLine();
QString actualLine = prefix + actualIn.readLine();
- removeFullPathStrings(actualLine);
- removeFullPathStrings(expectedLine);
QCOMPARE(actualLine, expectedLine);
}
}
}
-void tst_generatedOutput::testAndCompare(const char *input,
- const char *outNames,
- const char *extraParams,
- const char *outputPathPrefix)
+void tst_generatedOutput::testAndCompare(const char *input, const char *outNames,
+ const char *extraParams, const char *outputPathPrefix)
{
- QStringList args{ "-outputdir", m_outputDir->path() + "/" + outputPathPrefix,
- QFINDTESTDATA(input) };
+ QStringList args { "-outputdir", m_outputDir->path() + "/" + outputPathPrefix,
+ QFINDTESTDATA(input) };
if (extraParams)
args << QString(QLatin1String(extraParams)).split(QChar(' '));
@@ -165,6 +166,19 @@ void tst_generatedOutput::testAndCompare(const char *input,
compareLineByLine(expectedOuts);
}
+// Copy <project>.index to <project>/<project>.index in the outputdir
+void tst_generatedOutput::copyIndexFiles()
+{
+ QDirIterator it(m_outputDir->path(), QStringList("*.index"), QDir::Files, QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ QFileInfo fileInfo(it.next());
+ QDir indexDir(m_outputDir->path());
+ QVERIFY(indexDir.mkpath(fileInfo.baseName()));
+ QVERIFY(indexDir.cd(fileInfo.baseName()));
+ if (!indexDir.exists(fileInfo.fileName()))
+ QVERIFY(QFile::copy(fileInfo.filePath(), indexDir.filePath(fileInfo.fileName())));
+ }
+}
void tst_generatedOutput::htmlFromQDocFile()
{
@@ -223,7 +237,6 @@ void tst_generatedOutput::webXmlFromCpp()
"html/testqdoc-testderived.webxml");
}
-
void tst_generatedOutput::webXmlFromQml()
{
testAndCompare("webxml_testqml.qdocconf",
@@ -240,10 +253,69 @@ void tst_generatedOutput::webXmlFromCppBug80259()
"html/index.webxml");
}
+void tst_generatedOutput::docBookFromQDocFile()
+{
+ testAndCompare("docbook_test.qdocconf",
+ "docbook/qdoctests-qdocfileoutput.xml "
+ "docbook/qdoctests-qdocfileoutput-linking.xml");
+}
+
+void tst_generatedOutput::docBookFromCpp()
+{
+ testAndCompare("docbook_testcpp.qdocconf",
+ "docbook/testcpp-module.xml "
+ "docbook/testqdoc-test.xml "
+ "docbook/testqdoc-testderived.xml "
+ "docbook/testqdoc.xml");
+}
+
+void tst_generatedOutput::docBookFromQml()
+{
+ testAndCompare("docbook_testqml.qdocconf",
+ "docbook/test-componentset-example.xml "
+ "docbook/uicomponents-qmlmodule.xml "
+ "docbook/qdoc-test-qmlmodule.xml "
+ "docbook/qml-qdoc-test-abstractparent.xml "
+ "docbook/qml-qdoc-test-child.xml "
+ "docbook/qml-qdoc-test-doctest.xml "
+ "docbook/qml-qdoc-test-type.xml "
+ "docbook/qml-uicomponents-progressbar.xml "
+ "docbook/qml-uicomponents-switch.xml "
+ "docbook/qml-uicomponents-tabwidget.xml "
+ "docbook/qml-int.xml");
+}
+
void tst_generatedOutput::examplesManifestXml()
{
- testAndCompare("examples-qhp.qdocconf",
- "examples-manifest.xml");
+ testAndCompare("examples-qhp.qdocconf", "examples-manifest.xml");
+}
+
+void tst_generatedOutput::ignoresinceVariable()
+{
+ testAndCompare("ignoresince.qdocconf",
+ "ignoresince/testqdoc.html "
+ "ignoresince/testqdoc-test.html");
+}
+
+void tst_generatedOutput::templateParameters()
+{
+ testAndCompare("testtemplate.qdocconf",
+ "template/testqdoc-test.html "
+ "template/foo.html "
+ "template/bar.html "
+ "template/baz.html");
+}
+
+void tst_generatedOutput::scopedEnum()
+{
+ testAndCompare("scopedenum.qdocconf", "scopedenum/testqdoc-test.html");
+}
+
+void tst_generatedOutput::dontDocument()
+{
+ testAndCompare("dontdocument/dontdocument.qdocconf",
+ "dontdocument/classes.html "
+ "dontdocument/seenclass.html");
}
void tst_generatedOutput::inheritedQmlPropertyGroups()
@@ -252,6 +324,17 @@ void tst_generatedOutput::inheritedQmlPropertyGroups()
"qmlpropertygroups/qml-qdoc-test-anotherchild-members.html");
}
+void tst_generatedOutput::crossModuleLinking()
+{
+ htmlFromCpp();
+ copyIndexFiles();
+ QString indexDir = QLatin1String("-indexdir ") + m_outputDir->path();
+ testAndCompare("crossmodule/crossmodule.qdocconf",
+ "crossmodule/testtype.html "
+ "crossmodule/testtype-members.html",
+ indexDir.toLatin1().data());
+}
+
void tst_generatedOutput::includeFromExampleDirs()
{
testAndCompare("includefromexampledirs/includefromexampledirs.qdocconf",
@@ -259,6 +342,7 @@ void tst_generatedOutput::includeFromExampleDirs()
"includefromexampledirs/qml-qdoc-test-abstractparent.html "
"includefromexampledirs/qml-qdoc-test-abstractparent-members.html");
}
+
QTEST_APPLESS_MAIN(tst_generatedOutput)
#include "tst_generatedoutput.moc"