diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:34:13 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:34:13 (GMT) |
commit | 67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch) | |
tree | 1dbf50b3dff8d5ca7e9344733968c72704eb15ff /tests/auto/qhelpgenerator | |
download | Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2 |
Long live Qt!
Diffstat (limited to 'tests/auto/qhelpgenerator')
-rw-r--r-- | tests/auto/qhelpgenerator/.gitignore | 1 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/cars.html | 11 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/classic.css | 92 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/fancy.html | 11 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/people.html | 11 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/sub/about.html | 11 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/test.html | 11 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/data/test.qhp | 72 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/qhelpgenerator.pro | 10 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp | 218 | ||||
-rw-r--r-- | tests/auto/qhelpgenerator/tst_qhelpgenerator.pro | 9 |
11 files changed, 457 insertions, 0 deletions
diff --git a/tests/auto/qhelpgenerator/.gitignore b/tests/auto/qhelpgenerator/.gitignore new file mode 100644 index 0000000..5accdd5 --- /dev/null +++ b/tests/auto/qhelpgenerator/.gitignore @@ -0,0 +1 @@ +tst_qhelpgenerator diff --git a/tests/auto/qhelpgenerator/data/cars.html b/tests/auto/qhelpgenerator/data/cars.html new file mode 100644 index 0000000..385723c --- /dev/null +++ b/tests/auto/qhelpgenerator/data/cars.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Cars</title> + <link href="classic.css" rel="stylesheet" type="text/css" /> +</head> +<body> +</body> +</html> diff --git a/tests/auto/qhelpgenerator/data/classic.css b/tests/auto/qhelpgenerator/data/classic.css new file mode 100644 index 0000000..9113540 --- /dev/null +++ b/tests/auto/qhelpgenerator/data/classic.css @@ -0,0 +1,92 @@ +h3.fn,span.fn +{ + margin-left: 1cm; + text-indent: -1cm; +} + +a:link +{ + color: #004faf; + text-decoration: none +} + +a:visited +{ + color: #672967; + text-decoration: none +} + +td.postheader +{ + font-family: sans-serif +} + +tr.address +{ + font-family: sans-serif +} + +body +{ + background: #ffffff; + color: black +} + +table tr.odd { + background: #f0f0f0; + color: black; +} + +table tr.even { + background: #e4e4e4; + color: black; +} + +table.annotated th { + padding: 3px; + text-align: left +} + +table.annotated td { + padding: 3px; +} + +table tr pre +{ + padding-top: none; + padding-bottom: none; + padding-left: none; + padding-right: none; + border: none; + background: none +} + +tr.qt-style +{ + background: #a2c511; + color: black +} + +body pre +{ + padding: 0.2em; + border: #e7e7e7 1px solid; + background: #f1f1f1; + color: black +} + +span.preprocessor, span.preprocessor a +{ + color: darkblue; +} + +span.comment +{ + color: darkred; + font-style: italic +} + +span.string,span.char +{ + color: darkgreen; +} diff --git a/tests/auto/qhelpgenerator/data/fancy.html b/tests/auto/qhelpgenerator/data/fancy.html new file mode 100644 index 0000000..7715e49 --- /dev/null +++ b/tests/auto/qhelpgenerator/data/fancy.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Fancy</title> + <link href="classic.css" rel="stylesheet" type="text/css" /> +</head> +<body> +</body> +</html> diff --git a/tests/auto/qhelpgenerator/data/people.html b/tests/auto/qhelpgenerator/data/people.html new file mode 100644 index 0000000..c745dc8 --- /dev/null +++ b/tests/auto/qhelpgenerator/data/people.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>People</title> + <link href="classic.css" rel="stylesheet" type="text/css" /> +</head> +<body> +</body> +</html> diff --git a/tests/auto/qhelpgenerator/data/sub/about.html b/tests/auto/qhelpgenerator/data/sub/about.html new file mode 100644 index 0000000..0bc0a3d --- /dev/null +++ b/tests/auto/qhelpgenerator/data/sub/about.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>About</title> + <link href="classic.css" rel="stylesheet" type="text/css" /> +</head> +<body> +</body> +</html> diff --git a/tests/auto/qhelpgenerator/data/test.html b/tests/auto/qhelpgenerator/data/test.html new file mode 100644 index 0000000..bf0e505 --- /dev/null +++ b/tests/auto/qhelpgenerator/data/test.html @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Test Manual</title> + <link href="classic.css" rel="stylesheet" type="text/css" /> +</head> +<body> +</body> +</html> diff --git a/tests/auto/qhelpgenerator/data/test.qhp b/tests/auto/qhelpgenerator/data/test.qhp new file mode 100644 index 0000000..e9ac7f2 --- /dev/null +++ b/tests/auto/qhelpgenerator/data/test.qhp @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<QtHelpProject version="1.0"> + <metaData name="author" value="Nokia Corporation and/or its subsidiary(-ies)" /> + <metaData name="language" value="en" /> + <virtualFolder>testFolder</virtualFolder> + <namespace>trolltech.com.1_0_0.test</namespace> + <customFilter name="Custom Filter 1"> + <filterAttribute>test</filterAttribute> + <filterAttribute>filter1</filterAttribute> + </customFilter> + <customFilter name="Custom Filter 2"> + <filterAttribute>test</filterAttribute> + <filterAttribute>filter2</filterAttribute> + </customFilter> + <filterSection> + <filterAttribute>test</filterAttribute> + <filterAttribute>filter1</filterAttribute> + <toc> + <section title="Test Manual" ref="test.html"> + <section title="Section 1" ref="test.html#section1"> + </section> + <section title="Section 2" ref="test.html#section2"> + </section> + <section title="Section 3" ref="test.html#section3"> + </section> + <section title="People" ref="people.html"> + </section> + <section title="About" ref="./sub/about.html"> + </section> + </section> + </toc> + <keywords> + <keyword name="foo" id="Test::foo" ref="test.html#foo"/> + <keyword name="bar" id="Test::bar" ref="test.html#bar"/> + <keyword name="bla" id="Test::bla" ref="test.html#bla"/> + <keyword name="einstein" id="People::einstein" ref="people.html#einstein"/> + <keyword name="newton" id="People::newton" ref="people.html#newton"/> + </keywords> + <files> + <file>classic.css</file> + <file>test.html</file> + <file>people.html</file> + <file>./sub/about.html</file> + </files> + </filterSection> + <filterSection> + <filterAttribute>test</filterAttribute> + <filterAttribute>filter2</filterAttribute> + <toc> + <section title="Fancy Manual" ref="fancy.html"> + <section title="Section 1" ref="fancy.html#section1"> + </section> + <section title="Section 2" ref="fancy.html#section2"> + </section> + <section title="Section 3" ref="fancy.html#section3"> + </section> + <section title="Cars" ref="cars.html"> + </section> + </section> + </toc> + <keywords> + <keyword name="foo" id="Fancy::foo" ref="fancy.html#foo"/> + <keyword name="foobar" id="Fancy::foobar" ref="fancy.html#foobar"/> + <keyword name="audi" id="Cars::newton" ref="cars.html#audi"/> + </keywords> + <files> + <file>classic.css</file> + <file>fancy.html</file> + <file>cars.html</file> + </files> + </filterSection> +</QtHelpProject>
\ No newline at end of file diff --git a/tests/auto/qhelpgenerator/qhelpgenerator.pro b/tests/auto/qhelpgenerator/qhelpgenerator.pro new file mode 100644 index 0000000..efa1ef5 --- /dev/null +++ b/tests/auto/qhelpgenerator/qhelpgenerator.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +CONFIG += ordered + +contains(QT_BUILD_PARTS, tools): { + SUBDIRS += ../../../tools/assistant/lib/fulltextsearch \ + ../../../tools/assistant/lib +} + +SUBDIRS += tst_qhelpgenerator.pro + diff --git a/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp new file mode 100644 index 0000000..207fdbe --- /dev/null +++ b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> + +#ifndef QT_NO_BUILD_TOOLS + +#include <QtCore/QFileInfo> +#include <QtSql/QSqlDatabase> +#include <QtSql/QSqlQuery> + +#include <QtHelp/private/qhelpgenerator_p.h> +#include <QtHelp/private/qhelpprojectdata_p.h> + +class tst_QHelpGenerator : public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void generateHelp(); + +private: + void checkNamespace(); + void checkFilters(); + void checkIndices(); + void checkFiles(); + void checkMetaData(); + + QString m_outputFile; + QSqlQuery *m_query; +}; + +void tst_QHelpGenerator::initTestCase() +{ + QString path = QLatin1String(SRCDIR); + m_outputFile = path + QLatin1String("/data/test.qch"); + if (QFile::exists(m_outputFile)) { + QDir d; + if (!d.remove(m_outputFile)) + QFAIL("Cannot remove old output file!"); + } +} + +void tst_QHelpGenerator::generateHelp() +{ + // defined in profile + QString path = QLatin1String(SRCDIR); + + QString inputFile(path + "/data/test.qhp"); + QHelpProjectData data; + if (!data.readData(inputFile)) + QFAIL("Cannot read qthp file!"); + + QHelpGenerator generator; + QCOMPARE(generator.generate(&data, m_outputFile), true); + + { + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "testdb"); + db.setDatabaseName(m_outputFile); + if (!db.open()) { + QSqlDatabase::removeDatabase("testdb"); + QFAIL("Created database seems to be corrupt!"); + } + m_query = new QSqlQuery(db); + checkNamespace(); + checkFilters(); + checkIndices(); + checkFiles(); + checkMetaData(); + + m_query->clear(); + delete m_query; + } + QSqlDatabase::removeDatabase("testdb"); + + // check if db is still in use... + initTestCase(); +} + +void tst_QHelpGenerator::checkNamespace() +{ + m_query->exec("SELECT Id, Name FROM NamespaceTable"); + if (m_query->next() + && m_query->value(1).toString() == QLatin1String("trolltech.com.1_0_0.test")) + return; + QFAIL("Namespace Error!"); +} + +void tst_QHelpGenerator::checkFilters() +{ + m_query->exec("SELECT COUNT(Id) FROM FilterAttributeTable"); + if (!m_query->next() || m_query->value(0).toInt() != 3) + QFAIL("FilterAttribute Error!"); + + m_query->exec("SELECT a.Name FROM FilterAttributeTable a, FilterTable b, " + "FilterNameTable c WHERE c.Id=b.NameId AND b.FilterAttributeID=a.Id " + "AND c.Name=\'Custom Filter 2\'"); + QStringList lst; + while (m_query->next()) + lst.append(m_query->value(0).toString()); + if (!lst.contains("test") || !lst.contains("filter2")) + QFAIL("FilterAttribute Error!"); +} + +void tst_QHelpGenerator::checkIndices() +{ + m_query->exec("SELECT a.Name, b.Anchor FROM FileNameTable a, " + "IndexTable b, IndexFilterTable c, FilterAttributeTable d " + "WHERE a.FileID=b.FileId AND b.Id=c.IndexId " + "AND c.FilterAttributeId=d.Id AND d.Name=\'filter1\' AND b.Name=\'foo\'"); + if (!m_query->next() || m_query->value(0).toString() != QLatin1String("test.html") + || m_query->value(1).toString() != QLatin1String("foo")) + QFAIL("Index Error!"); + + /* + m_query->exec("SELECT COUNT(DISTINCT Id) FROM IndexItemTable"); + if (!m_query->next() || m_query->value(0).toInt() != 7) + QFAIL("Index Error!"); + */ + + m_query->exec("SELECT COUNT(a.Id) FROM IndexTable a, " + "IndexFilterTable b, FilterAttributeTable c WHERE a.Id=b.IndexId " + "AND b.FilterAttributeId=c.Id AND c.Name=\'filter2\'"); + if (!m_query->next() || m_query->value(0).toInt() != 3) + QFAIL("Index Error!"); +} + +void tst_QHelpGenerator::checkFiles() +{ + m_query->exec("SELECT COUNT(a.FileId) FROM FileNameTable a, FolderTable b " + "WHERE a.FolderId=b.Id AND b.Name=\'testFolder\'"); + if (!m_query->next() || m_query->value(0).toInt() != 6) + QFAIL("File Error!"); + + QStringList lst; + lst << "classic.css" << "test.html" << "people.html" << "sub/about.html"; + m_query->exec("SELECT a.Name FROM FileNameTable a, FileFilterTable b, " + "FilterAttributeTable c WHERE c.Id=b.FilterAttributeId " + "AND b.FileId=a.FileID AND c.Name=\'filter1\'"); + while (m_query->next()) + lst.removeAll(m_query->value(0).toString()); + QCOMPARE(lst.count(), 0); + + QMap<int, QStringList> fileAtts; + m_query->exec("SELECT a.Id, b.Name FROM FileAttributeSetTable a, " + "FilterAttributeTable b WHERE a.FilterAttributeId=b.Id"); + while (m_query->next()) { + int id = m_query->value(0).toInt(); + if (!fileAtts.contains(id)) + fileAtts.insert(id, QStringList()); + fileAtts[id].append(m_query->value(1).toString()); + } + QCOMPARE(fileAtts.count(), 2); + QCOMPARE((bool)fileAtts.value(1).contains("test"), true); + QCOMPARE((bool)fileAtts.value(1).contains("filter1"), true); + QCOMPARE((bool)fileAtts.value(1).contains("filter2"), false); + QCOMPARE((bool)fileAtts.value(2).contains("test"), true); + QCOMPARE((bool)fileAtts.value(2).contains("filter2"), true); +} + +void tst_QHelpGenerator::checkMetaData() +{ + m_query->exec("SELECT COUNT(Value) FROM MetaDataTable"); + if (!m_query->next()) + QFAIL("Meta Data Error"); + QCOMPARE(m_query->value(0).toInt(), 4); + + m_query->exec("SELECT Value FROM MetaDataTable WHERE Name=\'author\'"); + if (!m_query->next()) + QFAIL("Meta Data Error"); + QCOMPARE(m_query->value(0).toString(), QString("Nokia Corporation and/or its subsidiary(-ies)")); +} + +QTEST_MAIN(tst_QHelpGenerator) +#include "tst_qhelpgenerator.moc" + +#else // QT_NO_BUILD_TOOLS +QTEST_NOOP_MAIN +#endif + diff --git a/tests/auto/qhelpgenerator/tst_qhelpgenerator.pro b/tests/auto/qhelpgenerator/tst_qhelpgenerator.pro new file mode 100644 index 0000000..b4b07dd --- /dev/null +++ b/tests/auto/qhelpgenerator/tst_qhelpgenerator.pro @@ -0,0 +1,9 @@ +load(qttest_p4) + +SOURCES += tst_qhelpgenerator.cpp +CONFIG += help +QT += sql + +DEFINES += SRCDIR=\\\"$$PWD\\\" +DEFINES += QT_USE_USING_NAMESPACE +!contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS |