diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-01-06 13:31:34 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-01-06 13:34:56 (GMT) |
commit | 0de487a10f3a54c46f30042b96c321f982e01a90 (patch) | |
tree | 00352de4bdd56ad903a9333164536bc2823cf16e /tests/auto/qfiledialog2 | |
parent | 59a2ed52a780afea84c118054fb7de2440a5d17f (diff) | |
download | Qt-0de487a10f3a54c46f30042b96c321f982e01a90.zip Qt-0de487a10f3a54c46f30042b96c321f982e01a90.tar.gz Qt-0de487a10f3a54c46f30042b96c321f982e01a90.tar.bz2 |
Fix default filter selection when using HideNameFilterDetails option.
When you have HideNameFilterDetails on, comparing the default filter
given in parameter for selectNameFilter has to be done with the striped
version of the filter, i.e. without the details.
Task-number:QTBUG-4842
Reviewed-by:gabriel
Reviewed-by:olivier
Diffstat (limited to 'tests/auto/qfiledialog2')
-rw-r--r-- | tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 9757fa0..c3f88c4 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -131,6 +131,7 @@ private slots: void QTBUG4419_lineEditSelectAll(); void QTBUG6558_showDirsOnly(); + void QTBUG4842_selectFilterWithHideNameFilterDetails(); private: QByteArray userSettings; @@ -1107,5 +1108,45 @@ void tst_QFiledialog::QTBUG6558_showDirsOnly() dirTemp.rmdir(tempName); } +void tst_QFiledialog::QTBUG4842_selectFilterWithHideNameFilterDetails() +{ + QStringList filtersStr; + filtersStr << "Images (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "XML files (*.xml)"; + QString chosenFilterString("Text files (*.txt)"); + + QNonNativeFileDialog fd(0, "TestFileDialog"); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.setOption(QFileDialog::HideNameFilterDetails, true); + fd.setNameFilters(filtersStr); + fd.selectNameFilter(chosenFilterString); + fd.show(); + + QApplication::setActiveWindow(&fd); + QTest::qWaitForWindowShown(&fd); + QTRY_COMPARE(fd.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd)); + + QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo"); + //We compare the current combobox text with the stripped version + QCOMPARE(filters->currentText(), QString("Text files")); + + QNonNativeFileDialog fd2(0, "TestFileDialog"); + fd2.setAcceptMode(QFileDialog::AcceptSave); + fd2.setOption(QFileDialog::HideNameFilterDetails, false); + fd2.setNameFilters(filtersStr); + fd2.selectNameFilter(chosenFilterString); + fd2.show(); + + QApplication::setActiveWindow(&fd2); + QTest::qWaitForWindowShown(&fd2); + QTRY_COMPARE(fd2.isVisible(), true); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&fd2)); + + QComboBox *filters2 = qFindChild<QComboBox*>(&fd2, "fileTypeCombo"); + //We compare the current combobox text with the non stripped version + QCOMPARE(filters2->currentText(), chosenFilterString); + +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog2.moc" |