114 void task227304_proxyOnFileDialog(); |
114 void task227304_proxyOnFileDialog(); |
115 void task227930_correctNavigationKeyboardBehavior(); |
115 void task227930_correctNavigationKeyboardBehavior(); |
116 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
116 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
117 void task226366_lowerCaseHardDriveWindows(); |
117 void task226366_lowerCaseHardDriveWindows(); |
118 #endif |
118 #endif |
|
119 void completionOnLevelAfterRoot(); |
119 void task233037_selectingDirectory(); |
120 void task233037_selectingDirectory(); |
120 void task235069_hideOnEscape(); |
121 void task235069_hideOnEscape(); |
121 void task236402_dontWatchDeletedDir(); |
122 void task236402_dontWatchDeletedDir(); |
122 void task203703_returnProperSeparator(); |
123 void task203703_returnProperSeparator(); |
123 void task228844_ensurePreviousSorting(); |
124 void task228844_ensurePreviousSorting(); |
548 QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
551 QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
549 QCOMPARE(edit->text(), QString("C:")); |
552 QCOMPARE(edit->text(), QString("C:")); |
550 } |
553 } |
551 #endif |
554 #endif |
552 |
555 |
|
556 void tst_QFiledialog::completionOnLevelAfterRoot() |
|
557 { |
|
558 QNonNativeFileDialog fd; |
|
559 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
560 fd.setDirectory("C:"); |
|
561 QDir current = fd.directory(); |
|
562 current.mkdir("completionOnLevelAfterRootTest"); |
|
563 #else |
|
564 fd.setFilter(QDir::Hidden | QDir::AllDirs | QDir::Files | QDir::System); |
|
565 fd.setDirectory("/"); |
|
566 QDir etc("/etc"); |
|
567 if (!etc.exists()) |
|
568 QSKIP("This test requires to have an etc directory under /", SkipAll); |
|
569 #endif |
|
570 fd.show(); |
|
571 QLineEdit *edit = qFindChild<QLineEdit*>(&fd, "fileNameEdit"); |
|
572 QTest::qWait(2000); |
|
573 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
574 //I love testlib :D |
|
575 QTest::keyClick(edit, Qt::Key_C); |
|
576 QTest::keyClick(edit, Qt::Key_O); |
|
577 QTest::keyClick(edit, Qt::Key_M); |
|
578 QTest::keyClick(edit, Qt::Key_P); |
|
579 QTest::keyClick(edit, Qt::Key_L); |
|
580 #else |
|
581 QTest::keyClick(edit, Qt::Key_E); |
|
582 QTest::keyClick(edit, Qt::Key_T); |
|
583 #endif |
|
584 QTest::qWait(200); |
|
585 QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); |
|
586 QTest::qWait(200); |
|
587 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) |
|
588 QCOMPARE(edit->text(), QString("completionOnLevelAfterRootTest")); |
|
589 current.rmdir("completionOnLevelAfterRootTest"); |
|
590 #else |
|
591 QCOMPARE(edit->text(), QString("etc")); |
|
592 #endif |
|
593 } |
|
594 |
553 void tst_QFiledialog::task233037_selectingDirectory() |
595 void tst_QFiledialog::task233037_selectingDirectory() |
554 { |
596 { |
555 QDir current = QDir::currentPath(); |
597 QDir current = QDir::currentPath(); |
556 current.mkdir("test"); |
598 current.mkdir("test"); |
557 QNonNativeFileDialog fd; |
599 QNonNativeFileDialog fd; |
1038 |
1080 |
1039 QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); |
1081 QCOMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName()); |
1040 QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); |
1082 QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName()); |
1041 } |
1083 } |
1042 |
1084 |
|
1085 void tst_QFiledialog::QTBUG6558_showDirsOnly() |
|
1086 { |
|
1087 const QString tempPath = QDir::tempPath(); |
|
1088 QDir dirTemp(tempPath); |
|
1089 const QString tempName = QLatin1String("showDirsOnly.") + QString::number(qrand()); |
|
1090 dirTemp.mkdir(tempName); |
|
1091 dirTemp.cd(tempName); |
|
1092 QTRY_VERIFY(dirTemp.exists()); |
|
1093 |
|
1094 const QString dirPath = dirTemp.absolutePath(); |
|
1095 QDir dir(dirPath); |
|
1096 |
|
1097 //We create two dirs |
|
1098 dir.mkdir("a"); |
|
1099 dir.mkdir("b"); |
|
1100 |
|
1101 //Create a file |
|
1102 QFile tempFile(dirPath + "/plop.txt"); |
|
1103 tempFile.open(QIODevice::WriteOnly | QIODevice::Text); |
|
1104 QTextStream out(&tempFile); |
|
1105 out << "The magic number is: " << 49 << "\n"; |
|
1106 tempFile.close(); |
|
1107 |
|
1108 QNonNativeFileDialog fd(0, "TestFileDialog"); |
|
1109 |
|
1110 fd.setDirectory(dir.absolutePath()); |
|
1111 fd.setViewMode(QFileDialog::List); |
|
1112 fd.setAcceptMode(QFileDialog::AcceptSave); |
|
1113 fd.setOption(QFileDialog::ShowDirsOnly, true); |
|
1114 fd.show(); |
|
1115 |
|
1116 QApplication::setActiveWindow(&fd); |
|
1117 QTest::qWaitForWindowShown(&fd); |
|
1118 QTRY_COMPARE(fd.isVisible(), true); |
|
1119 QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
|
1120 |
|
1121 QFileSystemModel *model = qFindChild<QFileSystemModel*>(&fd, "qt_filesystem_model"); |
|
1122 QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
|
1123 |
|
1124 fd.setOption(QFileDialog::ShowDirsOnly, false); |
|
1125 QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); |
|
1126 |
|
1127 fd.setOption(QFileDialog::ShowDirsOnly, true); |
|
1128 QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
|
1129 |
|
1130 fd.setFileMode(QFileDialog::DirectoryOnly); |
|
1131 QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 2); |
|
1132 QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), true); |
|
1133 |
|
1134 fd.setFileMode(QFileDialog::AnyFile); |
|
1135 QTRY_COMPARE(model->rowCount(model->index(dir.absolutePath())), 3); |
|
1136 QTRY_COMPARE(bool(fd.options() & QFileDialog::ShowDirsOnly), false); |
|
1137 |
|
1138 fd.setDirectory(QDir::homePath()); |
|
1139 |
|
1140 //We remove the dirs |
|
1141 dir.rmdir("a"); |
|
1142 dir.rmdir("b"); |
|
1143 |
|
1144 //we delete the file |
|
1145 tempFile.remove(); |
|
1146 |
|
1147 dirTemp.cdUp(); |
|
1148 dirTemp.rmdir(tempName); |
|
1149 } |
|
1150 |
|
1151 void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() |
|
1152 { |
|
1153 QStringList filtersStr; |
|
1154 filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; |
|
1155 QString chosenFilterString("Text files (*.txt)"); |
|
1156 |
|
1157 QNonNativeFileDialog fd(0, "TestFileDialog"); |
|
1158 fd.setAcceptMode(QFileDialog::AcceptSave); |
|
1159 fd.setOption(QFileDialog::HideNameFilterDetails, true); |
|
1160 fd.setNameFilters(filtersStr); |
|
1161 fd.selectNameFilter(chosenFilterString); |
|
1162 fd.show(); |
|
1163 |
|
1164 QApplication::setActiveWindow(&fd); |
|
1165 QTest::qWaitForWindowShown(&fd); |
|
1166 QTRY_COMPARE(fd.isVisible(), true); |
|
1167 QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); |
|
1168 |
|
1169 QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); |
|
1170 //We compare the current combobox text with the stripped version |
|
1171 QCOMPARE(filters->currentText(), QString("Text files")); |
|
1172 |
|
1173 QNonNativeFileDialog fd2(0, "TestFileDialog"); |
|
1174 fd2.setAcceptMode(QFileDialog::AcceptSave); |
|
1175 fd2.setOption(QFileDialog::HideNameFilterDetails, false); |
|
1176 fd2.setNameFilters(filtersStr); |
|
1177 fd2.selectNameFilter(chosenFilterString); |
|
1178 fd2.show(); |
|
1179 |
|
1180 QApplication::setActiveWindow(&fd2); |
|
1181 QTest::qWaitForWindowShown(&fd2); |
|
1182 QTRY_COMPARE(fd2.isVisible(), true); |
|
1183 QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2)); |
|
1184 |
|
1185 QComboBox *filters2 = qFindChild<QComboBox*>(&fd2, "fileTypeCombo"); |
|
1186 //We compare the current combobox text with the non stripped version |
|
1187 QCOMPARE(filters2->currentText(), chosenFilterString); |
|
1188 |
|
1189 } |
|
1190 |
1043 QTEST_MAIN(tst_QFiledialog) |
1191 QTEST_MAIN(tst_QFiledialog) |
1044 #include "tst_qfiledialog2.moc" |
1192 #include "tst_qfiledialog2.moc" |