author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
#include <QtTest/QtTest> |
|
42 |
||
43 |
#ifndef QT_NO_BUILD_TOOLS |
|
44 |
||
45 |
#include <QtCore/QFileInfo> |
|
46 |
||
47 |
#include <QtHelp/private/qhelpprojectdata_p.h> |
|
48 |
||
49 |
class tst_QHelpProjectData : public QObject |
|
50 |
{ |
|
51 |
Q_OBJECT |
|
52 |
||
53 |
private slots: |
|
54 |
void initTestCase(); |
|
55 |
||
56 |
void readData(); |
|
57 |
void namespaceName(); |
|
58 |
void virtualFolder(); |
|
59 |
void customFilters(); |
|
60 |
void filterSections(); |
|
61 |
void metaData(); |
|
62 |
void rootPath(); |
|
63 |
||
64 |
private: |
|
65 |
QString m_inputFile; |
|
66 |
}; |
|
67 |
||
68 |
void tst_QHelpProjectData::initTestCase() |
|
69 |
{ |
|
70 |
const QString path = QLatin1String(SRCDIR); |
|
71 |
m_inputFile = path + QLatin1String("/data/test.qhp"); |
|
72 |
} |
|
73 |
||
74 |
void tst_QHelpProjectData::readData() |
|
75 |
{ |
|
76 |
QHelpProjectData data; |
|
77 |
if (!data.readData(m_inputFile)) |
|
78 |
QFAIL("Cannot parse qhp file!"); |
|
79 |
} |
|
80 |
||
81 |
void tst_QHelpProjectData::namespaceName() |
|
82 |
{ |
|
83 |
QHelpProjectData data; |
|
84 |
if (!data.readData(m_inputFile)) |
|
85 |
QFAIL("Cannot read qhp file!"); |
|
86 |
QCOMPARE(data.namespaceName(), QString("trolltech.com.1_0_0.test")); |
|
87 |
} |
|
88 |
||
89 |
void tst_QHelpProjectData::virtualFolder() |
|
90 |
{ |
|
91 |
QHelpProjectData data; |
|
92 |
if (!data.readData(m_inputFile)) |
|
93 |
QFAIL("Cannot read qhp file!"); |
|
94 |
QCOMPARE(data.virtualFolder(), QString("testFolder")); |
|
95 |
} |
|
96 |
||
97 |
void tst_QHelpProjectData::customFilters() |
|
98 |
{ |
|
99 |
QHelpProjectData data; |
|
100 |
if (!data.readData(m_inputFile)) |
|
101 |
QFAIL("Cannot read qhp file!"); |
|
102 |
||
103 |
QList<QHelpDataCustomFilter> filters = data.customFilters(); |
|
104 |
QCOMPARE(filters.count(), 2); |
|
105 |
||
106 |
foreach (QHelpDataCustomFilter f, filters) { |
|
107 |
if (f.name == QLatin1String("Custom Filter 1")) { |
|
108 |
foreach (QString id, f.filterAttributes) { |
|
109 |
if (id != QLatin1String("test") |
|
110 |
&& id != QLatin1String("filter1")) |
|
111 |
QFAIL("Wrong filter attribute!"); |
|
112 |
} |
|
113 |
} else if (f.name == QLatin1String("Custom Filter 2")) { |
|
114 |
foreach (QString id, f.filterAttributes) { |
|
115 |
if (id != QLatin1String("test") |
|
116 |
&& id != QLatin1String("filter2")) |
|
117 |
QFAIL("Wrong filter attribute!"); |
|
118 |
} |
|
119 |
} else { |
|
120 |
QFAIL("Unexpected filter name!"); |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
void tst_QHelpProjectData::filterSections() |
|
126 |
{ |
|
127 |
QHelpProjectData data; |
|
128 |
if (!data.readData(m_inputFile)) |
|
129 |
QFAIL("Cannot read qhp file!"); |
|
130 |
||
131 |
QList<QHelpDataFilterSection> sections = data.filterSections(); |
|
132 |
QCOMPARE(sections.count(), 2); |
|
133 |
||
134 |
foreach (QHelpDataFilterSection s, sections) { |
|
135 |
if (s.filterAttributes().contains("filter1")) { |
|
136 |
QCOMPARE(s.indices().count(), 5); |
|
137 |
foreach (QHelpDataIndexItem idx, s.indices()) { |
|
138 |
if (idx.name == QLatin1String("foo")) { |
|
139 |
QCOMPARE(idx.identifier, QString("Test::foo")); |
|
140 |
} else if (idx.name == QLatin1String("bar")) { |
|
141 |
QCOMPARE(idx.reference, QString("test.html#bar")); |
|
142 |
} else if (idx.name == QLatin1String("bla")) { |
|
143 |
QCOMPARE(idx.identifier, QString("Test::bla")); |
|
144 |
} else if (idx.name == QLatin1String("einstein")) { |
|
145 |
QCOMPARE(idx.reference, QString("people.html#einstein")); |
|
146 |
} else if (idx.name == QLatin1String("newton")) { |
|
147 |
QCOMPARE(idx.identifier, QString("People::newton")); |
|
148 |
} else { |
|
149 |
QFAIL("Unexpected index!"); |
|
150 |
} |
|
151 |
} |
|
152 |
QCOMPARE(s.contents().count(), 1); |
|
153 |
QCOMPARE(s.contents().first()->children().count(), 5); |
|
154 |
} else if (s.filterAttributes().contains("filter2")) { |
|
155 |
QCOMPARE(s.contents().count(), 1); |
|
156 |
QStringList lst; |
|
157 |
lst << "classic.css" << "fancy.html" << "cars.html"; |
|
158 |
foreach (QString f, s.files()) |
|
159 |
lst.removeAll(f); |
|
160 |
QCOMPARE(lst.count(), 0); |
|
161 |
} else { |
|
162 |
QFAIL("Unexpected filter attribute!"); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
void tst_QHelpProjectData::metaData() |
|
168 |
{ |
|
169 |
QHelpProjectData data; |
|
170 |
if (!data.readData(m_inputFile)) |
|
171 |
QFAIL("Cannot read qhp file!"); |
|
172 |
||
173 |
QCOMPARE(data.metaData().count(), 2); |
|
174 |
QCOMPARE(data.metaData().value("author").toString(), |
|
175 |
QString("Nokia Corporation and/or its subsidiary(-ies)")); |
|
176 |
} |
|
177 |
||
178 |
void tst_QHelpProjectData::rootPath() |
|
179 |
{ |
|
180 |
QHelpProjectData data; |
|
181 |
if (!data.readData(m_inputFile)) |
|
182 |
QFAIL("Cannot read qhp file!"); |
|
183 |
||
184 |
QFileInfo fi(m_inputFile); |
|
185 |
QCOMPARE(data.rootPath(), fi.absolutePath()); |
|
186 |
} |
|
187 |
||
188 |
QTEST_MAIN(tst_QHelpProjectData) |
|
189 |
#include "tst_qhelpprojectdata.moc" |
|
190 |
||
191 |
#else // QT_NO_BUILD_TOOLS |
|
192 |
QTEST_NOOP_MAIN |
|
193 |
#endif |