author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
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:
3
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 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
#include <QtCore> |
|
45 |
||
46 |
#ifdef Q_OS_SYMBIAN |
|
47 |
#define SRCDIR "." |
|
48 |
#endif |
|
49 |
||
50 |
class tst_QResourceEngine: public QObject |
|
51 |
{ |
|
52 |
Q_OBJECT |
|
53 |
||
54 |
private slots: |
|
55 |
void initTestCase(); |
|
56 |
void cleanupTestCase(); |
|
57 |
||
58 |
void checkUnregisterResource_data(); |
|
59 |
void checkUnregisterResource(); |
|
60 |
void checkStructure_data(); |
|
61 |
void checkStructure(); |
|
62 |
void searchPath_data(); |
|
63 |
void searchPath(); |
|
64 |
void doubleSlashInRoot(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
void setLocale(); |
0 | 66 |
|
67 |
private: |
|
68 |
QString builddir; |
|
69 |
}; |
|
70 |
||
71 |
Q_DECLARE_METATYPE(QLocale) |
|
72 |
Q_DECLARE_METATYPE(qlonglong) |
|
73 |
||
74 |
void tst_QResourceEngine::initTestCase() |
|
75 |
{ |
|
76 |
QVERIFY(QResource::registerResource("runtime_resource.rcc")); |
|
77 |
QVERIFY(QResource::registerResource("runtime_resource.rcc", "/secondary_root/")); |
|
78 |
QString srcdir(QLatin1String(SRCDIR)); |
|
79 |
if (!srcdir.isEmpty()) { |
|
80 |
builddir = QDir::current().absolutePath(); |
|
81 |
if (!builddir.endsWith(QDir::separator())) |
|
82 |
builddir.append(QDir::separator()); |
|
83 |
QDir::setCurrent(srcdir); |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
void tst_QResourceEngine::cleanupTestCase() |
|
88 |
{ |
|
89 |
if (!builddir.isEmpty()) { |
|
90 |
QDir::setCurrent(builddir); |
|
91 |
} |
|
92 |
||
93 |
// make sure we don't leak memory |
|
94 |
QVERIFY(QResource::unregisterResource("runtime_resource.rcc")); |
|
95 |
QVERIFY(QResource::unregisterResource("runtime_resource.rcc", "/secondary_root/")); |
|
96 |
} |
|
97 |
||
98 |
void tst_QResourceEngine::checkStructure_data() |
|
99 |
{ |
|
100 |
QTest::addColumn<QString>("pathName"); |
|
101 |
QTest::addColumn<QString>("contents"); |
|
102 |
QTest::addColumn<QStringList>("containedFiles"); |
|
103 |
QTest::addColumn<QStringList>("containedDirs"); |
|
104 |
QTest::addColumn<QLocale>("locale"); |
|
105 |
QTest::addColumn<qlonglong>("contentsSize"); |
|
106 |
||
107 |
QFileInfo info; |
|
108 |
||
109 |
QTest::newRow("root dir") << QString(":/") |
|
110 |
<< QString() |
|
111 |
<< (QStringList() << "search_file.txt") |
|
112 |
<< (QStringList() << QLatin1String("aliasdir") << QLatin1String("otherdir") |
|
113 |
<< QLatin1String("runtime_resource") |
|
114 |
<< QLatin1String("searchpath1") << QLatin1String("searchpath2") |
|
115 |
<< QLatin1String("secondary_root") |
|
116 |
<< QLatin1String("test") |
|
117 |
<< QLatin1String("withoutslashes")) |
|
118 |
<< QLocale::c() |
|
119 |
<< qlonglong(0); |
|
120 |
||
121 |
QTest::newRow("secondary root") << QString(":/secondary_root/") |
|
122 |
<< QString() |
|
123 |
<< QStringList() |
|
124 |
<< (QStringList() << QLatin1String("runtime_resource")) |
|
125 |
<< QLocale::c() |
|
126 |
<< qlonglong(0); |
|
127 |
||
128 |
QStringList roots; |
|
129 |
roots << QString(":/") << QString(":/runtime_resource/") << QString(":/secondary_root/runtime_resource/"); |
|
130 |
for(int i = 0; i < roots.size(); ++i) { |
|
131 |
const QString root = roots.at(i); |
|
132 |
||
133 |
QTest::newRow(QString(root + "prefix dir").toLatin1().constData()) << QString(root + "test/abc/123/+++") |
|
134 |
<< QString() |
|
135 |
<< (QStringList() << QLatin1String("currentdir.txt") << QLatin1String("currentdir2.txt") << QLatin1String("parentdir.txt")) |
|
136 |
<< (QStringList() << QLatin1String("subdir")) |
|
137 |
<< QLocale::c() |
|
138 |
<< qlonglong(0); |
|
139 |
||
140 |
QTest::newRow(QString(root + "parent to prefix").toLatin1().constData()) << QString(root + "test/abc/123") |
|
141 |
<< QString() |
|
142 |
<< QStringList() |
|
143 |
<< (QStringList() << QLatin1String("+++")) |
|
144 |
<< QLocale::c() |
|
145 |
<< qlonglong(0); |
|
146 |
||
147 |
QTest::newRow(QString(root + "two parents prefix").toLatin1().constData()) << QString(root + "test/abc") |
|
148 |
<< QString() |
|
149 |
<< QStringList() |
|
150 |
<< QStringList(QLatin1String("123")) |
|
151 |
<< QLocale::c() |
|
152 |
<< qlonglong(0); |
|
153 |
||
154 |
QTest::newRow(QString(root + "test dir ").toLatin1().constData()) << QString(root + "test") |
|
155 |
<< QString() |
|
156 |
<< (QStringList() << QLatin1String("testdir.txt")) |
|
157 |
<< (QStringList() << QLatin1String("abc") << QLatin1String("test")) |
|
158 |
<< QLocale::c() |
|
159 |
<< qlonglong(0); |
|
160 |
||
161 |
QTest::newRow(QString(root + "prefix no slashes").toLatin1().constData()) << QString(root + "withoutslashes") |
|
162 |
<< QString() |
|
163 |
<< QStringList("blahblah.txt") |
|
164 |
<< QStringList() |
|
165 |
<< QLocale::c() |
|
166 |
<< qlonglong(0); |
|
167 |
||
168 |
QTest::newRow(QString(root + "other dir").toLatin1().constData()) << QString(root + "otherdir") |
|
169 |
<< QString() |
|
170 |
<< QStringList(QLatin1String("otherdir.txt")) |
|
171 |
<< QStringList() |
|
172 |
<< QLocale::c() |
|
173 |
<< qlonglong(0); |
|
174 |
||
175 |
QTest::newRow(QString(root + "alias dir").toLatin1().constData()) << QString(root + "aliasdir") |
|
176 |
<< QString() |
|
177 |
<< QStringList(QLatin1String("aliasdir.txt")) |
|
178 |
<< QStringList() |
|
179 |
<< QLocale::c() |
|
180 |
<< qlonglong(0); |
|
181 |
||
182 |
QTest::newRow(QString(root + "second test dir").toLatin1().constData()) << QString(root + "test/test") |
|
183 |
<< QString() |
|
184 |
<< (QStringList() << QLatin1String("test1.txt") << QLatin1String("test2.txt")) |
|
185 |
<< QStringList() |
|
186 |
<< QLocale::c() |
|
187 |
<< qlonglong(0); |
|
188 |
||
189 |
info = QFileInfo("testqrc/test/test/test1.txt"); |
|
190 |
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test1.txt") |
|
191 |
<< QString("abc") |
|
192 |
<< QStringList() |
|
193 |
<< QStringList() |
|
194 |
<< QLocale::c() |
|
195 |
<< qlonglong(info.size()); |
|
196 |
||
197 |
info = QFileInfo("testqrc/blahblah.txt"); |
|
198 |
QTest::newRow(QString(root + "text no slashes").toLatin1().constData()) << QString(root + "withoutslashes/blahblah.txt") |
|
199 |
<< QString("qwerty") |
|
200 |
<< QStringList() |
|
201 |
<< QStringList() |
|
202 |
<< QLocale::c() |
|
203 |
<< qlonglong(info.size()); |
|
204 |
||
205 |
||
206 |
info = QFileInfo("testqrc/test/test/test2.txt"); |
|
207 |
QTest::newRow(QString(root + "test1 text").toLatin1().constData()) << QString(root + "test/test/test2.txt") |
|
208 |
<< QString("def") |
|
209 |
<< QStringList() |
|
210 |
<< QStringList() |
|
211 |
<< QLocale::c() |
|
212 |
<< qlonglong(info.size()); |
|
213 |
||
214 |
info = QFileInfo("testqrc/currentdir.txt"); |
|
215 |
QTest::newRow(QString(root + "currentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir.txt") |
|
216 |
<< QString("\"This is the current dir\" ") |
|
217 |
<< QStringList() |
|
218 |
<< QStringList() |
|
219 |
<< QLocale::c() |
|
220 |
<< qlonglong(info.size()); |
|
221 |
||
222 |
info = QFileInfo("testqrc/currentdir2.txt"); |
|
223 |
QTest::newRow(QString(root + "currentdir text2").toLatin1().constData()) << QString(root + "test/abc/123/+++/currentdir2.txt") |
|
224 |
<< QString("\"This is also the current dir\" ") |
|
225 |
<< QStringList() |
|
226 |
<< QStringList() |
|
227 |
<< QLocale::c() |
|
228 |
<< qlonglong(info.size()); |
|
229 |
||
230 |
info = QFileInfo("parentdir.txt"); |
|
231 |
QTest::newRow(QString(root + "parentdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/parentdir.txt") |
|
232 |
<< QString("abcdefgihklmnopqrstuvwxyz ") |
|
233 |
<< QStringList() |
|
234 |
<< QStringList() |
|
235 |
<< QLocale::c() |
|
236 |
<< qlonglong(info.size()); |
|
237 |
||
238 |
info = QFileInfo("testqrc/subdir/subdir.txt"); |
|
239 |
QTest::newRow(QString(root + "subdir text").toLatin1().constData()) << QString(root + "test/abc/123/+++/subdir/subdir.txt") |
|
240 |
<< QString("\"This is in the sub directory\" ") |
|
241 |
<< QStringList() |
|
242 |
<< QStringList() |
|
243 |
<< QLocale::c() |
|
244 |
<< qlonglong(info.size()); |
|
245 |
||
246 |
info = QFileInfo("testqrc/test/testdir.txt"); |
|
247 |
QTest::newRow(QString(root + "testdir text").toLatin1().constData()) << QString(root + "test/testdir.txt") |
|
248 |
<< QString("\"This is in the test directory\" ") |
|
249 |
<< QStringList() |
|
250 |
<< QStringList() |
|
251 |
<< QLocale::c() |
|
252 |
<< qlonglong(info.size()); |
|
253 |
||
254 |
info = QFileInfo("testqrc/otherdir/otherdir.txt"); |
|
255 |
QTest::newRow(QString(root + "otherdir text").toLatin1().constData()) << QString(root + "otherdir/otherdir.txt") |
|
256 |
<< QString("\"This is the other dir\" ") |
|
257 |
<< QStringList() |
|
258 |
<< QStringList() |
|
259 |
<< QLocale::c() |
|
260 |
<< qlonglong(info.size()); |
|
261 |
||
262 |
info = QFileInfo("testqrc/test/testdir2.txt"); |
|
263 |
QTest::newRow(QString(root + "alias text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
264 |
<< QString("\"This is another file in this directory\" ") |
|
265 |
<< QStringList() |
|
266 |
<< QStringList() |
|
267 |
<< QLocale::c() |
|
268 |
<< qlonglong(info.size()); |
|
269 |
||
270 |
info = QFileInfo("testqrc/aliasdir/aliasdir.txt"); |
|
271 |
QTest::newRow(QString(root + "korean text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
272 |
<< QString("\"This is a korean text file\" ") |
|
273 |
<< QStringList() |
|
274 |
<< QStringList() |
|
275 |
<< QLocale("ko") |
|
276 |
<< qlonglong(info.size()); |
|
277 |
||
278 |
info = QFileInfo("testqrc/aliasdir/aliasdir.txt"); |
|
279 |
QTest::newRow(QString(root + "korean text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
280 |
<< QString("\"This is a korean text file\" ") |
|
281 |
<< QStringList() |
|
282 |
<< QStringList() |
|
283 |
<< QLocale("ko_KR") |
|
284 |
<< qlonglong(info.size()); |
|
285 |
||
286 |
info = QFileInfo("testqrc/test/german.txt"); |
|
287 |
QTest::newRow(QString(root + "german text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
288 |
<< QString("Deutsch") |
|
289 |
<< QStringList() |
|
290 |
<< QStringList() |
|
291 |
<< QLocale("de") |
|
292 |
<< qlonglong(info.size()); |
|
293 |
||
294 |
info = QFileInfo("testqrc/test/german.txt"); |
|
295 |
QTest::newRow(QString(root + "german text 2").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
296 |
<< QString("Deutsch") |
|
297 |
<< QStringList() |
|
298 |
<< QStringList() |
|
299 |
<< QLocale("de_DE") |
|
300 |
<< qlonglong(info.size()); |
|
301 |
||
302 |
QFile file("testqrc/aliasdir/compressme.txt"); |
|
303 |
file.open(QFile::ReadOnly); |
|
304 |
info = QFileInfo("testqrc/aliasdir/compressme.txt"); |
|
305 |
QTest::newRow(QString(root + "compressed text").toLatin1().constData()) << QString(root + "aliasdir/aliasdir.txt") |
|
306 |
<< QString(file.readAll()) |
|
307 |
<< QStringList() |
|
308 |
<< QStringList() |
|
309 |
<< QLocale("de_CH") |
|
310 |
<< qlonglong(info.size()); |
|
311 |
} |
|
312 |
} |
|
313 |
||
314 |
void tst_QResourceEngine::checkStructure() |
|
315 |
{ |
|
316 |
QFETCH(QString, pathName); |
|
317 |
QFETCH(QString, contents); |
|
318 |
QFETCH(QStringList, containedFiles); |
|
319 |
QFETCH(QStringList, containedDirs); |
|
320 |
QFETCH(QLocale, locale); |
|
321 |
QFETCH(qlonglong, contentsSize); |
|
322 |
||
323 |
bool directory = (containedDirs.size() + containedFiles.size() > 0); |
|
324 |
QLocale::setDefault(locale); |
|
325 |
||
326 |
QFileInfo fileInfo(pathName); |
|
327 |
||
328 |
QVERIFY(fileInfo.exists()); |
|
329 |
QCOMPARE(fileInfo.isDir(), directory); |
|
330 |
QCOMPARE(fileInfo.size(), contentsSize); |
|
331 |
//QVERIFY(fileInfo.isReadable()); |
|
332 |
QVERIFY(!fileInfo.isWritable()); |
|
333 |
QVERIFY(!fileInfo.isExecutable()); |
|
334 |
||
335 |
if (directory) { |
|
336 |
QDir dir(pathName); |
|
337 |
||
338 |
// Test the Dir filter |
|
339 |
QFileInfoList list = dir.entryInfoList(QDir::Dirs, QDir::Name); |
|
340 |
// for(int i = 0; i < list.size(); ++i) |
|
341 |
// qDebug() << "one" << i << list.at(i).fileName(); |
|
342 |
// for(int i = 0; i < containedDirs.size(); ++i) |
|
343 |
// qDebug() << "two" << i << containedDirs.at(i); |
|
344 |
// qDebug() << "one" << list.size() << containedDirs.size(); |
|
345 |
QCOMPARE(list.size(), containedDirs.size()); |
|
346 |
// qDebug() << "two"; |
|
347 |
||
348 |
int i; |
|
349 |
for (i=0; i<list.size(); ++i) { |
|
350 |
QVERIFY(list.at(i).isDir()); |
|
351 |
QCOMPARE(list.at(i).fileName(), containedDirs.at(i)); |
|
352 |
} |
|
353 |
||
354 |
list = dir.entryInfoList(QDir::Files, QDir::Name); |
|
355 |
QCOMPARE(containedFiles.size(), list.size()); |
|
356 |
||
357 |
for (i=0; i<list.size(); ++i) { |
|
358 |
QVERIFY(!list.at(i).isDir()); |
|
359 |
QCOMPARE(list.at(i).fileName(), containedFiles.at(i)); |
|
360 |
} |
|
361 |
||
362 |
list = dir.entryInfoList(QDir::NoFilter, QDir::SortFlags(QDir::Name | QDir::DirsFirst)); |
|
363 |
QCOMPARE(containedFiles.size() + containedDirs.size(), list.size()); |
|
364 |
||
365 |
for (i=0; i<list.size(); ++i) { |
|
366 |
QString expectedName; |
|
367 |
if (i < containedDirs.size()) |
|
368 |
expectedName = containedDirs.at(i); |
|
369 |
else |
|
370 |
expectedName = containedFiles.at(i - containedDirs.size()); |
|
371 |
||
372 |
QCOMPARE(list.at(i).fileName(), expectedName); |
|
373 |
} |
|
374 |
} else { |
|
375 |
QFile file(pathName); |
|
376 |
QVERIFY(file.open(QFile::ReadOnly)); |
|
377 |
||
378 |
QByteArray ba = file.readAll(); |
|
379 |
QVERIFY(QString(ba).startsWith(contents)); |
|
380 |
} |
|
381 |
QLocale::setDefault(QLocale::system()); |
|
382 |
} |
|
383 |
||
384 |
void tst_QResourceEngine::searchPath_data() |
|
385 |
{ |
|
386 |
QTest::addColumn<QString>("searchPath"); |
|
387 |
QTest::addColumn<QString>("file"); |
|
388 |
QTest::addColumn<QByteArray>("expected"); |
|
389 |
||
390 |
QTest::newRow("no_search_path") << QString() |
|
391 |
<< ":search_file.txt" |
|
392 |
<< QByteArray("root\n"); |
|
393 |
QTest::newRow("path1") << "/searchpath1" |
|
394 |
<< ":search_file.txt" |
|
395 |
<< QByteArray("path1\n"); |
|
396 |
QTest::newRow("no_search_path2") << QString() |
|
397 |
<< ":/search_file.txt" |
|
398 |
<< QByteArray("root\n"); |
|
399 |
QTest::newRow("path2") << "/searchpath2" |
|
400 |
<< ":search_file.txt" |
|
401 |
<< QByteArray("path2\n"); |
|
402 |
} |
|
403 |
||
404 |
void tst_QResourceEngine::searchPath() |
|
405 |
{ |
|
406 |
QFETCH(QString, searchPath); |
|
407 |
QFETCH(QString, file); |
|
408 |
QFETCH(QByteArray, expected); |
|
409 |
||
410 |
if(!searchPath.isEmpty()) |
|
411 |
QDir::addResourceSearchPath(searchPath); |
|
412 |
QFile qf(file); |
|
413 |
QVERIFY(qf.open(QFile::ReadOnly)); |
|
414 |
QByteArray actual = qf.readAll(); |
|
415 |
||
416 |
actual.replace('\r', ""); |
|
417 |
||
418 |
QCOMPARE(actual, expected); |
|
419 |
qf.close(); |
|
420 |
} |
|
421 |
||
422 |
void tst_QResourceEngine::checkUnregisterResource_data() |
|
423 |
{ |
|
424 |
QTest::addColumn<QString>("rcc_file"); |
|
425 |
QTest::addColumn<QString>("root"); |
|
426 |
QTest::addColumn<QString>("file_check"); |
|
427 |
QTest::addColumn<int>("size"); |
|
428 |
||
429 |
QTest::newRow("currentdir.txt") << builddir + QString("runtime_resource.rcc") << QString("/check_unregister/") |
|
430 |
<< QString(":/check_unregister/runtime_resource/test/abc/123/+++/currentdir.txt") |
|
431 |
<< (int)QFileInfo("testqrc/currentdir.txt").size(); |
|
432 |
} |
|
433 |
||
434 |
void tst_QResourceEngine::checkUnregisterResource() |
|
435 |
{ |
|
436 |
QFETCH(QString, rcc_file); |
|
437 |
QFETCH(QString, root); |
|
438 |
QFETCH(QString, file_check); |
|
439 |
QFETCH(int, size); |
|
440 |
||
441 |
||
442 |
||
443 |
QVERIFY(!QFile::exists(file_check)); |
|
444 |
QVERIFY(QResource::registerResource(rcc_file, root)); |
|
445 |
QVERIFY(QFile::exists(file_check)); |
|
446 |
QVERIFY(QResource::unregisterResource(rcc_file, root)); |
|
447 |
QVERIFY(!QFile::exists(file_check)); |
|
448 |
QVERIFY(QResource::registerResource(rcc_file, root)); |
|
449 |
QVERIFY(QFile::exists(file_check)); |
|
450 |
QFileInfo fileInfo(file_check); |
|
451 |
fileInfo.setCaching(false); |
|
452 |
QVERIFY(fileInfo.exists()); |
|
453 |
QVERIFY(!QResource::unregisterResource(rcc_file, root)); |
|
454 |
QVERIFY(!QFile::exists(file_check)); |
|
455 |
QCOMPARE((int)fileInfo.size(), size); |
|
456 |
} |
|
457 |
||
458 |
void tst_QResourceEngine::doubleSlashInRoot() |
|
459 |
{ |
|
460 |
QVERIFY(QFile::exists(":/secondary_root/runtime_resource/search_file.txt")); |
|
461 |
QVERIFY(QFile::exists("://secondary_root/runtime_resource/search_file.txt")); |
|
462 |
} |
|
463 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
464 |
void tst_QResourceEngine::setLocale() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
466 |
QLocale::setDefault(QLocale::c()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
467 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
468 |
// default constructed QResource gets the default locale |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
469 |
QResource resource; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
470 |
resource.setFileName("aliasdir/aliasdir.txt"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
QVERIFY(!resource.isCompressed()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
472 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
// change the default locale and make sure it doesn't affect the resource |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
474 |
QLocale::setDefault(QLocale("de_CH")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
475 |
QVERIFY(!resource.isCompressed()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
476 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
477 |
// then explicitly set the locale on qresource |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
478 |
resource.setLocale(QLocale("de_CH")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
479 |
QVERIFY(resource.isCompressed()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
480 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
// the reset the default locale back |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
QLocale::setDefault(QLocale::system()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
|
0 | 485 |
QTEST_MAIN(tst_QResourceEngine) |
486 |
||
487 |
#include "tst_qresourceengine.moc" |
|
488 |