diff options
Diffstat (limited to 'tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp')
-rw-r--r-- | tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp | 202 |
1 files changed, 167 insertions, 35 deletions
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index 3fa2c954f..b3c69af71 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,46 @@ 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(); - void examplesManifestXml(); + // DocBook generator + void docBookFromQDocFile(); + void docBookFromCpp(); + void docBookFromQml(); + + // Output format independent tests + void examplesManifestXmlAndQhp(); + void ignoresinceVariable(); + void templateParameters(); + void scopedEnum(); + void dontDocument(); void inheritedQmlPropertyGroups(); + void crossModuleLinking(); void includeFromExampleDirs(); + void singleExec(); + void preparePhase(); + void generatePhase(); + void noAutoList(); 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 +93,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 +121,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 +144,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,17 +170,30 @@ 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() { - testAndCompare("test.qdocconf", + testAndCompare("testdata/configs/test.qdocconf", "qdoctests-qdocfileoutput.html " "qdoctests-qdocfileoutput-linking.html"); } void tst_generatedOutput::htmlFromCpp() { - testAndCompare("testcpp.qdocconf", + testAndCompare("testdata/configs/testcpp.qdocconf", "testcpp-module.html " "testqdoc-test.html " "testqdoc-test-members.html " @@ -184,8 +202,9 @@ void tst_generatedOutput::htmlFromCpp() void tst_generatedOutput::htmlFromQml() { - testAndCompare("testqml.qdocconf", + testAndCompare("testdata/configs/testqml.qdocconf", "test-componentset-example.html " + "test-cmaketest-example.html " "uicomponents-qmlmodule.html " "qdoc-test-qmlmodule.html " "qml-qdoc-test-abstractparent.html " @@ -201,7 +220,7 @@ void tst_generatedOutput::htmlFromQml() void tst_generatedOutput::htmlFromCppBug80259() { - testAndCompare("bug80259/testmodule.qdocconf", + testAndCompare("testdata/bug80259/testmodule.qdocconf", "first.html " "second.html " "third.html " @@ -210,55 +229,168 @@ void tst_generatedOutput::htmlFromCppBug80259() void tst_generatedOutput::webXmlFromQDocFile() { - testAndCompare("webxml_test.qdocconf", + testAndCompare("testdata/configs/webxml_test.qdocconf", "html/qdoctests-qdocfileoutput.webxml " "html/qdoctests-qdocfileoutput-linking.webxml"); } void tst_generatedOutput::webXmlFromCpp() { - testAndCompare("webxml_testcpp.qdocconf", + testAndCompare("testdata/configs/webxml_testcpp.qdocconf", "html/testcpp-module.webxml " "html/testqdoc-test.webxml " "html/testqdoc-testderived.webxml"); } - void tst_generatedOutput::webXmlFromQml() { - testAndCompare("webxml_testqml.qdocconf", + testAndCompare("testdata/configs/webxml_testqml.qdocconf", "html/test-componentset-example.webxml " "html/uicomponents-qmlmodule.webxml"); } void tst_generatedOutput::webXmlFromCppBug80259() { - testAndCompare("bug80259/webxml_testmodule.qdocconf", + testAndCompare("testdata/bug80259/webxml_testmodule.qdocconf", "html/first.webxml " "html/second.webxml " "html/third.webxml " "html/index.webxml"); } -void tst_generatedOutput::examplesManifestXml() +void tst_generatedOutput::docBookFromQDocFile() +{ + testAndCompare("testdata/configs/docbook_test.qdocconf", + "docbook/qdoctests-qdocfileoutput.xml " + "docbook/qdoctests-qdocfileoutput-linking.xml"); +} + +void tst_generatedOutput::docBookFromCpp() +{ + testAndCompare("testdata/configs/docbook_testcpp.qdocconf", + "docbook/testcpp-module.xml " + "docbook/testqdoc-test.xml " + "docbook/testqdoc-testderived.xml " + "docbook/testqdoc.xml"); +} + +void tst_generatedOutput::docBookFromQml() +{ + testAndCompare("testdata/configs/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::examplesManifestXmlAndQhp() +{ + testAndCompare("testdata/configs/examples-qhp.qdocconf", + "examples-manifest.xml " + "test.qhp"); +} + +void tst_generatedOutput::ignoresinceVariable() +{ + testAndCompare("testdata/configs/ignoresince.qdocconf", + "ignoresince/testqdoc.html " + "ignoresince/testqdoc-test.html"); +} + +void tst_generatedOutput::templateParameters() +{ + testAndCompare("testdata/configs/testtemplate.qdocconf", + "template/testqdoc-test.html " + "template/foo.html " + "template/bar.html " + "template/baz.html"); +} + +void tst_generatedOutput::scopedEnum() { - testAndCompare("examples-qhp.qdocconf", - "examples-manifest.xml"); + testAndCompare("testdata/configs/scopedenum.qdocconf", "scopedenum/testqdoc-test.html"); +} + +void tst_generatedOutput::dontDocument() +{ + testAndCompare("testdata/dontdocument/dontdocument.qdocconf", + "dontdocument/classes.html " + "dontdocument/seenclass.html"); } void tst_generatedOutput::inheritedQmlPropertyGroups() { - testAndCompare("qmlpropertygroups/qmlpropertygroups.qdocconf", + testAndCompare("testdata/qmlpropertygroups/qmlpropertygroups.qdocconf", "qmlpropertygroups/qml-qdoc-test-anotherchild-members.html"); } +void tst_generatedOutput::crossModuleLinking() +{ + htmlFromCpp(); + copyIndexFiles(); + QString indexDir = QLatin1String("-indexdir ") + m_outputDir->path(); + testAndCompare("testdata/crossmodule/crossmodule.qdocconf", + "crossmodule/testtype.html " + "crossmodule/testtype-members.html", + indexDir.toLatin1().data()); +} + void tst_generatedOutput::includeFromExampleDirs() { - testAndCompare("includefromexampledirs/includefromexampledirs.qdocconf", + testAndCompare("testdata/includefromexampledirs/includefromexampledirs.qdocconf", "includefromexampledirs/index.html " "includefromexampledirs/qml-qdoc-test-abstractparent.html " "includefromexampledirs/qml-qdoc-test-abstractparent-members.html"); } + +void tst_generatedOutput::singleExec() +{ + // Build both testcpp and crossmodule projects in single-exec mode + testAndCompare("testdata/singleexec/singleexec.qdocconf", + "testcpp-module.html " + "testqdoc-test.html " + "testqdoc-test-members.html " + "testqdoc.html " + "crossmodule/testtype.html " + "crossmodule/testtype-members.html", + "-single-exec"); +} + +void tst_generatedOutput::preparePhase() +{ + testAndCompare("testdata/configs/testcpp.qdocconf", + "testcpp.index", + "-prepare"); +} + +void tst_generatedOutput::generatePhase() +{ + testAndCompare("testdata/configs/testcpp.qdocconf", + "testcpp-module.html " + "testqdoc-test.html " + "testqdoc-test-members.html " + "testqdoc.html", + "-generate"); +} + +void tst_generatedOutput::noAutoList() +{ + testAndCompare("testdata/configs/noautolist.qdocconf", + "noautolist/testcpp-module.html " + "noautolist/test-componentset-example.html " + "noautolist/qdoc-test-qmlmodule.html " + "noautolist-docbook/testcpp-module.xml " + "noautolist-docbook/test-componentset-example.xml " + "noautolist-docbook/qdoc-test-qmlmodule.xml"); +} + QTEST_APPLESS_MAIN(tst_generatedOutput) #include "tst_generatedoutput.moc" |