summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-04-28 08:44:53 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-05-01 06:03:10 +0000
commit315b359bc199fcc9492fa33f573d6c43d22b3b6a (patch)
treef883e9a5d0477cd7f84475a66c55f86121aa3cfd /src/widgets
parent3ce2dd391e30bde9387ddf9e84b159dcd0ad3c07 (diff)
QFileDialog: Stabilize tests.
The init()/cleanup() code in tst_qfiledialog and tst_qfiledialog2 currently differs and fails to clean up the settings file since it only removes the legacy settings under the Qt group and instantiates a new QFileDialog while the QSettings class is still in scope. Also, it has no means of clearing the setLastVisitedDirectory(), which causes the tst_QFiledialog::completer() and tst_QFiledialog::history() tests to interfere, leaving the settings in an invalid state. tst_qfiledialog2 does not use QStandardPaths::setTestModeEnabled((). - Ensure the last visited URL is always clean by making QFileDialogPrivate::setLastVisitedDirectory() static and calling it from init(). - Introduce a cleanupSettingsFile() function to the tests that cleans both groups and call it from initTestCase() and cleanup() to ensure a clean state. - Add QStandardPaths::setTestModeEnabled() to tst_qfiledialog2. Fixes sporadic test fails when executing tst_QFiledialog::completer() and tst_QFiledialog::history() in a sequence. Task-number: QTBUG-45764 Change-Id: I24de3caabf77be067b385d64ff11b7a07fe12b72 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp4
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 9e5548ab4c..8590467abc 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -906,7 +906,7 @@ void QFileDialog::setDirectory(const QString &directory)
return;
QUrl newDirUrl = QUrl::fromLocalFile(newDirectory);
- d->setLastVisitedDirectory(newDirUrl);
+ QFileDialogPrivate::setLastVisitedDirectory(newDirUrl);
d->options->setInitialDirectory(QUrl::fromLocalFile(directory));
if (!d->usingWidgets()) {
@@ -967,7 +967,7 @@ void QFileDialog::setDirectoryUrl(const QUrl &directory)
if (!directory.isValid())
return;
- d->setLastVisitedDirectory(directory);
+ QFileDialogPrivate::setLastVisitedDirectory(directory);
d->options->setInitialDirectory(directory);
if (d->nativeDialogInUse)
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 8a10896966..f610e46f83 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -187,7 +187,7 @@ public:
#endif
bool restoreWidgetState(QStringList &history, int splitterPosition);
- void setLastVisitedDirectory(const QUrl &dir);
+ static void setLastVisitedDirectory(const QUrl &dir);
void retranslateWindowTitle();
void retranslateStrings();
void emitFilesSelected(const QStringList &files);