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/qhelpcontentmodel | |
download | Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2 |
Long live Qt!
Diffstat (limited to 'tests/auto/qhelpcontentmodel')
-rw-r--r-- | tests/auto/qhelpcontentmodel/.gitignore | 2 | ||||
-rw-r--r-- | tests/auto/qhelpcontentmodel/data/collection.qhc | bin | 0 -> 10240 bytes | |||
-rw-r--r-- | tests/auto/qhelpcontentmodel/data/qmake-3.3.8.qch | bin | 0 -> 61440 bytes | |||
-rw-r--r-- | tests/auto/qhelpcontentmodel/data/qmake-4.3.0.qch | bin | 0 -> 93184 bytes | |||
-rw-r--r-- | tests/auto/qhelpcontentmodel/data/test.qch | bin | 0 -> 22528 bytes | |||
-rw-r--r-- | tests/auto/qhelpcontentmodel/qhelpcontentmodel.pro | 10 | ||||
-rw-r--r-- | tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp | 182 | ||||
-rw-r--r-- | tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro | 8 |
8 files changed, 202 insertions, 0 deletions
diff --git a/tests/auto/qhelpcontentmodel/.gitignore b/tests/auto/qhelpcontentmodel/.gitignore new file mode 100644 index 0000000..0602f2f --- /dev/null +++ b/tests/auto/qhelpcontentmodel/.gitignore @@ -0,0 +1,2 @@ +tst_qhelpcontentmodel +data/col.qhc diff --git a/tests/auto/qhelpcontentmodel/data/collection.qhc b/tests/auto/qhelpcontentmodel/data/collection.qhc Binary files differnew file mode 100644 index 0000000..6fb8abb --- /dev/null +++ b/tests/auto/qhelpcontentmodel/data/collection.qhc diff --git a/tests/auto/qhelpcontentmodel/data/qmake-3.3.8.qch b/tests/auto/qhelpcontentmodel/data/qmake-3.3.8.qch Binary files differnew file mode 100644 index 0000000..a3ca18a --- /dev/null +++ b/tests/auto/qhelpcontentmodel/data/qmake-3.3.8.qch diff --git a/tests/auto/qhelpcontentmodel/data/qmake-4.3.0.qch b/tests/auto/qhelpcontentmodel/data/qmake-4.3.0.qch Binary files differnew file mode 100644 index 0000000..8f76134 --- /dev/null +++ b/tests/auto/qhelpcontentmodel/data/qmake-4.3.0.qch diff --git a/tests/auto/qhelpcontentmodel/data/test.qch b/tests/auto/qhelpcontentmodel/data/test.qch Binary files differnew file mode 100644 index 0000000..1d6c1a8 --- /dev/null +++ b/tests/auto/qhelpcontentmodel/data/test.qch diff --git a/tests/auto/qhelpcontentmodel/qhelpcontentmodel.pro b/tests/auto/qhelpcontentmodel/qhelpcontentmodel.pro new file mode 100644 index 0000000..79bb44c --- /dev/null +++ b/tests/auto/qhelpcontentmodel/qhelpcontentmodel.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +CONFIG += ordered + +contains(QT_BUILD_PARTS, tools): { + SUBDIRS += ../../../tools/assistant/lib/fulltextsearch \ + ../../../tools/assistant/lib +} + +SUBDIRS += tst_qhelpcontentmodel.pro + diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp new file mode 100644 index 0000000..80f1595 --- /dev/null +++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.cpp @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** 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/QThread> +#include <QtCore/QUrl> +#include <QtCore/QFileInfo> + +#include <QtHelp/QHelpEngine> +#include <QtHelp/QHelpContentWidget> + +class SignalWaiter : public QThread +{ + Q_OBJECT + +public: + SignalWaiter(); + void run(); + +public slots: + void stopWaiting(); + +private: + bool stop; +}; + +SignalWaiter::SignalWaiter() +{ + stop = false; +} + +void SignalWaiter::run() +{ + while (!stop) + msleep(500); + stop = false; +} + +void SignalWaiter::stopWaiting() +{ + stop = true; +} + + +class tst_QHelpContentModel : public QObject +{ + Q_OBJECT + +private slots: + void init(); + + void setupContents(); + void contentItemAt(); + +private: + QString m_colFile; +}; + +void tst_QHelpContentModel::init() +{ + // defined in profile + QString path = QLatin1String(SRCDIR); + + m_colFile = path + QLatin1String("/data/col.qhc"); + if (QFile::exists(m_colFile)) + QDir::current().remove(m_colFile); + if (!QFile::copy(path + "/data/collection.qhc", m_colFile)) + QFAIL("Cannot copy file!"); + QFile f(m_colFile); + f.setPermissions(QFile::WriteUser|QFile::ReadUser); +} + +void tst_QHelpContentModel::setupContents() +{ + QHelpEngine h(m_colFile, 0); + QHelpContentModel *m = h.contentModel(); + SignalWaiter w; + connect(m, SIGNAL(contentsCreated()), + &w, SLOT(stopWaiting())); + w.start(); + h.setupData(); + int i = 0; + while (w.isRunning() && i++ < 10) + QTest::qWait(500); + + QCOMPARE(h.currentFilter(), QString("unfiltered")); + QCOMPARE(m->rowCount(), 4); + + w.start(); + h.setCurrentFilter("Custom Filter 1"); + i = 0; + while (w.isRunning() && i++ < 10) + QTest::qWait(500); + + QCOMPARE(m->rowCount(), 1); +} + +void tst_QHelpContentModel::contentItemAt() +{ + QHelpEngine h(m_colFile, 0); + QHelpContentModel *m = h.contentModel(); + SignalWaiter w; + connect(m, SIGNAL(contentsCreated()), + &w, SLOT(stopWaiting())); + w.start(); + h.setupData(); + int i = 0; + while (w.isRunning() && i++ < 10) + QTest::qWait(500); + + QCOMPARE(h.currentFilter(), QString("unfiltered")); + + QModelIndex root = m->index(0, 0); + if (!root.isValid()) + QFAIL("Cannot retrieve root item!"); + QHelpContentItem *item = m->contentItemAt(root); + if (!item) + QFAIL("Cannot retrieve content item!"); + QCOMPARE(item->title(), QString("qmake Manual")); + + item = m->contentItemAt(m->index(4, 0, root)); + QCOMPARE(item->title(), QString("qmake Concepts")); + + item = m->contentItemAt(m->index(3, 0)); + QCOMPARE(item->title(), QString("Fancy Manual")); + + w.start(); + h.setCurrentFilter("Custom Filter 1"); + i = 0; + while (w.isRunning() && i++ < 10) + QTest::qWait(500); + + item = m->contentItemAt(m->index(0, 0)); + QCOMPARE(item->title(), QString("Test Manual")); +} + +QTEST_MAIN(tst_QHelpContentModel) +#include "tst_qhelpcontentmodel.moc" + +#else // QT_NO_BUILD_TOOLS +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro new file mode 100644 index 0000000..7cd8d51 --- /dev/null +++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +SOURCES += tst_qhelpcontentmodel.cpp + +CONFIG += help + +DEFINES += SRCDIR=\\\"$$PWD\\\" +DEFINES += QT_USE_USING_NAMESPACE +!contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS |