diff options
Diffstat (limited to 'tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp')
-rw-r--r-- | tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp | 247 |
1 files changed, 234 insertions, 13 deletions
diff --git a/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp b/tests/auto/qdoc/generatedoutput/tst_generatedoutput.cpp index 09709ac6c..5449a50e2 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,9 +38,35 @@ 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 examplesManifestXmlAndQhp(); + void ignoresinceVariable(); + void templateParameters(); + void scopedEnum(); + void dontDocument(); + void inheritedQmlPropertyGroups(); + void crossModuleLinking(); + void includeFromExampleDirs(); + void singleExec(); + void preparePhase(); + void generatePhase(); private: QScopedPointer<QTemporaryDir> m_outputDir; @@ -47,9 +74,9 @@ private: 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() @@ -65,7 +92,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)); } } @@ -121,29 +148,51 @@ void tst_generatedOutput::compareLineByLine(const QStringList &expectedFiles) } } -void tst_generatedOutput::testAndCompare(const char *input, - const char *outNames, - const char *extraParams) +void tst_generatedOutput::testAndCompare(const char *input, const char *outNames, + const char *extraParams, const char *outputPathPrefix) { - QStringList args{ "-outputdir", m_outputDir->path(), QFINDTESTDATA(input) }; + QStringList args { "-outputdir", m_outputDir->path() + "/" + outputPathPrefix, + QFINDTESTDATA(input) }; if (extraParams) args << QString(QLatin1String(extraParams)).split(QChar(' ')); + runQDocProcess(args); + if (QTest::currentTestFailed()) return; - compareLineByLine(QString(QLatin1String(outNames)).split(QChar(' '))); + + QStringList expectedOuts(QString(QLatin1String(outNames)).split(QChar(' '))); + if (outputPathPrefix) + for (auto &expectedOut : expectedOuts) + expectedOut = QString(outputPathPrefix) + "/" + expectedOut; + + 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 " @@ -152,9 +201,181 @@ void tst_generatedOutput::htmlFromCpp() void tst_generatedOutput::htmlFromQml() { - testAndCompare("testqml.qdocconf", + testAndCompare("testdata/configs/testqml.qdocconf", "test-componentset-example.html " - "uicomponents-qmlmodule.html"); + "uicomponents-qmlmodule.html " + "qdoc-test-qmlmodule.html " + "qml-qdoc-test-abstractparent.html " + "qml-qdoc-test-child.html " + "qml-qdoc-test-doctest.html " + "qml-qdoc-test-type-members.html " + "qml-qdoc-test-type.html " + "qml-uicomponents-progressbar.html " + "qml-uicomponents-switch.html " + "qml-uicomponents-tabwidget.html " + "qml-int.html"); +} + +void tst_generatedOutput::htmlFromCppBug80259() +{ + testAndCompare("testdata/bug80259/testmodule.qdocconf", + "first.html " + "second.html " + "third.html " + "index.html"); +} + +void tst_generatedOutput::webXmlFromQDocFile() +{ + testAndCompare("testdata/configs/webxml_test.qdocconf", + "html/qdoctests-qdocfileoutput.webxml " + "html/qdoctests-qdocfileoutput-linking.webxml"); +} + +void tst_generatedOutput::webXmlFromCpp() +{ + testAndCompare("testdata/configs/webxml_testcpp.qdocconf", + "html/testcpp-module.webxml " + "html/testqdoc-test.webxml " + "html/testqdoc-testderived.webxml"); +} + +void tst_generatedOutput::webXmlFromQml() +{ + testAndCompare("testdata/configs/webxml_testqml.qdocconf", + "html/test-componentset-example.webxml " + "html/uicomponents-qmlmodule.webxml"); +} + +void tst_generatedOutput::webXmlFromCppBug80259() +{ + testAndCompare("testdata/bug80259/webxml_testmodule.qdocconf", + "html/first.webxml " + "html/second.webxml " + "html/third.webxml " + "html/index.webxml"); +} + +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("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("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("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"); } QTEST_APPLESS_MAIN(tst_generatedOutput) |