summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-04-11 10:23:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-21 15:58:51 +0100
commitecd3027d385fd0f41cf7d970fc9273965e04ffc3 (patch)
tree61f60704907adb906f81e8ee4d9f4e0e0b387a27 /tests/auto
parent54d43c6480ff033ad80165a2da02d2e01f708cf4 (diff)
Strip any trailing spaces from the filename before trying to open it
On Windows, trailing spaces in a filename are silently ignored, so we need to strip it before trying to open a file with it. Otherwise it ends up being stripped later and in a case like " ." it will end up causing Qt to think that a folder exists when it does not. [ChangeLog][Platform Specific Changes][Windows][QtWidgets][QFileDialog] Handled the case of having trailing spaces in a filename correctly so if the filename ends up being empty that the parent path is used instead. Change-Id: I6500cc3a44746bf4a65e73bcfb63265a0a97c8a3 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 8bad4bb176..54a3a85e87 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -148,6 +148,7 @@ private slots:
void enableChooseButton();
void hooks();
void widgetlessNativeDialog();
+ void trailingDotsAndSpaces();
#ifdef Q_OS_UNIX
#ifdef QT_BUILD_INTERNAL
void tildeExpansion_data();
@@ -1413,6 +1414,33 @@ void tst_QFiledialog::widgetlessNativeDialog()
QVERIFY(!button);
}
+void tst_QFiledialog::trailingDotsAndSpaces()
+{
+#ifndef Q_OS_WIN
+ QSKIP("This is only tested on Windows");
+#endif
+ QNonNativeFileDialog fd;
+ fd.setViewMode(QFileDialog::List);
+ fd.setFileMode(QFileDialog::ExistingFile);
+ fd.setOptions(QFileDialog::DontUseNativeDialog);
+ fd.show();
+ QLineEdit *lineEdit = fd.findChild<QLineEdit *>("fileNameEdit");
+ QVERIFY(lineEdit);
+ QListView *list = fd.findChild<QListView *>("listView");
+ QVERIFY(list);
+ QTest::qWait(1000);
+ int currentChildrenCount = list->model()->rowCount(list->rootIndex());
+ QTest::keyClick(lineEdit, Qt::Key_Space);
+ QTest::keyClick(lineEdit, Qt::Key_Period);
+ QTest::qWait(1000);
+ QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+ lineEdit->clear();
+ QTest::keyClick(lineEdit, Qt::Key_Period);
+ QTest::keyClick(lineEdit, Qt::Key_Space);
+ QTest::qWait(1000);
+ QVERIFY(currentChildrenCount == list->model()->rowCount(list->rootIndex()));
+}
+
#ifdef Q_OS_UNIX
#ifdef QT_BUILD_INTERNAL
void tst_QFiledialog::tildeExpansion_data()