author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:20:32 +0300 | |
changeset 34 | a33bf25e6f72 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
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 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
||
45 |
#include <qcoreapplication.h> |
|
46 |
#include <qdebug.h> |
|
47 |
#include <qfiledialog.h> |
|
48 |
#include <qabstractitemdelegate.h> |
|
49 |
#include <qdirmodel.h> |
|
50 |
#include <qitemdelegate.h> |
|
51 |
#include <qlistview.h> |
|
52 |
#include <qcombobox.h> |
|
53 |
#include <qpushbutton.h> |
|
54 |
#include <qtoolbutton.h> |
|
55 |
#include <qtreeview.h> |
|
56 |
#include <qheaderview.h> |
|
57 |
#include <qcompleter.h> |
|
58 |
#include <qaction.h> |
|
59 |
#include <qdialogbuttonbox.h> |
|
60 |
#include <qsortfilterproxymodel.h> |
|
61 |
#include <qlineedit.h> |
|
62 |
#include <qlayout.h> |
|
63 |
#include "../../shared/util.h" |
|
64 |
#include "../../../src/gui/dialogs/qsidebar_p.h" |
|
65 |
#include "../../../src/gui/dialogs/qfilesystemmodel_p.h" |
|
66 |
#include "../../../src/gui/dialogs/qfiledialog_p.h" |
|
67 |
||
68 |
#include "../network-settings.h" |
|
69 |
||
70 |
//TESTED_CLASS= |
|
71 |
//TESTED_FILES= |
|
72 |
||
73 |
#if defined(Q_OS_SYMBIAN) |
|
74 |
# define STRINGIFY(x) #x |
|
75 |
# define TOSTRING(x) STRINGIFY(x) |
|
76 |
# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" |
|
77 |
#endif |
|
78 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
79 |
#if defined QT_BUILD_INTERNAL |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
80 |
QT_BEGIN_NAMESPACE |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
81 |
Q_GUI_EXPORT bool qt_test_isFetchedRoot(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
82 |
Q_GUI_EXPORT void qt_test_resetFetchedRoot(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
83 |
QT_END_NAMESPACE |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
84 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
85 |
|
0 | 86 |
class QNonNativeFileDialog : public QFileDialog |
87 |
{ |
|
88 |
Q_OBJECT |
|
89 |
public: |
|
90 |
QNonNativeFileDialog(QWidget *parent = 0, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString()) |
|
91 |
: QFileDialog(parent, caption, directory, filter) |
|
92 |
{ |
|
93 |
setOption(QFileDialog::DontUseNativeDialog, true); |
|
94 |
} |
|
95 |
}; |
|
96 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
97 |
class tst_QFileDialog2 : public QObject |
0 | 98 |
{ |
99 |
Q_OBJECT |
|
100 |
||
101 |
public: |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
102 |
tst_QFileDialog2(); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
103 |
virtual ~tst_QFileDialog2(); |
0 | 104 |
|
105 |
public slots: |
|
106 |
void init(); |
|
107 |
void cleanup(); |
|
108 |
||
109 |
private slots: |
|
110 |
void listRoot(); |
|
111 |
void heapCorruption(); |
|
112 |
void deleteDirAndFiles(); |
|
113 |
void filter(); |
|
114 |
void showNameFilterDetails(); |
|
115 |
void unc(); |
|
116 |
void emptyUncPath(); |
|
117 |
||
118 |
void task178897_minimumSize(); |
|
119 |
void task180459_lastDirectory_data(); |
|
120 |
void task180459_lastDirectory(); |
|
121 |
void task227304_proxyOnFileDialog(); |
|
122 |
void task227930_correctNavigationKeyboardBehavior(); |
|
123 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
124 |
void task226366_lowerCaseHardDriveWindows(); |
|
125 |
#endif |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
void completionOnLevelAfterRoot(); |
0 | 127 |
void task233037_selectingDirectory(); |
128 |
void task235069_hideOnEscape(); |
|
129 |
void task236402_dontWatchDeletedDir(); |
|
130 |
void task203703_returnProperSeparator(); |
|
131 |
void task228844_ensurePreviousSorting(); |
|
132 |
void task239706_editableFilterCombo(); |
|
133 |
void task218353_relativePaths(); |
|
134 |
void task251321_sideBarHiddenEntries(); |
|
135 |
void task251341_sideBarRemoveEntries(); |
|
136 |
void task254490_selectFileMultipleTimes(); |
|
137 |
void task257579_sideBarWithNonCleanUrls(); |
|
138 |
void task259105_filtersCornerCases(); |
|
139 |
||
140 |
void QTBUG4419_lineEditSelectAll(); |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
141 |
void QTBUG6558_showDirsOnly(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
void QTBUG4842_selectFilterWithHideNameFilterDetails(); |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
143 |
void dontShowCompleterOnRoot(); |
0 | 144 |
|
145 |
private: |
|
146 |
QByteArray userSettings; |
|
147 |
}; |
|
148 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
149 |
tst_QFileDialog2::tst_QFileDialog2() |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
150 |
{ |
0 | 151 |
#if defined(Q_OS_WINCE) |
152 |
qApp->setAutoMaximizeThreshold(-1); |
|
153 |
#endif |
|
154 |
} |
|
155 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
156 |
tst_QFileDialog2::~tst_QFileDialog2() |
0 | 157 |
{ |
158 |
} |
|
159 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
160 |
void tst_QFileDialog2::init() |
0 | 161 |
{ |
162 |
// Save the developers settings so they don't get mad when their sidebar folders are gone. |
|
163 |
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
|
164 |
settings.beginGroup(QLatin1String("Qt")); |
|
165 |
userSettings = settings.value(QLatin1String("filedialog")).toByteArray(); |
|
166 |
settings.remove(QLatin1String("filedialog")); |
|
167 |
||
168 |
// populate it with some default settings |
|
169 |
QNonNativeFileDialog fd; |
|
170 |
#if defined(Q_OS_WINCE) |
|
171 |
QTest::qWait(1000); |
|
172 |
#endif |
|
173 |
} |
|
174 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
175 |
void tst_QFileDialog2::cleanup() |
0 | 176 |
{ |
177 |
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
|
178 |
settings.beginGroup(QLatin1String("Qt")); |
|
179 |
settings.setValue(QLatin1String("filedialog"), userSettings); |
|
180 |
} |
|
181 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
182 |
void tst_QFileDialog2::listRoot() |
0 | 183 |
{ |
184 |
#if defined QT_BUILD_INTERNAL |
|
185 |
QFileInfoGatherer fileInfoGatherer; |
|
186 |
fileInfoGatherer.start(); |
|
187 |
QTest::qWait(1500); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
188 |
qt_test_resetFetchedRoot(); |
0 | 189 |
QString dir(QDir::currentPath()); |
190 |
QNonNativeFileDialog fd(0, QString(), dir); |
|
191 |
fd.show(); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
192 |
QCOMPARE(qt_test_isFetchedRoot(),false); |
0 | 193 |
fd.setDirectory(""); |
194 |
#ifdef Q_OS_WINCE |
|
195 |
QTest::qWait(1500); |
|
196 |
#else |
|
197 |
QTest::qWait(500); |
|
198 |
#endif |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
199 |
QCOMPARE(qt_test_isFetchedRoot(),true); |
0 | 200 |
#endif |
201 |
} |
|
202 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
203 |
void tst_QFileDialog2::heapCorruption() |
0 | 204 |
{ |
205 |
QVector<QNonNativeFileDialog*> dialogs; |
|
206 |
for (int i=0; i < 10; i++) { |
|
207 |
QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL); |
|
208 |
dialogs << f; |
|
209 |
} |
|
210 |
qDeleteAll(dialogs); |
|
211 |
} |
|
212 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
struct FriendlyQFileDialog : public QNonNativeFileDialog |
0 | 214 |
{ |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
215 |
friend class tst_QFileDialog2; |
0 | 216 |
Q_DECLARE_PRIVATE(QFileDialog) |
217 |
}; |
|
218 |
||
219 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
220 |
void tst_QFileDialog2::deleteDirAndFiles() |
0 | 221 |
{ |
222 |
#if defined QT_BUILD_INTERNAL |
|
223 |
QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; |
|
224 |
QDir dir; |
|
225 |
QVERIFY(dir.mkpath(tempPath + "/foo")); |
|
226 |
QVERIFY(dir.mkpath(tempPath + "/foo/B")); |
|
227 |
QVERIFY(dir.mkpath(tempPath + "/foo/B")); |
|
228 |
QVERIFY(dir.mkpath(tempPath + "/foo/c")); |
|
229 |
QVERIFY(dir.mkpath(tempPath + "/bar")); |
|
230 |
QFile(tempPath + "/foo/a"); |
|
231 |
QTemporaryFile *t; |
|
232 |
t = new QTemporaryFile(tempPath + "/foo/aXXXXXX"); |
|
233 |
t->setAutoRemove(false); |
|
234 |
t->open(); |
|
235 |
t->close(); |
|
236 |
delete t; |
|
237 |
||
238 |
t = new QTemporaryFile(tempPath + "/foo/B/yXXXXXX"); |
|
239 |
t->setAutoRemove(false); |
|
240 |
t->open(); |
|
241 |
t->close(); |
|
242 |
delete t; |
|
243 |
FriendlyQFileDialog fd; |
|
244 |
fd.setOption(QFileDialog::DontUseNativeDialog); |
|
245 |
fd.d_func()->removeDirectory(tempPath); |
|
246 |
QFileInfo info(tempPath); |
|
247 |
QTest::qWait(2000); |
|
248 |
QVERIFY(!info.exists()); |
|
249 |
#endif |
|
250 |
} |
|
251 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
252 |
void tst_QFileDialog2::filter() |
0 | 253 |
{ |
254 |
QNonNativeFileDialog fd; |
|
255 |
QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); |
|
256 |
QVERIFY(hiddenAction); |
|
257 |
QVERIFY(hiddenAction->isEnabled()); |
|
258 |
QVERIFY(!hiddenAction->isChecked()); |
|
259 |
QDir::Filters filter = fd.filter(); |
|
260 |
filter |= QDir::Hidden; |
|
261 |
fd.setFilter(filter); |
|
262 |
QVERIFY(hiddenAction->isChecked()); |
|
263 |
} |
|
264 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
265 |
void tst_QFileDialog2::showNameFilterDetails() |
0 | 266 |
{ |
267 |
QNonNativeFileDialog fd; |
|
268 |
QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
|
269 |
QVERIFY(filters); |
|
270 |
QVERIFY(fd.isNameFilterDetailsVisible()); |
|
271 |
||
272 |
||
273 |
QStringList filterChoices; |
|
274 |
filterChoices << "Image files (*.png *.xpm *.jpg)" |
|
275 |
<< "Text files (*.txt)" |
|
276 |
<< "Any files (*.*)"; |
|
277 |
fd.setFilters(filterChoices); |
|
278 |
||
279 |
fd.setNameFilterDetailsVisible(false); |
|
280 |
QCOMPARE(filters->itemText(0), QString("Image files")); |
|
281 |
QCOMPARE(filters->itemText(1), QString("Text files")); |
|
282 |
QCOMPARE(filters->itemText(2), QString("Any files")); |
|
283 |
||
284 |
fd.setNameFilterDetailsVisible(true); |
|
285 |
QCOMPARE(filters->itemText(0), filterChoices.at(0)); |
|
286 |
QCOMPARE(filters->itemText(1), filterChoices.at(1)); |
|
287 |
QCOMPARE(filters->itemText(2), filterChoices.at(2)); |
|
288 |
} |
|
289 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
290 |
void tst_QFileDialog2::unc() |
0 | 291 |
{ |
292 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
293 |
// Only test UNC on Windows./ |
|
294 |
QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable"); |
|
295 |
#else |
|
296 |
QString dir(QDir::currentPath()); |
|
297 |
#endif |
|
298 |
QVERIFY(QFile::exists(dir)); |
|
299 |
QNonNativeFileDialog fd(0, QString(), dir); |
|
300 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
|
301 |
QVERIFY(model); |
|
302 |
QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); |
|
303 |
} |
|
304 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
305 |
void tst_QFileDialog2::emptyUncPath() |
0 | 306 |
{ |
307 |
QNonNativeFileDialog fd; |
|
308 |
fd.show(); |
|
309 |
QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
310 |
QVERIFY(lineEdit); |
|
311 |
// press 'keys' for the input |
|
312 |
for (int i = 0; i < 3 ; ++i) |
|
313 |
QTest::keyPress(lineEdit, Qt::Key_Backslash); |
|
314 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
|
315 |
QVERIFY(model); |
|
316 |
} |
|
317 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
318 |
void tst_QFileDialog2::task178897_minimumSize() |
0 | 319 |
{ |
320 |
QNonNativeFileDialog fd; |
|
321 |
QSize oldMs = fd.layout()->minimumSize(); |
|
322 |
QStringList history = fd.history(); |
|
323 |
history << QDir::toNativeSeparators("/verylongdirectory/" |
|
324 |
"aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk"); |
|
325 |
fd.setHistory(history); |
|
326 |
fd.show(); |
|
327 |
||
328 |
QSize ms = fd.layout()->minimumSize(); |
|
329 |
QVERIFY(ms.width() <= oldMs.width()); |
|
330 |
} |
|
331 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
332 |
void tst_QFileDialog2::task180459_lastDirectory_data() |
0 | 333 |
{ |
334 |
QTest::addColumn<QString>("path"); |
|
335 |
QTest::addColumn<QString>("directory"); |
|
336 |
QTest::addColumn<bool>("isEnabled"); |
|
337 |
QTest::addColumn<QString>("result"); |
|
338 |
||
339 |
QTest::newRow("path+file") << QDir::homePath() + QDir::separator() + "foo" |
|
340 |
<< QDir::homePath() << true |
|
341 |
<< QDir::homePath() + QDir::separator() + "foo" ; |
|
342 |
QTest::newRow("no path") << "" |
|
343 |
<< QDir::tempPath() << false << QString(); |
|
344 |
QTest::newRow("file") << "foo" |
|
345 |
<< QDir::currentPath() << true |
|
346 |
<< QDir::currentPath() + QDir::separator() + "foo" ; |
|
347 |
QTest::newRow("path") << QDir::homePath() |
|
348 |
<< QDir::homePath() << false << QString(); |
|
349 |
QTest::newRow("path not existing") << "/usr/bin/foo/bar/foo/foo.txt" |
|
350 |
<< QDir::tempPath() << true |
|
351 |
<< QDir::tempPath() + QDir::separator() + "foo.txt"; |
|
352 |
||
353 |
} |
|
354 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
355 |
void tst_QFileDialog2::task180459_lastDirectory() |
0 | 356 |
{ |
357 |
//first visit the temp directory and close the dialog |
|
358 |
QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); |
|
359 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); |
|
360 |
QVERIFY(model); |
|
361 |
QCOMPARE(model->index(QDir::tempPath()), model->index(dlg->directory().absolutePath())); |
|
362 |
delete dlg; |
|
363 |
||
364 |
QFETCH(QString, path); |
|
365 |
QFETCH(QString, directory); |
|
366 |
QFETCH(bool, isEnabled); |
|
367 |
QFETCH(QString, result); |
|
368 |
||
369 |
dlg = new QNonNativeFileDialog(0, "", path); |
|
370 |
model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); |
|
371 |
QVERIFY(model); |
|
372 |
dlg->setAcceptMode(QFileDialog::AcceptSave); |
|
373 |
QCOMPARE(model->index(dlg->directory().absolutePath()), model->index(directory)); |
|
374 |
||
375 |
QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(dlg, "buttonBox"); |
|
376 |
QPushButton *button = buttonBox->button(QDialogButtonBox::Save); |
|
377 |
QVERIFY(button); |
|
378 |
QCOMPARE(button->isEnabled(), isEnabled); |
|
379 |
if (isEnabled) |
|
380 |
QCOMPARE(model->index(result), model->index(dlg->selectedFiles().first())); |
|
381 |
||
382 |
delete dlg; |
|
383 |
} |
|
384 |
||
385 |
||
386 |
||
387 |
class FilterDirModel : public QSortFilterProxyModel |
|
388 |
{ |
|
389 |
||
390 |
public: |
|
391 |
FilterDirModel(QString root, QObject* parent=0):QSortFilterProxyModel(parent), m_root(root) |
|
392 |
{} |
|
393 |
~FilterDirModel() |
|
394 |
{}; |
|
395 |
||
396 |
protected: |
|
397 |
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const |
|
398 |
{ |
|
399 |
QModelIndex parentIndex; |
|
400 |
parentIndex = source_parent; |
|
401 |
||
402 |
QString path; |
|
403 |
path = parentIndex.child(source_row,0).data(Qt::DisplayRole).toString(); |
|
404 |
||
405 |
do { |
|
406 |
path = parentIndex.data(Qt::DisplayRole).toString() + "/" + path; |
|
407 |
parentIndex = parentIndex.parent(); |
|
408 |
} while(parentIndex.isValid()); |
|
409 |
||
410 |
QFileInfo info(path); |
|
411 |
if (info.isDir() && (QDir(path) != m_root)) |
|
412 |
return false; |
|
413 |
return true; |
|
414 |
} |
|
415 |
||
416 |
||
417 |
private: |
|
418 |
QDir m_root; |
|
419 |
||
420 |
||
421 |
}; |
|
422 |
||
423 |
class sortProxy : public QSortFilterProxyModel |
|
424 |
{ |
|
425 |
public: |
|
426 |
sortProxy(QObject *parent) : QSortFilterProxyModel(parent) |
|
427 |
{ |
|
428 |
} |
|
429 |
protected: |
|
430 |
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const |
|
431 |
{ |
|
432 |
QFileSystemModel * const model = qobject_cast<QFileSystemModel *>(sourceModel()); |
|
433 |
const QFileInfo leftInfo(model->fileInfo(left)); |
|
434 |
const QFileInfo rightInfo(model->fileInfo(right)); |
|
435 |
||
436 |
if (leftInfo.isDir() == rightInfo.isDir()) |
|
437 |
return(leftInfo.filePath().compare(rightInfo.filePath(),Qt::CaseInsensitive) < 0); |
|
438 |
else if (leftInfo.isDir()) |
|
439 |
return(false); |
|
440 |
else |
|
441 |
return(true); |
|
442 |
} |
|
443 |
}; |
|
444 |
||
445 |
class CrashDialog : public QNonNativeFileDialog |
|
446 |
{ |
|
447 |
Q_OBJECT |
|
448 |
||
449 |
public: |
|
450 |
CrashDialog(QWidget *parent, const QString &caption, const |
|
451 |
QString &dir, const QString &filter) |
|
452 |
: QNonNativeFileDialog(parent, caption, dir, filter) |
|
453 |
{ |
|
454 |
sortProxy *proxyModel = new sortProxy(this); |
|
455 |
setProxyModel(proxyModel); |
|
456 |
} |
|
457 |
}; |
|
458 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
459 |
void tst_QFileDialog2::task227304_proxyOnFileDialog() |
0 | 460 |
{ |
461 |
#if defined QT_BUILD_INTERNAL |
|
462 |
QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); |
|
463 |
fd.setProxyModel(new FilterDirModel(QDir::currentPath())); |
|
464 |
fd.show(); |
|
465 |
QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
466 |
QTest::qWait(200); |
|
467 |
QTest::keyClick(edit, Qt::Key_T); |
|
468 |
QTest::keyClick(edit, Qt::Key_S); |
|
469 |
QTest::qWait(200); |
|
470 |
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
|
471 |
||
472 |
CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") ); |
|
473 |
dialog->setFileMode(QFileDialog::ExistingFile); |
|
474 |
dialog->show(); |
|
475 |
||
476 |
QListView *list = qFindChild<QListView*>(dialog, "listView"); |
|
477 |
QTest::qWait(200); |
|
478 |
QTest::keyClick(list, Qt::Key_Down); |
|
479 |
QTest::keyClick(list, Qt::Key_Return); |
|
480 |
QTest::qWait(200); |
|
481 |
||
482 |
dialog->close(); |
|
483 |
fd.close(); |
|
484 |
||
485 |
QNonNativeFileDialog fd2(0, "I should not crash with a proxy", QDir::tempPath(), 0); |
|
486 |
QSortFilterProxyModel *pm = new QSortFilterProxyModel; |
|
487 |
fd2.setProxyModel(pm); |
|
488 |
fd2.show(); |
|
489 |
QSidebar *sidebar = qFindChild<QSidebar*>(&fd2, "sidebar"); |
|
490 |
sidebar->setFocus(); |
|
491 |
sidebar->selectUrl(QUrl::fromLocalFile(QDir::homePath())); |
|
492 |
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); |
|
493 |
QTest::qWait(250); |
|
494 |
//We shouldn't crash |
|
495 |
#endif |
|
496 |
} |
|
497 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
498 |
void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() |
0 | 499 |
{ |
500 |
QDir current = QDir::currentPath(); |
|
501 |
current.mkdir("test"); |
|
502 |
current.cd("test"); |
|
503 |
QFile file("test/out.txt"); |
|
504 |
QFile file2("test/out2.txt"); |
|
505 |
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text)); |
|
506 |
QVERIFY(file2.open(QIODevice::WriteOnly | QIODevice::Text)); |
|
507 |
current.cdUp(); |
|
508 |
current.mkdir("test2"); |
|
509 |
QNonNativeFileDialog fd; |
|
510 |
fd.setViewMode(QFileDialog::List); |
|
511 |
fd.setDirectory(current.absolutePath()); |
|
512 |
fd.show(); |
|
513 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
514 |
QTest::qWait(200); |
|
515 |
QTest::keyClick(list, Qt::Key_Down); |
|
516 |
QTest::keyClick(list, Qt::Key_Return); |
|
517 |
QTest::qWait(200); |
|
518 |
QTest::mouseClick(list->viewport(), Qt::LeftButton,0); |
|
519 |
QTest::keyClick(list, Qt::Key_Down); |
|
520 |
QTest::keyClick(list, Qt::Key_Backspace); |
|
521 |
QTest::qWait(200); |
|
522 |
QTest::keyClick(list, Qt::Key_Down); |
|
523 |
QTest::keyClick(list, Qt::Key_Down); |
|
524 |
QTest::keyClick(list, Qt::Key_Return); |
|
525 |
QTest::qWait(200); |
|
526 |
QCOMPARE(fd.isVisible(), true); |
|
527 |
QTest::qWait(200); |
|
528 |
file.close(); |
|
529 |
file2.close(); |
|
530 |
file.remove(); |
|
531 |
file2.remove(); |
|
532 |
current.rmdir("test"); |
|
533 |
current.rmdir("test2"); |
|
534 |
} |
|
535 |
||
536 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
537 |
void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() |
0 | 538 |
{ |
539 |
QNonNativeFileDialog fd; |
|
540 |
fd.setDirectory(QDir::root().path()); |
|
541 |
fd.show(); |
|
542 |
QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
543 |
QToolButton *buttonParent = qFindChild<QToolButton*>(&fd, "toParentButton"); |
|
544 |
QTest::qWait(200); |
|
545 |
QTest::mouseClick(buttonParent, Qt::LeftButton,0,QPoint(0,0)); |
|
546 |
QTest::qWait(2000); |
|
547 |
QTest::keyClick(edit, Qt::Key_C); |
|
548 |
QTest::qWait(200); |
|
549 |
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
|
550 |
QTest::qWait(200); |
|
551 |
QCOMPARE(edit->text(), QString("C:")); |
|
552 |
QTest::qWait(2000); |
|
553 |
//i clear my previous selection in the completer |
|
554 |
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
|
555 |
edit->clear(); |
|
556 |
QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT)); |
|
557 |
QTest::qWait(200); |
|
558 |
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
|
559 |
QCOMPARE(edit->text(), QString("C:")); |
|
560 |
} |
|
561 |
#endif |
|
562 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
563 |
void tst_QFileDialog2::completionOnLevelAfterRoot() |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
565 |
QNonNativeFileDialog fd; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
566 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
fd.setDirectory("C:"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
568 |
QDir current = fd.directory(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
569 |
current.mkdir("completionOnLevelAfterRootTest"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
#else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
571 |
fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
572 |
fd.setDirectory("/"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
573 |
QDir etc("/etc"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
if (!etc.exists()) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
QSKIP("This test requires to have an etc directory under /", SkipAll); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
fd.show(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
578 |
QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
579 |
QTest::qWait(2000); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
580 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
//I love testlib :D |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
582 |
QTest::keyClick(edit, Qt::Key_C); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
583 |
QTest::keyClick(edit, Qt::Key_O); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
584 |
QTest::keyClick(edit, Qt::Key_M); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
QTest::keyClick(edit, Qt::Key_P); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
586 |
QTest::keyClick(edit, Qt::Key_L); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
587 |
#else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
588 |
QTest::keyClick(edit, Qt::Key_E); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
589 |
QTest::keyClick(edit, Qt::Key_T); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
590 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
591 |
QTest::qWait(200); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
592 |
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
593 |
QTest::qWait(200); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
594 |
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
595 |
QCOMPARE(edit->text(), QString("completionOnLevelAfterRootTest")); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
596 |
current.rmdir("completionOnLevelAfterRootTest"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
597 |
#else |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
598 |
QCOMPARE(edit->text(), QString("etc")); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
599 |
#endif |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
600 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
601 |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
602 |
void tst_QFileDialog2::task233037_selectingDirectory() |
0 | 603 |
{ |
604 |
QDir current = QDir::currentPath(); |
|
605 |
current.mkdir("test"); |
|
606 |
QNonNativeFileDialog fd; |
|
607 |
fd.setViewMode(QFileDialog::List); |
|
608 |
fd.setDirectory(current.absolutePath()); |
|
609 |
fd.setAcceptMode( QFileDialog::AcceptSave); |
|
610 |
fd.show(); |
|
611 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
612 |
QTest::qWait(3000); // Wait for sort to settle (I need a signal). |
|
613 |
#ifdef QT_KEYPAD_NAVIGATION |
|
614 |
list->setEditFocus(true); |
|
615 |
#endif |
|
616 |
QTest::keyClick(list, Qt::Key_Down); |
|
617 |
QTest::qWait(100); |
|
618 |
QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); |
|
619 |
QPushButton *button = buttonBox->button(QDialogButtonBox::Save); |
|
620 |
QVERIFY(button); |
|
621 |
QCOMPARE(button->isEnabled(), true); |
|
622 |
current.rmdir("test"); |
|
623 |
} |
|
624 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
625 |
void tst_QFileDialog2::task235069_hideOnEscape() |
0 | 626 |
{ |
627 |
QDir current = QDir::currentPath(); |
|
628 |
QNonNativeFileDialog fd; |
|
629 |
fd.setViewMode(QFileDialog::List); |
|
630 |
fd.setDirectory(current.absolutePath()); |
|
631 |
fd.setAcceptMode( QFileDialog::AcceptSave); |
|
632 |
fd.show(); |
|
633 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
634 |
list->setFocus(); |
|
635 |
QTest::qWait(200); |
|
636 |
QTest::keyClick(list, Qt::Key_Escape); |
|
637 |
QCOMPARE(fd.isVisible(), false); |
|
638 |
QNonNativeFileDialog fd2; |
|
639 |
fd2.setDirectory(current.absolutePath()); |
|
640 |
fd2.setAcceptMode( QFileDialog::AcceptSave); |
|
641 |
fd2.show(); |
|
642 |
QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit"); |
|
643 |
QTest::keyClick(edit, Qt::Key_Escape); |
|
644 |
QCOMPARE(fd2.isVisible(), false); |
|
645 |
} |
|
646 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
647 |
void tst_QFileDialog2::task236402_dontWatchDeletedDir() |
0 | 648 |
{ |
649 |
#if defined QT_BUILD_INTERNAL |
|
650 |
//THIS TEST SHOULD NOT DISPLAY WARNINGS |
|
651 |
QDir current = QDir::currentPath(); |
|
652 |
//make sure it is the first on the list |
|
653 |
current.mkdir("aaaaaaaaaa"); |
|
654 |
FriendlyQFileDialog fd; |
|
655 |
fd.setViewMode(QFileDialog::List); |
|
656 |
fd.setDirectory(current.absolutePath()); |
|
657 |
fd.setAcceptMode( QFileDialog::AcceptSave); |
|
658 |
fd.show(); |
|
659 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
660 |
list->setFocus(); |
|
661 |
QTest::qWait(200); |
|
662 |
QTest::keyClick(list, Qt::Key_Return); |
|
663 |
QTest::qWait(200); |
|
664 |
QTest::keyClick(list, Qt::Key_Backspace); |
|
665 |
QTest::keyClick(list, Qt::Key_Down); |
|
666 |
QTest::qWait(200); |
|
667 |
fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/"); |
|
668 |
QTest::qWait(1000); |
|
669 |
#endif |
|
670 |
} |
|
671 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
672 |
void tst_QFileDialog2::task203703_returnProperSeparator() |
0 | 673 |
{ |
674 |
QDir current = QDir::currentPath(); |
|
675 |
current.mkdir("aaaaaaaaaaaaaaaaaa"); |
|
676 |
QNonNativeFileDialog fd; |
|
677 |
fd.setDirectory(current.absolutePath()); |
|
678 |
fd.setViewMode(QFileDialog::List); |
|
679 |
fd.setFileMode(QFileDialog::Directory); |
|
680 |
fd.show(); |
|
681 |
QTest::qWait(500); |
|
682 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
683 |
list->setFocus(); |
|
684 |
QTest::qWait(200); |
|
685 |
QTest::keyClick(list, Qt::Key_Return); |
|
686 |
QTest::qWait(1000); |
|
687 |
QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); |
|
688 |
QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel); |
|
689 |
QTest::keyClick(button, Qt::Key_Return); |
|
690 |
QTest::qWait(500); |
|
691 |
QString result = fd.selectedFiles().first(); |
|
692 |
QVERIFY(result.at(result.count() - 1) != '/'); |
|
693 |
QVERIFY(!result.contains('\\')); |
|
694 |
current.rmdir("aaaaaaaaaaaaaaaaaa"); |
|
695 |
} |
|
696 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
697 |
void tst_QFileDialog2::task228844_ensurePreviousSorting() |
0 | 698 |
{ |
699 |
QDir current = QDir::currentPath(); |
|
700 |
current.mkdir("aaaaaaaaaaaaaaaaaa"); |
|
701 |
current.cd("aaaaaaaaaaaaaaaaaa"); |
|
702 |
current.mkdir("a"); |
|
703 |
current.mkdir("b"); |
|
704 |
current.mkdir("c"); |
|
705 |
current.mkdir("d"); |
|
706 |
current.mkdir("e"); |
|
707 |
current.mkdir("f"); |
|
708 |
current.mkdir("g"); |
|
709 |
QTemporaryFile *tempFile = new QTemporaryFile(current.absolutePath() + "/rXXXXXX"); |
|
710 |
tempFile->open(); |
|
711 |
current.cdUp(); |
|
712 |
||
713 |
QNonNativeFileDialog fd; |
|
714 |
fd.setDirectory(current.absolutePath()); |
|
715 |
fd.setViewMode(QFileDialog::Detail); |
|
716 |
fd.show(); |
|
717 |
#if defined(Q_OS_WINCE) |
|
718 |
QTest::qWait(1500); |
|
719 |
#else |
|
720 |
QTest::qWait(500); |
|
721 |
#endif |
|
722 |
QTreeView *tree = qFindChild<QTreeView*>(&fd, "treeView"); |
|
723 |
tree->header()->setSortIndicator(3,Qt::DescendingOrder); |
|
724 |
QTest::qWait(200); |
|
725 |
QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); |
|
726 |
QPushButton *button = buttonBox->button(QDialogButtonBox::Open); |
|
727 |
QTest::mouseClick(button, Qt::LeftButton); |
|
728 |
#if defined(Q_OS_WINCE) |
|
729 |
QTest::qWait(1500); |
|
730 |
#else |
|
731 |
QTest::qWait(500); |
|
732 |
#endif |
|
733 |
QNonNativeFileDialog fd2; |
|
734 |
fd2.setFileMode(QFileDialog::Directory); |
|
735 |
fd2.restoreState(fd.saveState()); |
|
736 |
current.cd("aaaaaaaaaaaaaaaaaa"); |
|
737 |
fd2.setDirectory(current.absolutePath()); |
|
738 |
fd2.show(); |
|
739 |
#if defined(Q_OS_WINCE) |
|
740 |
QTest::qWait(1500); |
|
741 |
#else |
|
742 |
QTest::qWait(500); |
|
743 |
#endif |
|
744 |
QTreeView *tree2 = qFindChild<QTreeView*>(&fd2, "treeView"); |
|
745 |
tree2->setFocus(); |
|
746 |
||
747 |
QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath()); |
|
748 |
||
749 |
QDialogButtonBox *buttonBox2 = qFindChild<QDialogButtonBox*>(&fd2, "buttonBox"); |
|
750 |
QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open); |
|
751 |
fd2.selectFile("g"); |
|
752 |
QTest::mouseClick(button2, Qt::LeftButton); |
|
753 |
#if defined(Q_OS_WINCE) |
|
754 |
QTest::qWait(1500); |
|
755 |
#else |
|
756 |
QTest::qWait(500); |
|
757 |
#endif |
|
758 |
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g")); |
|
759 |
||
760 |
QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName()); |
|
761 |
fd3.restoreState(fd.saveState()); |
|
762 |
fd3.setFileMode(QFileDialog::Directory); |
|
763 |
fd3.show(); |
|
764 |
#if defined(Q_OS_WINCE) |
|
765 |
QTest::qWait(1500); |
|
766 |
#else |
|
767 |
QTest::qWait(500); |
|
768 |
#endif |
|
769 |
QTreeView *tree3 = qFindChild<QTreeView*>(&fd3, "treeView"); |
|
770 |
tree3->setFocus(); |
|
771 |
||
772 |
QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath()); |
|
773 |
||
774 |
QDialogButtonBox *buttonBox3 = qFindChild<QDialogButtonBox*>(&fd3, "buttonBox"); |
|
775 |
QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open); |
|
776 |
QTest::mouseClick(button3, Qt::LeftButton); |
|
777 |
#if defined(Q_OS_WINCE) |
|
778 |
QTest::qWait(1500); |
|
779 |
#else |
|
780 |
QTest::qWait(500); |
|
781 |
#endif |
|
782 |
QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName()); |
|
783 |
||
784 |
current.cd("aaaaaaaaaaaaaaaaaa"); |
|
785 |
current.rmdir("a"); |
|
786 |
current.rmdir("b"); |
|
787 |
current.rmdir("c"); |
|
788 |
current.rmdir("d"); |
|
789 |
current.rmdir("e"); |
|
790 |
current.rmdir("f"); |
|
791 |
current.rmdir("g"); |
|
792 |
tempFile->close(); |
|
793 |
delete tempFile; |
|
794 |
current.cdUp(); |
|
795 |
current.rmdir("aaaaaaaaaaaaaaaaaa"); |
|
796 |
} |
|
797 |
||
798 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
799 |
void tst_QFileDialog2::task239706_editableFilterCombo() |
0 | 800 |
{ |
801 |
QNonNativeFileDialog d; |
|
802 |
d.setNameFilter("*.cpp *.h"); |
|
803 |
||
804 |
d.show(); |
|
805 |
QTest::qWait(500); |
|
806 |
||
807 |
QList<QComboBox *> comboList = d.findChildren<QComboBox *>(); |
|
808 |
QComboBox *filterCombo = 0; |
|
809 |
foreach (QComboBox *combo, comboList) { |
|
810 |
if (combo->objectName() == QString("fileTypeCombo")) { |
|
811 |
filterCombo = combo; |
|
812 |
break; |
|
813 |
} |
|
814 |
} |
|
815 |
Q_ASSERT(filterCombo); |
|
816 |
filterCombo->setEditable(true); |
|
817 |
QTest::mouseClick(filterCombo, Qt::LeftButton); |
|
818 |
QTest::keyPress(filterCombo, Qt::Key_X); |
|
819 |
QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure |
|
820 |
} |
|
821 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
822 |
void tst_QFileDialog2::task218353_relativePaths() |
0 | 823 |
{ |
824 |
QDir appDir = QDir::current(); |
|
825 |
QVERIFY(appDir.cdUp() != false); |
|
826 |
QNonNativeFileDialog d(0, "TestDialog", ".."); |
|
827 |
QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
|
828 |
||
829 |
d.setDirectory(appDir.absolutePath() + QLatin1String("/non-existing-directory/../another-non-existing-dir/../")); |
|
830 |
QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
|
831 |
||
832 |
QDir::current().mkdir("test"); |
|
833 |
appDir = QDir::current(); |
|
834 |
d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../")); |
|
835 |
QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
|
836 |
appDir.rmdir("test"); |
|
837 |
} |
|
838 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
839 |
void tst_QFileDialog2::task251321_sideBarHiddenEntries() |
0 | 840 |
{ |
841 |
#if defined QT_BUILD_INTERNAL |
|
842 |
QNonNativeFileDialog fd; |
|
843 |
||
844 |
QDir current = QDir::currentPath(); |
|
845 |
current.mkdir(".hidden"); |
|
846 |
QDir hiddenDir = QDir(".hidden"); |
|
847 |
hiddenDir.mkdir("subdir"); |
|
848 |
QDir hiddenSubDir = QDir(".hidden/subdir"); |
|
849 |
hiddenSubDir.mkdir("happy"); |
|
850 |
hiddenSubDir.mkdir("happy2"); |
|
851 |
||
852 |
QList<QUrl> urls; |
|
853 |
urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath()); |
|
854 |
fd.setSidebarUrls(urls); |
|
855 |
fd.show(); |
|
856 |
QTest::qWait(250); |
|
857 |
||
858 |
QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); |
|
859 |
sidebar->setFocus(); |
|
860 |
sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath())); |
|
861 |
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); |
|
862 |
// give the background processes more time on windows mobile |
|
863 |
#ifdef Q_OS_WINCE |
|
864 |
QTest::qWait(1000); |
|
865 |
#else |
|
866 |
QTest::qWait(250); |
|
867 |
#endif |
|
868 |
||
869 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
|
870 |
QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2); |
|
871 |
||
872 |
hiddenSubDir.rmdir("happy2"); |
|
873 |
hiddenSubDir.rmdir("happy"); |
|
874 |
hiddenDir.rmdir("subdir"); |
|
875 |
current.rmdir(".hidden"); |
|
876 |
#endif |
|
877 |
} |
|
878 |
||
879 |
#if defined QT_BUILD_INTERNAL |
|
880 |
class MyQSideBar : public QSidebar |
|
881 |
{ |
|
882 |
public : |
|
883 |
MyQSideBar(QWidget *parent = 0) : QSidebar(parent) |
|
884 |
{} |
|
885 |
||
886 |
void removeSelection() { |
|
887 |
QList<QModelIndex> idxs = selectionModel()->selectedIndexes(); |
|
888 |
QList<QPersistentModelIndex> indexes; |
|
889 |
for (int i = 0; i < idxs.count(); i++) |
|
890 |
indexes.append(idxs.at(i)); |
|
891 |
||
892 |
for (int i = 0; i < indexes.count(); ++i) |
|
893 |
if (!indexes.at(i).data(Qt::UserRole + 1).toUrl().path().isEmpty()) |
|
894 |
model()->removeRow(indexes.at(i).row()); |
|
895 |
} |
|
896 |
}; |
|
897 |
#endif |
|
898 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
899 |
void tst_QFileDialog2::task251341_sideBarRemoveEntries() |
0 | 900 |
{ |
901 |
#if defined QT_BUILD_INTERNAL |
|
902 |
QNonNativeFileDialog fd; |
|
903 |
||
904 |
QDir current = QDir::currentPath(); |
|
905 |
current.mkdir("testDir"); |
|
906 |
QDir testSubDir = QDir("testDir"); |
|
907 |
||
908 |
QList<QUrl> urls; |
|
909 |
urls << QUrl::fromLocalFile(testSubDir.absolutePath()); |
|
910 |
urls << QUrl::fromLocalFile("NotFound"); |
|
911 |
fd.setSidebarUrls(urls); |
|
912 |
fd.show(); |
|
913 |
QTest::qWait(250); |
|
914 |
||
915 |
QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); |
|
916 |
sidebar->setFocus(); |
|
917 |
//We enter in the first bookmark |
|
918 |
sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath())); |
|
919 |
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); |
|
920 |
QTest::qWait(250); |
|
921 |
||
922 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
|
923 |
//There is no file |
|
924 |
QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0); |
|
925 |
//Icon is not enabled QUrlModel::EnabledRole |
|
926 |
QVariant value = sidebar->model()->index(0, 0).data(Qt::UserRole + 2); |
|
927 |
QCOMPARE(qvariant_cast<bool>(value), true); |
|
928 |
||
929 |
sidebar->setFocus(); |
|
930 |
//We enter in the second bookmark which is invalid |
|
931 |
sidebar->selectUrl(QUrl::fromLocalFile("NotFound")); |
|
932 |
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); |
|
933 |
QTest::qWait(250); |
|
934 |
||
935 |
//We fallback to root because the entry in the bookmark is invalid |
|
936 |
QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath()))); |
|
937 |
//Icon is not enabled QUrlModel::EnabledRole |
|
938 |
value = sidebar->model()->index(1, 0).data(Qt::UserRole + 2); |
|
939 |
QCOMPARE(qvariant_cast<bool>(value), false); |
|
940 |
||
941 |
MyQSideBar mySideBar; |
|
942 |
mySideBar.init(model, urls); |
|
943 |
mySideBar.show(); |
|
944 |
mySideBar.selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath())); |
|
945 |
QTest::qWait(1000); |
|
946 |
mySideBar.removeSelection(); |
|
947 |
||
948 |
//We remove the first entry |
|
949 |
QList<QUrl> expected; |
|
950 |
expected << QUrl::fromLocalFile("NotFound"); |
|
951 |
QCOMPARE(mySideBar.urls(), expected); |
|
952 |
||
953 |
mySideBar.selectUrl(QUrl::fromLocalFile("NotFound")); |
|
954 |
mySideBar.removeSelection(); |
|
955 |
||
956 |
//We remove the second entry |
|
957 |
expected.clear(); |
|
958 |
QCOMPARE(mySideBar.urls(), expected); |
|
959 |
||
960 |
current.rmdir("testDir"); |
|
961 |
#endif |
|
962 |
} |
|
963 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
964 |
void tst_QFileDialog2::task254490_selectFileMultipleTimes() |
0 | 965 |
{ |
966 |
QString tempPath = QDir::tempPath(); |
|
967 |
QTemporaryFile *t; |
|
968 |
t = new QTemporaryFile; |
|
969 |
t->open(); |
|
970 |
QNonNativeFileDialog fd(0, "TestFileDialog"); |
|
971 |
||
972 |
fd.setDirectory(tempPath); |
|
973 |
fd.setViewMode(QFileDialog::List); |
|
974 |
fd.setAcceptMode(QFileDialog::AcceptSave); |
|
975 |
fd.setFileMode(QFileDialog::AnyFile); |
|
976 |
||
977 |
//This should select the file in the QFileDialog |
|
978 |
fd.selectFile(t->fileName()); |
|
979 |
||
980 |
//This should clear the selection and write it into the filename line edit |
|
981 |
fd.selectFile("new_file.txt"); |
|
982 |
||
983 |
fd.show(); |
|
984 |
QTest::qWait(250); |
|
985 |
||
986 |
QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
987 |
QVERIFY(lineEdit); |
|
988 |
QCOMPARE(lineEdit->text(),QLatin1String("new_file.txt")); |
|
989 |
QListView *list = qFindChild<QListView*>(&fd, "listView"); |
|
990 |
QVERIFY(list); |
|
991 |
QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0); |
|
992 |
||
993 |
t->deleteLater(); |
|
994 |
} |
|
995 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
996 |
void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() |
0 | 997 |
{ |
998 |
#if defined QT_BUILD_INTERNAL |
|
999 |
QDir tempDir = QDir::temp(); |
|
1000 |
QLatin1String dirname("autotest_task257579"); |
|
1001 |
tempDir.rmdir(dirname); //makes sure it doesn't exist any more |
|
1002 |
QVERIFY(tempDir.mkdir(dirname)); |
|
1003 |
QString url = QString::fromLatin1("%1/%2/..").arg(tempDir.absolutePath()).arg(dirname); |
|
1004 |
QNonNativeFileDialog fd; |
|
1005 |
fd.setSidebarUrls(QList<QUrl>() << QUrl::fromLocalFile(url)); |
|
1006 |
QSidebar *sidebar = qFindChild<QSidebar*>(&fd, "sidebar"); |
|
1007 |
QCOMPARE(sidebar->urls().count(), 1); |
|
1008 |
QVERIFY(sidebar->urls().first().toLocalFile() != url); |
|
1009 |
QCOMPARE(sidebar->urls().first().toLocalFile(), QDir::cleanPath(url)); |
|
1010 |
||
1011 |
#ifdef Q_OS_WIN |
|
1012 |
QCOMPARE(sidebar->model()->index(0,0).data().toString().toLower(), tempDir.dirName().toLower()); |
|
1013 |
#else |
|
1014 |
QCOMPARE(sidebar->model()->index(0,0).data().toString(), tempDir.dirName()); |
|
1015 |
#endif |
|
1016 |
||
1017 |
//all tests are finished, we can remove the temporary dir |
|
1018 |
QVERIFY(tempDir.rmdir(dirname)); |
|
1019 |
#endif |
|
1020 |
} |
|
1021 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1022 |
void tst_QFileDialog2::task259105_filtersCornerCases() |
0 | 1023 |
{ |
1024 |
QNonNativeFileDialog fd(0, "TestFileDialog"); |
|
1025 |
fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); |
|
1026 |
fd.setOption(QFileDialog::HideNameFilterDetails, true); |
|
1027 |
fd.show(); |
|
1028 |
QTest::qWait(250); |
|
1029 |
||
1030 |
//Extensions are hidden |
|
1031 |
QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
|
1032 |
QVERIFY(filters); |
|
1033 |
QCOMPARE(filters->currentText(), QLatin1String("All Files!")); |
|
1034 |
filters->setCurrentIndex(1); |
|
1035 |
QCOMPARE(filters->currentText(), QLatin1String("Text Files")); |
|
1036 |
||
1037 |
//We should have the full names |
|
1038 |
fd.setOption(QFileDialog::HideNameFilterDetails, false); |
|
1039 |
QTest::qWait(250); |
|
1040 |
filters->setCurrentIndex(0); |
|
1041 |
QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)")); |
|
1042 |
filters->setCurrentIndex(1); |
|
1043 |
QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)")); |
|
1044 |
||
1045 |
//Corner case undocumented of the task |
|
1046 |
fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)")); |
|
1047 |
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)")); |
|
1048 |
filters->setCurrentIndex(1); |
|
1049 |
QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)")); |
|
1050 |
||
1051 |
fd.setOption(QFileDialog::HideNameFilterDetails, true); |
|
1052 |
filters->setCurrentIndex(0); |
|
1053 |
QTest::qWait(500); |
|
1054 |
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); |
|
1055 |
filters->setCurrentIndex(1); |
|
1056 |
QCOMPARE(filters->currentText(), QLatin1String("Text Files")); |
|
1057 |
||
1058 |
fd.setOption(QFileDialog::HideNameFilterDetails, true); |
|
1059 |
filters->setCurrentIndex(0); |
|
1060 |
QTest::qWait(500); |
|
1061 |
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); |
|
1062 |
filters->setCurrentIndex(1); |
|
1063 |
QCOMPARE(filters->currentText(), QLatin1String("Text Files")); |
|
1064 |
} |
|
1065 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1066 |
void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() |
0 | 1067 |
{ |
1068 |
QString tempPath = QDir::tempPath(); |
|
1069 |
QTemporaryFile *t; |
|
1070 |
t = new QTemporaryFile; |
|
1071 |
t->open(); |
|
1072 |
QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName()); |
|
1073 |
||
1074 |
fd.setDirectory(tempPath); |
|
1075 |
fd.setViewMode(QFileDialog::List); |
|
1076 |
fd.setAcceptMode(QFileDialog::AcceptSave); |
|
1077 |
fd.setFileMode(QFileDialog::AnyFile); |
|
1078 |
||
1079 |
fd.show(); |
|
1080 |
QApplication::setActiveWindow(&fd); |
|
1081 |
QTest::qWaitForWindowShown(&fd); |
|
1082 |
QTRY_COMPARE(fd.isVisible(), true); |
|
1083 |
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
|
1084 |
||
1085 |
QTest::qWait(250); |
|
1086 |
QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
1087 |
||
1088 |
QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); |
|
1089 |
QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); |
|
1090 |
} |
|
1091 |
||
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1092 |
void tst_QFileDialog2::QTBUG6558_showDirsOnly() |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1093 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1094 |
const QString tempPath = QDir::tempPath(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1095 |
QDir dirTemp(tempPath); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1096 |
const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1097 |
dirTemp.mkdir(tempName); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1098 |
dirTemp.cd(tempName); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1099 |
QTRY_VERIFY(dirTemp.exists()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1100 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1101 |
const QString dirPath = dirTemp.absolutePath(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1102 |
QDir dir(dirPath); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1103 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1104 |
//We create two dirs |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1105 |
dir.mkdir("a"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1106 |
dir.mkdir("b"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1107 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1108 |
//Create a file |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1109 |
QFile tempFile(dirPath + "/plop.txt"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1110 |
tempFile.open(QIODevice::WriteOnly | QIODevice::Text); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
QTextStream out(&tempFile); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1112 |
out << "The magic number is: " << 49 << "\n"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1113 |
tempFile.close(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1114 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1115 |
QNonNativeFileDialog fd(0, "TestFileDialog"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1116 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1117 |
fd.setDirectory(dir.absolutePath()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1118 |
fd.setViewMode(QFileDialog::List); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1119 |
fd.setAcceptMode(QFileDialog::AcceptSave); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1120 |
fd.setOption(QFileDialog::ShowDirsOnly, true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1121 |
fd.show(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1122 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1123 |
QApplication::setActiveWindow(&fd); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1124 |
QTest::qWaitForWindowShown(&fd); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1125 |
QTRY_COMPARE(fd.isVisible(), true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1126 |
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1127 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1128 |
QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1129 |
QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1130 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1131 |
fd.setOption(QFileDialog::ShowDirsOnly, false); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1132 |
QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1133 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1134 |
fd.setOption(QFileDialog::ShowDirsOnly, true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1135 |
QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1136 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1137 |
fd.setFileMode(QFileDialog::DirectoryOnly); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1140 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1141 |
fd.setFileMode(QFileDialog::AnyFile); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1142 |
QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1143 |
QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), false); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1144 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1145 |
fd.setDirectory(QDir::homePath()); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1146 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1147 |
//We remove the dirs |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1148 |
dir.rmdir("a"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1149 |
dir.rmdir("b"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1150 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1151 |
//we delete the file |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1152 |
tempFile.remove(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1153 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1154 |
dirTemp.cdUp(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1155 |
dirTemp.rmdir(tempName); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1156 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1157 |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1158 |
void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1159 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1160 |
QStringList filtersStr; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1161 |
filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1162 |
QString chosenFilterString("Text files (*.txt)"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1163 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1164 |
QNonNativeFileDialog fd(0, "TestFileDialog"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1165 |
fd.setAcceptMode(QFileDialog::AcceptSave); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1166 |
fd.setOption(QFileDialog::HideNameFilterDetails, true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1167 |
fd.setNameFilters(filtersStr); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
fd.selectNameFilter(chosenFilterString); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
fd.show(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1170 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1171 |
QApplication::setActiveWindow(&fd); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1172 |
QTest::qWaitForWindowShown(&fd); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1173 |
QTRY_COMPARE(fd.isVisible(), true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1174 |
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1175 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1176 |
QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1177 |
//We compare the current combobox text with the stripped version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1178 |
QCOMPARE(filters->currentText(), QString("Text files")); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1179 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1180 |
QNonNativeFileDialog fd2(0, "TestFileDialog"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1181 |
fd2.setAcceptMode(QFileDialog::AcceptSave); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1182 |
fd2.setOption(QFileDialog::HideNameFilterDetails, false); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1183 |
fd2.setNameFilters(filtersStr); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1184 |
fd2.selectNameFilter(chosenFilterString); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1185 |
fd2.show(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1186 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1187 |
QApplication::setActiveWindow(&fd2); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1188 |
QTest::qWaitForWindowShown(&fd2); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1189 |
QTRY_COMPARE(fd2.isVisible(), true); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1190 |
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2)); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1191 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1192 |
QComboBox *filters2 = qFindChild<QComboBox*>(&fd2, "fileTypeCombo"); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1193 |
//We compare the current combobox text with the non stripped version |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1194 |
QCOMPARE(filters2->currentText(), chosenFilterString); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1195 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1196 |
} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1197 |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1198 |
void tst_QFileDialog2::dontShowCompleterOnRoot() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1199 |
{ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1200 |
QNonNativeFileDialog fd(0, "TestFileDialog"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1201 |
fd.setAcceptMode(QFileDialog::AcceptSave); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1202 |
fd.show(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1203 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1204 |
QApplication::setActiveWindow(&fd); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1205 |
QTest::qWaitForWindowShown(&fd); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1206 |
QTRY_COMPARE(fd.isVisible(), true); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1207 |
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1208 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1209 |
fd.setDirectory(""); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1210 |
QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1211 |
QTRY_VERIFY(lineEdit->text().isEmpty()); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1212 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1213 |
//The gatherer thread will then return the result |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1214 |
QApplication::processEvents(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1215 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1216 |
QTRY_VERIFY(lineEdit->completer()->popup()->isHidden()); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1217 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1218 |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1219 |
QTEST_MAIN(tst_QFileDialog2) |
0 | 1220 |
#include "tst_qfiledialog2.moc" |