diff options
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/a.xml | 13 | ||||
-rw-r--r-- | tests/testmodifydocumentation.cpp | 66 | ||||
-rw-r--r-- | tests/testmodifydocumentation.h | 36 |
4 files changed, 116 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index adfb5865e..43a4d51e3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,3 +10,4 @@ endmacro(declare_test testname) declare_test(testabstractmetaclass) declare_test(testabstractmetatype) declare_test(testenum) +declare_test(testmodifydocumentation) diff --git a/tests/a.xml b/tests/a.xml new file mode 100644 index 000000000..1c6d62a17 --- /dev/null +++ b/tests/a.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" ?> + +<WebXML> + <document> + <class name="A"> + <description>oi + <para>Paragraph number 1</para> + <para>Paragraph number 2</para> + <para>Paragraph number 3</para> + </description> + </class> + </document> +</WebXML> diff --git a/tests/testmodifydocumentation.cpp b/tests/testmodifydocumentation.cpp new file mode 100644 index 000000000..5a9e2c386 --- /dev/null +++ b/tests/testmodifydocumentation.cpp @@ -0,0 +1,66 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +* +* Contact: PySide team <contact@pyside.org> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#include "testmodifydocumentation.h" + +#include <QtTest/QTest> +#include "testutil.h" +#include <qtdocparser.h> + +void TestModifyDocumentation::testModifyDocumentation() +{ + const char* cppCode ="struct B { void b(); }; class A {};"; + const char* xmlCode = "<typesystem package=\"Foo\">\ + <value-type name='B'>\ + <modify-function signature='b()' remove='all' />\ + </value-type>\ + <value-type name='A'>\ + <modify-documentation xpath='description/para[3]'>\ + <para>Some changed contents here</para>\ + </modify-documentation>\ + </value-type>\ + </typesystem>"; + TestUtil t(cppCode, xmlCode); + + AbstractMetaClass* classA = t.builder()->classes().findClass("A"); + QVERIFY(classA); + DocModificationList docMods = classA->typeEntry()->docModifications(); + QCOMPARE(docMods.count(), 1); + QCOMPARE(docMods[0].code().trimmed(), QString("<para>Some changed contents here</para>")); + QCOMPARE(docMods[0].signature(), QString("")); + QtDocParser docParser; + docParser.setDocumentationDataDirectory(QFileInfo(__FILE__).absoluteDir().absolutePath()); + docParser.fillDocumentation(classA); + + QVERIFY(!classA->documentation().value().trimmed().isEmpty()); + QCOMPARE(classA->documentation().value(), QString("<?xml version=\"1.0\"?>\n\ +<description>oi\n\ + <para>Paragraph number 1</para>\n\ + <para>Paragraph number 2</para>\n\ + <para>Some changed contents here</para>\n\ +</description>\n")); +} + +QTEST_MAIN(TestModifyDocumentation) + +#include "testmodifydocumentation.moc" diff --git a/tests/testmodifydocumentation.h b/tests/testmodifydocumentation.h new file mode 100644 index 000000000..14bb0c69d --- /dev/null +++ b/tests/testmodifydocumentation.h @@ -0,0 +1,36 @@ +/* +* This file is part of the API Extractor project. +* +* Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +* +* Contact: PySide team <contact@pyside.org> +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA +* +*/ + +#ifndef TESTMODIFYDOCUMENTATION_H +#define TESTMODIFYDOCUMENTATION_H + +#include <QObject> + +class TestModifyDocumentation : public QObject +{ +Q_OBJECT +private slots: + void testModifyDocumentation(); +}; + +#endif |