diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-05-06 12:03:33 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-06 16:35:56 +0200 |
commit | d915432c23177a5d7f9ffd0d6899aab13ddc4c2b (patch) | |
tree | 2e06baa6e095500feba90846730ead3f25ab8624 /tests/auto/widgets | |
parent | a17aaed1cd99d4a00912e4a1c631d49f2c7c3cc4 (diff) |
QFileDialog: Return empty QUrl from the static get..FileUrl() functions.
Task-number: QTBUG-38672
Change-Id: Idf554cd93d1a79db7c82f3165bd128fb31ead3e5
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 047df0d3f2..096658ae02 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -171,6 +171,7 @@ private slots: void tildeExpansion(); #endif // QT_BUILD_INTERNAL #endif + void getFileUrl(); private: QByteArray userSettings; @@ -1429,5 +1430,49 @@ void tst_QFiledialog::tildeExpansion() #endif // QT_BUILD_INTERNAL #endif +class DialogRejecter : public QObject +{ + Q_OBJECT +public: + DialogRejecter() + { + QTimer *timer = new QTimer(this); + timer->setInterval(1000); + connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog); + timer->start(); + } + +public slots: + void rejectFileDialog() + { + if (QWidget *w = QApplication::activeModalWidget()) + if (QDialog *d = qobject_cast<QDialog *>(w)) + d->reject(); + } +}; + +void tst_QFiledialog::getFileUrl() +{ + // QTBUG-38672 , static functions should return empty Urls + const QFileDialog::Options options = QFileDialog::DontUseNativeDialog; + DialogRejecter dr; + + QUrl url = QFileDialog::getOpenFileUrl(0, QStringLiteral("getOpenFileUrl"), + QUrl(), QString(), Q_NULLPTR, options); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + + url = QFileDialog::getExistingDirectoryUrl(0, QStringLiteral("getExistingDirectoryUrl"), + QUrl(), options | QFileDialog::ShowDirsOnly); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + + url = QFileDialog::getSaveFileUrl(0, QStringLiteral("getSaveFileUrl"), + QUrl(), QString(), Q_NULLPTR, options); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" |