equal
deleted
inserted
replaced
85 { |
85 { |
86 setOption(QFileDialog::DontUseNativeDialog, true); |
86 setOption(QFileDialog::DontUseNativeDialog, true); |
87 } |
87 } |
88 }; |
88 }; |
89 |
89 |
90 class tst_QFiledialog : public QObject |
90 class tst_QFileDialog2 : public QObject |
91 { |
91 { |
92 Q_OBJECT |
92 Q_OBJECT |
93 |
93 |
94 public: |
94 public: |
95 tst_QFiledialog(); |
95 tst_QFileDialog2(); |
96 virtual ~tst_QFiledialog(); |
96 virtual ~tst_QFileDialog2(); |
97 |
97 |
98 public slots: |
98 public slots: |
99 void init(); |
99 void init(); |
100 void cleanup(); |
100 void cleanup(); |
101 |
101 |
136 |
136 |
137 private: |
137 private: |
138 QByteArray userSettings; |
138 QByteArray userSettings; |
139 }; |
139 }; |
140 |
140 |
141 tst_QFiledialog::tst_QFiledialog() |
141 tst_QFileDialog2::tst_QFileDialog2() |
142 { |
142 { |
143 #if defined(Q_OS_WINCE) |
143 #if defined(Q_OS_WINCE) |
144 qApp->setAutoMaximizeThreshold(-1); |
144 qApp->setAutoMaximizeThreshold(-1); |
145 #endif |
145 #endif |
146 } |
146 } |
147 |
147 |
148 tst_QFiledialog::~tst_QFiledialog() |
148 tst_QFileDialog2::~tst_QFileDialog2() |
149 { |
149 { |
150 } |
150 } |
151 |
151 |
152 void tst_QFiledialog::init() |
152 void tst_QFileDialog2::init() |
153 { |
153 { |
154 // Save the developers settings so they don't get mad when their sidebar folders are gone. |
154 // Save the developers settings so they don't get mad when their sidebar folders are gone. |
155 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
155 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
156 settings.beginGroup(QLatin1String("Qt")); |
156 settings.beginGroup(QLatin1String("Qt")); |
157 userSettings = settings.value(QLatin1String("filedialog")).toByteArray(); |
157 userSettings = settings.value(QLatin1String("filedialog")).toByteArray(); |
162 #if defined(Q_OS_WINCE) |
162 #if defined(Q_OS_WINCE) |
163 QTest::qWait(1000); |
163 QTest::qWait(1000); |
164 #endif |
164 #endif |
165 } |
165 } |
166 |
166 |
167 void tst_QFiledialog::cleanup() |
167 void tst_QFileDialog2::cleanup() |
168 { |
168 { |
169 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
169 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
170 settings.beginGroup(QLatin1String("Qt")); |
170 settings.beginGroup(QLatin1String("Qt")); |
171 settings.setValue(QLatin1String("filedialog"), userSettings); |
171 settings.setValue(QLatin1String("filedialog"), userSettings); |
172 } |
172 } |
173 |
173 |
174 void tst_QFiledialog::listRoot() |
174 void tst_QFileDialog2::listRoot() |
175 { |
175 { |
176 #if defined QT_BUILD_INTERNAL |
176 #if defined QT_BUILD_INTERNAL |
177 QFileInfoGatherer fileInfoGatherer; |
177 QFileInfoGatherer fileInfoGatherer; |
178 fileInfoGatherer.start(); |
178 fileInfoGatherer.start(); |
179 QTest::qWait(1500); |
179 QTest::qWait(1500); |
191 #endif |
191 #endif |
192 QCOMPARE(QFileInfoGatherer::fetchedRoot,true); |
192 QCOMPARE(QFileInfoGatherer::fetchedRoot,true); |
193 #endif |
193 #endif |
194 } |
194 } |
195 |
195 |
196 void tst_QFiledialog::heapCorruption() |
196 void tst_QFileDialog2::heapCorruption() |
197 { |
197 { |
198 QVector<QNonNativeFileDialog*> dialogs; |
198 QVector<QNonNativeFileDialog*> dialogs; |
199 for (int i=0; i < 10; i++) { |
199 for (int i=0; i < 10; i++) { |
200 QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL); |
200 QNonNativeFileDialog *f = new QNonNativeFileDialog(NULL); |
201 dialogs << f; |
201 dialogs << f; |
203 qDeleteAll(dialogs); |
203 qDeleteAll(dialogs); |
204 } |
204 } |
205 |
205 |
206 struct FriendlyQFileDialog : public QNonNativeFileDialog |
206 struct FriendlyQFileDialog : public QNonNativeFileDialog |
207 { |
207 { |
208 friend class tst_QFileDialog; |
208 friend class tst_QFileDialog2; |
209 Q_DECLARE_PRIVATE(QFileDialog) |
209 Q_DECLARE_PRIVATE(QFileDialog) |
210 }; |
210 }; |
211 |
211 |
212 |
212 |
213 void tst_QFiledialog::deleteDirAndFiles() |
213 void tst_QFileDialog2::deleteDirAndFiles() |
214 { |
214 { |
215 #if defined QT_BUILD_INTERNAL |
215 #if defined QT_BUILD_INTERNAL |
216 QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; |
216 QString tempPath = QDir::tempPath() + '/' + "QFileDialogTestDir4FullDelete"; |
217 QDir dir; |
217 QDir dir; |
218 QVERIFY(dir.mkpath(tempPath + "/foo")); |
218 QVERIFY(dir.mkpath(tempPath + "/foo")); |
240 QTest::qWait(2000); |
240 QTest::qWait(2000); |
241 QVERIFY(!info.exists()); |
241 QVERIFY(!info.exists()); |
242 #endif |
242 #endif |
243 } |
243 } |
244 |
244 |
245 void tst_QFiledialog::filter() |
245 void tst_QFileDialog2::filter() |
246 { |
246 { |
247 QNonNativeFileDialog fd; |
247 QNonNativeFileDialog fd; |
248 QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); |
248 QAction *hiddenAction = qFindChild<QAction*>(&fd, "qt_show_hidden_action"); |
249 QVERIFY(hiddenAction); |
249 QVERIFY(hiddenAction); |
250 QVERIFY(hiddenAction->isEnabled()); |
250 QVERIFY(hiddenAction->isEnabled()); |
253 filter |= QDir::Hidden; |
253 filter |= QDir::Hidden; |
254 fd.setFilter(filter); |
254 fd.setFilter(filter); |
255 QVERIFY(hiddenAction->isChecked()); |
255 QVERIFY(hiddenAction->isChecked()); |
256 } |
256 } |
257 |
257 |
258 void tst_QFiledialog::showNameFilterDetails() |
258 void tst_QFileDialog2::showNameFilterDetails() |
259 { |
259 { |
260 QNonNativeFileDialog fd; |
260 QNonNativeFileDialog fd; |
261 QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
261 QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
262 QVERIFY(filters); |
262 QVERIFY(filters); |
263 QVERIFY(fd.isNameFilterDetailsVisible()); |
263 QVERIFY(fd.isNameFilterDetailsVisible()); |
278 QCOMPARE(filters->itemText(0), filterChoices.at(0)); |
278 QCOMPARE(filters->itemText(0), filterChoices.at(0)); |
279 QCOMPARE(filters->itemText(1), filterChoices.at(1)); |
279 QCOMPARE(filters->itemText(1), filterChoices.at(1)); |
280 QCOMPARE(filters->itemText(2), filterChoices.at(2)); |
280 QCOMPARE(filters->itemText(2), filterChoices.at(2)); |
281 } |
281 } |
282 |
282 |
283 void tst_QFiledialog::unc() |
283 void tst_QFileDialog2::unc() |
284 { |
284 { |
285 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
285 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
286 // Only test UNC on Windows./ |
286 // Only test UNC on Windows./ |
287 QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable"); |
287 QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable"); |
288 #else |
288 #else |
293 QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
293 QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
294 QVERIFY(model); |
294 QVERIFY(model); |
295 QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); |
295 QCOMPARE(model->index(fd.directory().absolutePath()), model->index(dir)); |
296 } |
296 } |
297 |
297 |
298 void tst_QFiledialog::emptyUncPath() |
298 void tst_QFileDialog2::emptyUncPath() |
299 { |
299 { |
300 QNonNativeFileDialog fd; |
300 QNonNativeFileDialog fd; |
301 fd.show(); |
301 fd.show(); |
302 QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
302 QLineEdit *lineEdit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
303 QVERIFY(lineEdit); |
303 QVERIFY(lineEdit); |
306 QTest::keyPress(lineEdit, Qt::Key_Backslash); |
306 QTest::keyPress(lineEdit, Qt::Key_Backslash); |
307 QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
307 QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
308 QVERIFY(model); |
308 QVERIFY(model); |
309 } |
309 } |
310 |
310 |
311 void tst_QFiledialog::task178897_minimumSize() |
311 void tst_QFileDialog2::task178897_minimumSize() |
312 { |
312 { |
313 QNonNativeFileDialog fd; |
313 QNonNativeFileDialog fd; |
314 QSize oldMs = fd.layout()->minimumSize(); |
314 QSize oldMs = fd.layout()->minimumSize(); |
315 QStringList history = fd.history(); |
315 QStringList history = fd.history(); |
316 history << QDir::toNativeSeparators("/verylongdirectory/" |
316 history << QDir::toNativeSeparators("/verylongdirectory/" |
320 |
320 |
321 QSize ms = fd.layout()->minimumSize(); |
321 QSize ms = fd.layout()->minimumSize(); |
322 QVERIFY(ms.width() <= oldMs.width()); |
322 QVERIFY(ms.width() <= oldMs.width()); |
323 } |
323 } |
324 |
324 |
325 void tst_QFiledialog::task180459_lastDirectory_data() |
325 void tst_QFileDialog2::task180459_lastDirectory_data() |
326 { |
326 { |
327 QTest::addColumn<QString>("path"); |
327 QTest::addColumn<QString>("path"); |
328 QTest::addColumn<QString>("directory"); |
328 QTest::addColumn<QString>("directory"); |
329 QTest::addColumn<bool>("isEnabled"); |
329 QTest::addColumn<bool>("isEnabled"); |
330 QTest::addColumn<QString>("result"); |
330 QTest::addColumn<QString>("result"); |
343 << QDir::tempPath() << true |
343 << QDir::tempPath() << true |
344 << QDir::tempPath() + QDir::separator() + "foo.txt"; |
344 << QDir::tempPath() + QDir::separator() + "foo.txt"; |
345 |
345 |
346 } |
346 } |
347 |
347 |
348 void tst_QFiledialog::task180459_lastDirectory() |
348 void tst_QFileDialog2::task180459_lastDirectory() |
349 { |
349 { |
350 //first visit the temp directory and close the dialog |
350 //first visit the temp directory and close the dialog |
351 QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); |
351 QNonNativeFileDialog *dlg = new QNonNativeFileDialog(0, "", QDir::tempPath()); |
352 QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); |
352 QFileSystemModel *model = qFindChild<QFileSystemModel*>(dlg, "qt_filesystem_model"); |
353 QVERIFY(model); |
353 QVERIFY(model); |
447 sortProxy *proxyModel = new sortProxy(this); |
447 sortProxy *proxyModel = new sortProxy(this); |
448 setProxyModel(proxyModel); |
448 setProxyModel(proxyModel); |
449 } |
449 } |
450 }; |
450 }; |
451 |
451 |
452 void tst_QFiledialog::task227304_proxyOnFileDialog() |
452 void tst_QFileDialog2::task227304_proxyOnFileDialog() |
453 { |
453 { |
454 #if defined QT_BUILD_INTERNAL |
454 #if defined QT_BUILD_INTERNAL |
455 QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); |
455 QNonNativeFileDialog fd(0, "", QDir::currentPath(), 0); |
456 fd.setProxyModel(new FilterDirModel(QDir::currentPath())); |
456 fd.setProxyModel(new FilterDirModel(QDir::currentPath())); |
457 fd.show(); |
457 fd.show(); |
486 QTest::qWait(250); |
486 QTest::qWait(250); |
487 //We shouldn't crash |
487 //We shouldn't crash |
488 #endif |
488 #endif |
489 } |
489 } |
490 |
490 |
491 void tst_QFiledialog::task227930_correctNavigationKeyboardBehavior() |
491 void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() |
492 { |
492 { |
493 QDir current = QDir::currentPath(); |
493 QDir current = QDir::currentPath(); |
494 current.mkdir("test"); |
494 current.mkdir("test"); |
495 current.cd("test"); |
495 current.cd("test"); |
496 QFile file("test/out.txt"); |
496 QFile file("test/out.txt"); |
525 current.rmdir("test"); |
525 current.rmdir("test"); |
526 current.rmdir("test2"); |
526 current.rmdir("test2"); |
527 } |
527 } |
528 |
528 |
529 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
529 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
530 void tst_QFiledialog::task226366_lowerCaseHardDriveWindows() |
530 void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() |
531 { |
531 { |
532 QNonNativeFileDialog fd; |
532 QNonNativeFileDialog fd; |
533 fd.setDirectory(QDir::root().path()); |
533 fd.setDirectory(QDir::root().path()); |
534 fd.show(); |
534 fd.show(); |
535 QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
535 QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
551 QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
551 QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
552 QCOMPARE(edit->text(), QString("C:")); |
552 QCOMPARE(edit->text(), QString("C:")); |
553 } |
553 } |
554 #endif |
554 #endif |
555 |
555 |
556 void tst_QFiledialog::completionOnLevelAfterRoot() |
556 void tst_QFileDialog2::completionOnLevelAfterRoot() |
557 { |
557 { |
558 QNonNativeFileDialog fd; |
558 QNonNativeFileDialog fd; |
559 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
559 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
560 fd.setDirectory("C:"); |
560 fd.setDirectory("C:"); |
561 QDir current = fd.directory(); |
561 QDir current = fd.directory(); |
590 #else |
590 #else |
591 QCOMPARE(edit->text(), QString("etc")); |
591 QCOMPARE(edit->text(), QString("etc")); |
592 #endif |
592 #endif |
593 } |
593 } |
594 |
594 |
595 void tst_QFiledialog::task233037_selectingDirectory() |
595 void tst_QFileDialog2::task233037_selectingDirectory() |
596 { |
596 { |
597 QDir current = QDir::currentPath(); |
597 QDir current = QDir::currentPath(); |
598 current.mkdir("test"); |
598 current.mkdir("test"); |
599 QNonNativeFileDialog fd; |
599 QNonNativeFileDialog fd; |
600 fd.setViewMode(QFileDialog::List); |
600 fd.setViewMode(QFileDialog::List); |
613 QVERIFY(button); |
613 QVERIFY(button); |
614 QCOMPARE(button->isEnabled(), true); |
614 QCOMPARE(button->isEnabled(), true); |
615 current.rmdir("test"); |
615 current.rmdir("test"); |
616 } |
616 } |
617 |
617 |
618 void tst_QFiledialog::task235069_hideOnEscape() |
618 void tst_QFileDialog2::task235069_hideOnEscape() |
619 { |
619 { |
620 QDir current = QDir::currentPath(); |
620 QDir current = QDir::currentPath(); |
621 QNonNativeFileDialog fd; |
621 QNonNativeFileDialog fd; |
622 fd.setViewMode(QFileDialog::List); |
622 fd.setViewMode(QFileDialog::List); |
623 fd.setDirectory(current.absolutePath()); |
623 fd.setDirectory(current.absolutePath()); |
635 QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit"); |
635 QLineEdit *edit = qFindChild<QLineEdit*>(&fd2, "fileNameEdit"); |
636 QTest::keyClick(edit, Qt::Key_Escape); |
636 QTest::keyClick(edit, Qt::Key_Escape); |
637 QCOMPARE(fd2.isVisible(), false); |
637 QCOMPARE(fd2.isVisible(), false); |
638 } |
638 } |
639 |
639 |
640 void tst_QFiledialog::task236402_dontWatchDeletedDir() |
640 void tst_QFileDialog2::task236402_dontWatchDeletedDir() |
641 { |
641 { |
642 #if defined QT_BUILD_INTERNAL |
642 #if defined QT_BUILD_INTERNAL |
643 //THIS TEST SHOULD NOT DISPLAY WARNINGS |
643 //THIS TEST SHOULD NOT DISPLAY WARNINGS |
644 QDir current = QDir::currentPath(); |
644 QDir current = QDir::currentPath(); |
645 //make sure it is the first on the list |
645 //make sure it is the first on the list |
660 fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/"); |
660 fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/"); |
661 QTest::qWait(1000); |
661 QTest::qWait(1000); |
662 #endif |
662 #endif |
663 } |
663 } |
664 |
664 |
665 void tst_QFiledialog::task203703_returnProperSeparator() |
665 void tst_QFileDialog2::task203703_returnProperSeparator() |
666 { |
666 { |
667 QDir current = QDir::currentPath(); |
667 QDir current = QDir::currentPath(); |
668 current.mkdir("aaaaaaaaaaaaaaaaaa"); |
668 current.mkdir("aaaaaaaaaaaaaaaaaa"); |
669 QNonNativeFileDialog fd; |
669 QNonNativeFileDialog fd; |
670 fd.setDirectory(current.absolutePath()); |
670 fd.setDirectory(current.absolutePath()); |
685 QVERIFY(result.at(result.count() - 1) != '/'); |
685 QVERIFY(result.at(result.count() - 1) != '/'); |
686 QVERIFY(!result.contains('\\')); |
686 QVERIFY(!result.contains('\\')); |
687 current.rmdir("aaaaaaaaaaaaaaaaaa"); |
687 current.rmdir("aaaaaaaaaaaaaaaaaa"); |
688 } |
688 } |
689 |
689 |
690 void tst_QFiledialog::task228844_ensurePreviousSorting() |
690 void tst_QFileDialog2::task228844_ensurePreviousSorting() |
691 { |
691 { |
692 QDir current = QDir::currentPath(); |
692 QDir current = QDir::currentPath(); |
693 current.mkdir("aaaaaaaaaaaaaaaaaa"); |
693 current.mkdir("aaaaaaaaaaaaaaaaaa"); |
694 current.cd("aaaaaaaaaaaaaaaaaa"); |
694 current.cd("aaaaaaaaaaaaaaaaaa"); |
695 current.mkdir("a"); |
695 current.mkdir("a"); |
787 current.cdUp(); |
787 current.cdUp(); |
788 current.rmdir("aaaaaaaaaaaaaaaaaa"); |
788 current.rmdir("aaaaaaaaaaaaaaaaaa"); |
789 } |
789 } |
790 |
790 |
791 |
791 |
792 void tst_QFiledialog::task239706_editableFilterCombo() |
792 void tst_QFileDialog2::task239706_editableFilterCombo() |
793 { |
793 { |
794 QNonNativeFileDialog d; |
794 QNonNativeFileDialog d; |
795 d.setNameFilter("*.cpp *.h"); |
795 d.setNameFilter("*.cpp *.h"); |
796 |
796 |
797 d.show(); |
797 d.show(); |
810 QTest::mouseClick(filterCombo, Qt::LeftButton); |
810 QTest::mouseClick(filterCombo, Qt::LeftButton); |
811 QTest::keyPress(filterCombo, Qt::Key_X); |
811 QTest::keyPress(filterCombo, Qt::Key_X); |
812 QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure |
812 QTest::keyPress(filterCombo, Qt::Key_Enter); // should not trigger assertion failure |
813 } |
813 } |
814 |
814 |
815 void tst_QFiledialog::task218353_relativePaths() |
815 void tst_QFileDialog2::task218353_relativePaths() |
816 { |
816 { |
817 QDir appDir = QDir::current(); |
817 QDir appDir = QDir::current(); |
818 QVERIFY(appDir.cdUp() != false); |
818 QVERIFY(appDir.cdUp() != false); |
819 QNonNativeFileDialog d(0, "TestDialog", ".."); |
819 QNonNativeFileDialog d(0, "TestDialog", ".."); |
820 QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
820 QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
827 d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../")); |
827 d.setDirectory(appDir.absolutePath() + QLatin1String("/test/../test/../")); |
828 QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
828 QCOMPARE(d.directory().absolutePath(), appDir.absolutePath()); |
829 appDir.rmdir("test"); |
829 appDir.rmdir("test"); |
830 } |
830 } |
831 |
831 |
832 void tst_QFiledialog::task251321_sideBarHiddenEntries() |
832 void tst_QFileDialog2::task251321_sideBarHiddenEntries() |
833 { |
833 { |
834 #if defined QT_BUILD_INTERNAL |
834 #if defined QT_BUILD_INTERNAL |
835 QNonNativeFileDialog fd; |
835 QNonNativeFileDialog fd; |
836 |
836 |
837 QDir current = QDir::currentPath(); |
837 QDir current = QDir::currentPath(); |
887 model()->removeRow(indexes.at(i).row()); |
887 model()->removeRow(indexes.at(i).row()); |
888 } |
888 } |
889 }; |
889 }; |
890 #endif |
890 #endif |
891 |
891 |
892 void tst_QFiledialog::task251341_sideBarRemoveEntries() |
892 void tst_QFileDialog2::task251341_sideBarRemoveEntries() |
893 { |
893 { |
894 #if defined QT_BUILD_INTERNAL |
894 #if defined QT_BUILD_INTERNAL |
895 QNonNativeFileDialog fd; |
895 QNonNativeFileDialog fd; |
896 |
896 |
897 QDir current = QDir::currentPath(); |
897 QDir current = QDir::currentPath(); |
952 |
952 |
953 current.rmdir("testDir"); |
953 current.rmdir("testDir"); |
954 #endif |
954 #endif |
955 } |
955 } |
956 |
956 |
957 void tst_QFiledialog::task254490_selectFileMultipleTimes() |
957 void tst_QFileDialog2::task254490_selectFileMultipleTimes() |
958 { |
958 { |
959 QString tempPath = QDir::tempPath(); |
959 QString tempPath = QDir::tempPath(); |
960 QTemporaryFile *t; |
960 QTemporaryFile *t; |
961 t = new QTemporaryFile; |
961 t = new QTemporaryFile; |
962 t->open(); |
962 t->open(); |
984 QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0); |
984 QCOMPARE(list->selectionModel()->selectedRows(0).count(), 0); |
985 |
985 |
986 t->deleteLater(); |
986 t->deleteLater(); |
987 } |
987 } |
988 |
988 |
989 void tst_QFiledialog::task257579_sideBarWithNonCleanUrls() |
989 void tst_QFileDialog2::task257579_sideBarWithNonCleanUrls() |
990 { |
990 { |
991 #if defined QT_BUILD_INTERNAL |
991 #if defined QT_BUILD_INTERNAL |
992 QDir tempDir = QDir::temp(); |
992 QDir tempDir = QDir::temp(); |
993 QLatin1String dirname("autotest_task257579"); |
993 QLatin1String dirname("autotest_task257579"); |
994 tempDir.rmdir(dirname); //makes sure it doesn't exist any more |
994 tempDir.rmdir(dirname); //makes sure it doesn't exist any more |
1010 //all tests are finished, we can remove the temporary dir |
1010 //all tests are finished, we can remove the temporary dir |
1011 QVERIFY(tempDir.rmdir(dirname)); |
1011 QVERIFY(tempDir.rmdir(dirname)); |
1012 #endif |
1012 #endif |
1013 } |
1013 } |
1014 |
1014 |
1015 void tst_QFiledialog::task259105_filtersCornerCases() |
1015 void tst_QFileDialog2::task259105_filtersCornerCases() |
1016 { |
1016 { |
1017 QNonNativeFileDialog fd(0, "TestFileDialog"); |
1017 QNonNativeFileDialog fd(0, "TestFileDialog"); |
1018 fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); |
1018 fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); |
1019 fd.setOption(QFileDialog::HideNameFilterDetails, true); |
1019 fd.setOption(QFileDialog::HideNameFilterDetails, true); |
1020 fd.show(); |
1020 fd.show(); |
1054 QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); |
1054 QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); |
1055 filters->setCurrentIndex(1); |
1055 filters->setCurrentIndex(1); |
1056 QCOMPARE(filters->currentText(), QLatin1String("Text Files")); |
1056 QCOMPARE(filters->currentText(), QLatin1String("Text Files")); |
1057 } |
1057 } |
1058 |
1058 |
1059 void tst_QFiledialog::QTBUG4419_lineEditSelectAll() |
1059 void tst_QFileDialog2::QTBUG4419_lineEditSelectAll() |
1060 { |
1060 { |
1061 QString tempPath = QDir::tempPath(); |
1061 QString tempPath = QDir::tempPath(); |
1062 QTemporaryFile *t; |
1062 QTemporaryFile *t; |
1063 t = new QTemporaryFile; |
1063 t = new QTemporaryFile; |
1064 t->open(); |
1064 t->open(); |
1080 |
1080 |
1081 QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); |
1081 QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); |
1082 QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); |
1082 QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); |
1083 } |
1083 } |
1084 |
1084 |
1085 void tst_QFiledialog::QTBUG6558_showDirsOnly() |
1085 void tst_QFileDialog2::QTBUG6558_showDirsOnly() |
1086 { |
1086 { |
1087 const QString tempPath = QDir::tempPath(); |
1087 const QString tempPath = QDir::tempPath(); |
1088 QDir dirTemp(tempPath); |
1088 QDir dirTemp(tempPath); |
1089 const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); |
1089 const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); |
1090 dirTemp.mkdir(tempName); |
1090 dirTemp.mkdir(tempName); |
1146 |
1146 |
1147 dirTemp.cdUp(); |
1147 dirTemp.cdUp(); |
1148 dirTemp.rmdir(tempName); |
1148 dirTemp.rmdir(tempName); |
1149 } |
1149 } |
1150 |
1150 |
1151 void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() |
1151 void tst_QFileDialog2::QTBUG4842_selectFilterWithHideNameFilterDetails() |
1152 { |
1152 { |
1153 QStringList filtersStr; |
1153 QStringList filtersStr; |
1154 filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; |
1154 filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; |
1155 QString chosenFilterString("Text files (*.txt)"); |
1155 QString chosenFilterString("Text files (*.txt)"); |
1156 |
1156 |
1186 //We compare the current combobox text with the non stripped version |
1186 //We compare the current combobox text with the non stripped version |
1187 QCOMPARE(filters2->currentText(), chosenFilterString); |
1187 QCOMPARE(filters2->currentText(), chosenFilterString); |
1188 |
1188 |
1189 } |
1189 } |
1190 |
1190 |
1191 QTEST_MAIN(tst_QFiledialog) |
1191 QTEST_MAIN(tst_QFileDialog2) |
1192 #include "tst_qfiledialog2.moc" |
1192 #include "tst_qfiledialog2.moc" |