author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
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 <QStandardItemModel> |
|
45 |
#include <qdebug.h> |
|
46 |
#include <qdesktopservices.h> |
|
47 |
||
48 |
//#define RUN_MANUAL_TESTS |
|
49 |
//TESTED_CLASS= |
|
50 |
//TESTED_FILES= |
|
51 |
||
52 |
class tst_qdesktopservices : public QObject { |
|
53 |
Q_OBJECT |
|
54 |
||
55 |
public: |
|
56 |
tst_qdesktopservices(); |
|
57 |
virtual ~tst_qdesktopservices(); |
|
58 |
||
59 |
private slots: |
|
60 |
void init(); |
|
61 |
void cleanup(); |
|
62 |
void openUrl(); |
|
63 |
#ifdef Q_OS_SYMBIAN |
|
64 |
// These test are manual ones, you need to check from device that |
|
65 |
// correct system application is started with correct content |
|
66 |
// When you want to run these test, uncomment //#define RUN_MANUAL_TESTS |
|
67 |
void openHttpUrl_data(); |
|
68 |
void openHttpUrl(); |
|
69 |
void openMailtoUrl_data(); |
|
70 |
void openMailtoUrl(); |
|
71 |
void openFileUrl_data(); |
|
72 |
void openFileUrl(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
void openMultipleFileUrls(); |
0 | 74 |
#endif |
75 |
void handlers(); |
|
76 |
void storageLocation_data(); |
|
77 |
void storageLocation(); |
|
78 |
||
79 |
void storageLocationDoesNotEndWithSlash_data(); |
|
80 |
void storageLocationDoesNotEndWithSlash(); |
|
81 |
||
82 |
protected: |
|
83 |
}; |
|
84 |
||
85 |
tst_qdesktopservices::tst_qdesktopservices() |
|
86 |
{ |
|
87 |
QCoreApplication::setOrganizationName("Nokia"); |
|
88 |
QCoreApplication::setApplicationName("tst_qdesktopservices"); |
|
89 |
} |
|
90 |
||
91 |
tst_qdesktopservices::~tst_qdesktopservices() |
|
92 |
{ |
|
93 |
} |
|
94 |
||
95 |
void tst_qdesktopservices::init() |
|
96 |
{ |
|
97 |
} |
|
98 |
||
99 |
void tst_qdesktopservices::cleanup() |
|
100 |
{ |
|
101 |
} |
|
102 |
||
103 |
void tst_qdesktopservices::openUrl() |
|
104 |
{ |
|
105 |
// At the bare minimum check that they return false for invalid url's |
|
106 |
QCOMPARE(QDesktopServices::openUrl(QUrl()), false); |
|
107 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
108 |
// this test is only valid on windows on other systems it might mean open a new document in the application handling .file |
|
109 |
QCOMPARE(QDesktopServices::openUrl(QUrl("file://invalid.file")), false); |
|
110 |
#endif |
|
111 |
} |
|
112 |
||
113 |
#ifdef Q_OS_SYMBIAN |
|
114 |
void tst_qdesktopservices::openHttpUrl_data() |
|
115 |
{ |
|
116 |
QTest::addColumn<QUrl>("url"); |
|
117 |
QTest::addColumn<bool>("result"); |
|
118 |
QTest::newRow("BasicWithHttp") << QUrl("http://www.google.fi") << true; |
|
119 |
QTest::newRow("BasicWithoutHttp") << QUrl("www.nokia.fi") << true; |
|
120 |
QTest::newRow("BasicWithUserAndPw") << QUrl("http://s60prereleases:oslofjord@pepper.troll.no/s60prereleases/patches/") << true; |
|
121 |
QTest::newRow("URL with space") << QUrl("http://www.manataka.org/Contents Page.html") << true; |
|
122 |
||
123 |
} |
|
124 |
||
125 |
void tst_qdesktopservices::openHttpUrl() |
|
126 |
{ |
|
127 |
#ifndef RUN_MANUAL_TESTS |
|
128 |
QSKIP("Test disabled -- only for manual purposes", SkipAll); |
|
129 |
#endif |
|
130 |
||
131 |
QFETCH(QUrl, url); |
|
132 |
QFETCH(bool, result); |
|
133 |
QCOMPARE(QDesktopServices::openUrl(url), result); |
|
134 |
QTest::qWait(30000); |
|
135 |
} |
|
136 |
||
137 |
void tst_qdesktopservices::openMailtoUrl_data() |
|
138 |
{ |
|
139 |
QTest::addColumn<QUrl>("url"); |
|
140 |
QTest::addColumn<bool>("result"); |
|
141 |
||
142 |
// http://en.wikipedia.org/wiki/E-mail_address |
|
143 |
// RFC Valid e-mail addresses |
|
144 |
QTest::newRow("Wiki valid email 1") << QUrl("mailto:abc@example.com") << true; |
|
145 |
QTest::newRow("Wiki valid email 2") << QUrl("mailto:Abc@example.com") << true; |
|
146 |
QTest::newRow("Wiki valid email 3") << QUrl("mailto:aBC@example.com") << true; |
|
147 |
QTest::newRow("Wiki valid email 4") << QUrl("mailto:abc.123@example.com") << true; |
|
148 |
QTest::newRow("Wiki valid email 5") << QUrl("mailto:1234567890@example.com") << true; |
|
149 |
QTest::newRow("Wiki valid email 6") << QUrl("mailto:_______@example.com") << true; |
|
150 |
QTest::newRow("Wiki valid email 7") << QUrl("mailto:abc+mailbox/department=shipping@example.com") << true; |
|
151 |
// S60 email client considers the next URL invalid, even ity should be valid |
|
152 |
QTest::newRow("Wiki valid email 8") << QUrl("mailto:!#$%&'*+-/=?^_`.{|}~@example.com") << true; // all of these characters are allowed |
|
153 |
QTest::newRow("Wiki valid email 9") << QUrl("mailto:\"abc@def\"@example.com") << true; // anything goes inside quotation marks |
|
154 |
QTest::newRow("Wiki valid email 10") << QUrl("mailto:\"Fred \\\"quota\\\" Bloggs\"@example.com") << true; // however, quotes need escaping |
|
155 |
||
156 |
// RFC invalid e-mail addresses |
|
157 |
// These return true even though they are invalid, but check that user is notified about invalid URL in mail application |
|
158 |
QTest::newRow("Wiki invalid email 1") << QUrl("mailto:Abc.example.com") << true; // character @ is missing |
|
159 |
QTest::newRow("Wiki invalid email 2") << QUrl("mailto:Abc.@example.com") << true; // character dot(.) is last in local part |
|
160 |
QTest::newRow("Wiki invalid email 3") << QUrl("mailto:Abc..123@example.com") << true; // character dot(.) is double |
|
161 |
QTest::newRow("Wiki invalid email 4") << QUrl("mailto:A@b@c@example.com") << true; // only one @ is allowed outside quotations marks |
|
162 |
QTest::newRow("Wiki invalid email 5") << QUrl("mailto:()[]\\;:,<>@example.com") << true; // none of the characters before the @ is allowed outside quotation marks |
|
163 |
||
164 |
QTest::newRow("Basic") << QUrl("mailto:test@nokia.com") << true; |
|
165 |
QTest::newRow("BasicSeveralAddr") << QUrl("mailto:test@nokia.com,test2@nokia.com,test3@nokia.com") << true; |
|
166 |
QTest::newRow("BasicAndSubject") << QUrl("mailto:test@nokia.com?subject=hello nokia") << true; |
|
167 |
QTest::newRow("BasicAndTo") << QUrl("mailto:test@nokia.com?to=test2@nokia.com") << true; |
|
168 |
||
169 |
QTest::newRow("BasicAndCc") << QUrl("mailto:test@nokia.com?cc=mycc@address.com") << true; |
|
170 |
QTest::newRow("BasicAndBcc") << QUrl("mailto:test@nokia.com?bcc=mybcc@address.com") << true; |
|
171 |
QTest::newRow("BasicAndBody") << QUrl("mailto:test@nokia.com?body=Test email message body") << true; |
|
172 |
||
173 |
// RFC examples, these are actually invalid because there is not host defined |
|
174 |
// Check that user is notified about invalid URL in mail application |
|
175 |
QTest::newRow("RFC2368 Example 1") << QUrl::fromEncoded("mailto:addr1%2C%20addr2") << true; |
|
176 |
QTest::newRow("RFC2368 Example 2") << QUrl::fromEncoded("mailto:?to=addr1%2C%20addr2") << true; |
|
177 |
QTest::newRow("RFC2368 Example 3") << QUrl("mailto:addr1?to=addr2") << true; |
|
178 |
||
179 |
QTest::newRow("RFC2368 Example 4") << QUrl("mailto:joe@example.com?cc=bob@example.com&body=hello") << true; |
|
180 |
QTest::newRow("RFC2368 Example 5") << QUrl("mailto:?to=joe@example.com&cc=bob@example.com&body=hello") << true; |
|
181 |
QTest::newRow("RFC2368 Example 6") << QUrl("mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com") << true; // OpaqueData |
|
182 |
QTest::newRow("RFC2368 Example 7") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index") << true; |
|
183 |
QTest::newRow("RFC2368 Example 8") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue") << true; |
|
184 |
QTest::newRow("RFC2368 Example 9") << QUrl("mailto:infobot@example.com?subject=current-issue") << true; |
|
185 |
QTest::newRow("RFC2368 Example 10") << QUrl("mailto:chris@example.com") << true; |
|
186 |
||
187 |
//QTest::newRow("RFC2368 Example 11 - illegal chars") << QUrl("mailto:joe@example.com?cc=bob@example.com?body=hello") << false; |
|
188 |
QTest::newRow("RFC2368 Example 12") << QUrl::fromEncoded("mailto:gorby%25kremvax@example.com") << true; // encoded reserved chars '%' |
|
189 |
QTest::newRow("RFC2368 Example 13") << QUrl::fromEncoded("mailto:unlikely%3Faddress@example.com?blat=foop") << true; // encoded reserved chars `?' |
|
190 |
} |
|
191 |
||
192 |
void tst_qdesktopservices::openMailtoUrl() |
|
193 |
{ |
|
194 |
#ifndef RUN_MANUAL_TESTS |
|
195 |
QSKIP("Test disabled -- only for manual purposes", SkipAll); |
|
196 |
#endif |
|
197 |
||
198 |
QFETCH(QUrl, url); |
|
199 |
QFETCH(bool, result); |
|
200 |
QCOMPARE(QDesktopServices::openUrl(url), result); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
QTest::qWait(5000); |
0 | 202 |
} |
203 |
||
204 |
void tst_qdesktopservices::openFileUrl_data() |
|
205 |
{ |
|
206 |
QTest::addColumn<QUrl>("url"); |
|
207 |
QTest::addColumn<bool>("result"); |
|
208 |
||
209 |
// Text files |
|
210 |
QTest::newRow("DOS text file") << QUrl("file:///c:/data/others/dosfile.txt") << true; |
|
211 |
QTest::newRow("No EOF text file") << QUrl("file:///c:/data/others/noendofline.txt") << true; |
|
212 |
QTest::newRow("text file") << QUrl("file:///c:/data/others/testfile.txt") << true; |
|
213 |
QTest::newRow("text file with space") << QUrl("file:///c:/data/others/test file.txt") << true; |
|
214 |
||
215 |
// Images |
|
216 |
QTest::newRow("BMP image") << QUrl("file:///c:/data/images/image.bmp") << true; |
|
217 |
QTest::newRow("GIF image") << QUrl("file:///c:/data/images/image.gif") << true; |
|
218 |
QTest::newRow("JPG image") << QUrl("file:///c:/data/images/image.jpg") << true; |
|
219 |
QTest::newRow("PNG image") << QUrl("file:///c:/data/images/image.png") << true; |
|
220 |
||
221 |
// Audio |
|
222 |
QTest::newRow("MP4 audio") << QUrl("file:///c:/data/sounds/aac-only.mp4") << true; |
|
223 |
QTest::newRow("3GP audio") << QUrl("file:///c:/data/sounds/audio_3gpp.3gp") << true; |
|
224 |
||
225 |
// Video |
|
226 |
QTest::newRow("MP4 video") << QUrl("file:///c:/data/videos/vid-mpeg4-22k.mp4") << true; |
|
227 |
||
228 |
// Installs |
|
229 |
QTest::newRow("SISX") << QUrl("file:///c:/data/installs/ErrRd.sisx") << true; |
|
230 |
||
231 |
// Errors |
|
232 |
QTest::newRow("File does not exist") << QUrl("file:///c:/thisfileneverexists.txt") << false; |
|
233 |
} |
|
234 |
||
235 |
void tst_qdesktopservices::openFileUrl() |
|
236 |
{ |
|
237 |
#ifndef RUN_MANUAL_TESTS |
|
238 |
QSKIP("Test disabled -- only for manual purposes", SkipAll); |
|
239 |
#endif |
|
240 |
||
241 |
QFETCH(QUrl, url); |
|
242 |
QFETCH(bool, result); |
|
243 |
QCOMPARE(QDesktopServices::openUrl(url), result); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
QTest::qWait(5000); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
void tst_qdesktopservices::openMultipleFileUrls() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
#ifndef RUN_MANUAL_TESTS |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
QSKIP("Test disabled -- only for manual purposes", SkipAll); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.bmp")), true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/images/image.png")), true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/others/noendofline.txt")), true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
QCOMPARE(QDesktopServices::openUrl(QUrl("file:///c:/data/installs/ErrRd.sisx")), true); |
0 | 257 |
} |
258 |
#endif |
|
259 |
||
260 |
||
261 |
class MyUrlHandler : public QObject |
|
262 |
{ |
|
263 |
Q_OBJECT |
|
264 |
public: |
|
265 |
QUrl lastHandledUrl; |
|
266 |
||
267 |
public slots: |
|
268 |
inline void handle(const QUrl &url) { |
|
269 |
lastHandledUrl = url; |
|
270 |
} |
|
271 |
}; |
|
272 |
||
273 |
void tst_qdesktopservices::handlers() |
|
274 |
{ |
|
275 |
MyUrlHandler fooHandler; |
|
276 |
MyUrlHandler barHandler; |
|
277 |
||
278 |
QDesktopServices::setUrlHandler(QString("foo"), &fooHandler, "handle"); |
|
279 |
QDesktopServices::setUrlHandler(QString("bar"), &barHandler, "handle"); |
|
280 |
||
281 |
QUrl fooUrl("foo://blub/meh"); |
|
282 |
QUrl barUrl("bar://hmm/hmmmm"); |
|
283 |
||
284 |
QVERIFY(QDesktopServices::openUrl(fooUrl)); |
|
285 |
QVERIFY(QDesktopServices::openUrl(barUrl)); |
|
286 |
||
287 |
QCOMPARE(fooHandler.lastHandledUrl.toString(), fooUrl.toString()); |
|
288 |
QCOMPARE(barHandler.lastHandledUrl.toString(), barUrl.toString()); |
|
289 |
} |
|
290 |
||
291 |
Q_DECLARE_METATYPE(QDesktopServices::StandardLocation) |
|
292 |
void tst_qdesktopservices::storageLocation_data() |
|
293 |
{ |
|
294 |
QTest::addColumn<QDesktopServices::StandardLocation>("location"); |
|
295 |
QTest::newRow("DesktopLocation") << QDesktopServices::DesktopLocation; |
|
296 |
QTest::newRow("DocumentsLocation") << QDesktopServices::DocumentsLocation; |
|
297 |
QTest::newRow("FontsLocation") << QDesktopServices::FontsLocation; |
|
298 |
QTest::newRow("ApplicationsLocation") << QDesktopServices::ApplicationsLocation; |
|
299 |
QTest::newRow("MusicLocation") << QDesktopServices::MusicLocation; |
|
300 |
QTest::newRow("MoviesLocation") << QDesktopServices::MoviesLocation; |
|
301 |
QTest::newRow("PicturesLocation") << QDesktopServices::PicturesLocation; |
|
302 |
QTest::newRow("TempLocation") << QDesktopServices::TempLocation; |
|
303 |
QTest::newRow("HomeLocation") << QDesktopServices::HomeLocation; |
|
304 |
QTest::newRow("DataLocation") << QDesktopServices::DataLocation; |
|
305 |
} |
|
306 |
||
307 |
void tst_qdesktopservices::storageLocation() |
|
308 |
{ |
|
309 |
QFETCH(QDesktopServices::StandardLocation, location); |
|
310 |
#ifdef Q_OS_SYMBIAN |
|
311 |
QString storageLocation = QDesktopServices::storageLocation(location); |
|
312 |
QString displayName = QDesktopServices::displayName(location); |
|
313 |
//qDebug( "displayName: %s", displayName ); |
|
314 |
||
315 |
storageLocation = storageLocation.toLower(); |
|
316 |
displayName = displayName.toLower(); |
|
317 |
||
318 |
QString drive = QDir::currentPath().left(2).toLower(); |
|
319 |
if( drive == "z:" ) |
|
320 |
drive = "c:"; |
|
321 |
||
322 |
switch(location) { |
|
323 |
case QDesktopServices::DesktopLocation: |
|
324 |
QCOMPARE( storageLocation, drive + QString("/data") ); |
|
325 |
break; |
|
326 |
case QDesktopServices::DocumentsLocation: |
|
327 |
QCOMPARE( storageLocation, drive + QString("/data") ); |
|
328 |
break; |
|
329 |
case QDesktopServices::FontsLocation: |
|
330 |
// Currently point always to ROM |
|
331 |
QCOMPARE( storageLocation, QString("z:/resource/fonts") ); |
|
332 |
break; |
|
333 |
case QDesktopServices::ApplicationsLocation: |
|
334 |
#ifdef Q_CC_NOKIAX86 |
|
335 |
QCOMPARE( storageLocation, QString("z:/sys/bin") ); |
|
336 |
#else |
|
337 |
QCOMPARE( storageLocation, drive + QString("/sys/bin") ); |
|
338 |
#endif |
|
339 |
break; |
|
340 |
case QDesktopServices::MusicLocation: |
|
341 |
QCOMPARE( storageLocation, drive + QString("/data/sounds") ); |
|
342 |
break; |
|
343 |
case QDesktopServices::MoviesLocation: |
|
344 |
QCOMPARE( storageLocation, drive + QString("/data/videos") ); |
|
345 |
break; |
|
346 |
case QDesktopServices::PicturesLocation: |
|
347 |
QCOMPARE( storageLocation, drive + QString("/data/images") ); |
|
348 |
break; |
|
349 |
case QDesktopServices::TempLocation: |
|
350 |
QCOMPARE( storageLocation, QDir::tempPath().toLower()); |
|
351 |
break; |
|
352 |
case QDesktopServices::HomeLocation: |
|
353 |
QCOMPARE( storageLocation, QDir::homePath().toLower()); |
|
354 |
break; |
|
355 |
case QDesktopServices::DataLocation: |
|
356 |
// Just check the folder not the drive |
|
357 |
QCOMPARE( storageLocation.mid(2), QDir::currentPath().mid(2).toLower()); |
|
358 |
break; |
|
359 |
default: |
|
360 |
QCOMPARE( storageLocation, QString() ); |
|
361 |
break; |
|
362 |
} |
|
363 |
||
364 |
#else |
|
365 |
QDesktopServices::storageLocation(location); |
|
366 |
QDesktopServices::displayName(location); |
|
367 |
#endif |
|
368 |
} |
|
369 |
||
370 |
||
371 |
void tst_qdesktopservices::storageLocationDoesNotEndWithSlash_data() |
|
372 |
{ |
|
373 |
storageLocation_data(); |
|
374 |
} |
|
375 |
||
376 |
void tst_qdesktopservices::storageLocationDoesNotEndWithSlash() |
|
377 |
{ |
|
378 |
// Currently all desktop locations return their storage location |
|
379 |
// with "Unix-style" paths (i.e. they use a slash, not backslash). |
|
380 |
QFETCH(QDesktopServices::StandardLocation, location); |
|
381 |
QString loc = QDesktopServices::storageLocation(location); |
|
382 |
if (loc.size() > 1) // workaround for unlikely case of locations that return '/' |
|
383 |
QCOMPARE(loc.endsWith(QLatin1Char('/')), false); |
|
384 |
} |
|
385 |
||
386 |
||
387 |
QTEST_MAIN(tst_qdesktopservices) |
|
388 |
#include "tst_qdesktopservices.moc" |