summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2011-05-20 14:16:33 +0200
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-08 22:37:52 +0200
commit94c173de057bcf57a5105810d8ee34d2093fe805 (patch)
tree0256242e09ff4dc4d53d17ac1b6b73fc04058be2 /tests/auto
parent15d6f1f0315602f5b637353cb67f52636ce1deee (diff)
Add tilde (both ~ and ~<user>) expansion to QFileDialog on UNIX.
Task-number: QTBUG-3265 Change-Id: Id8062afe69e798e1f9cf3f4e967ae0d30c362b72 Reviewed-on: http://codereview.qt.nokia.com/411 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index bc076c5b2b..08d2e88f3c 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -78,6 +78,10 @@
# define STRINGIFY(x) #x
# define TOSTRING(x) STRINGIFY(x)
# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/"
+#elif defined(Q_OS_UNIX)
+#ifdef QT_BUILD_INTERNAL
+extern Q_GUI_EXPORT QString qt_tildeExpansion(const QString &path, bool *expanded = 0);
+#endif
#endif
class QNonNativeFileDialog : public QFileDialog
@@ -144,6 +148,10 @@ private slots:
void clearLineEdit();
void enableChooseButton();
void hooks();
+#ifdef Q_OS_UNIX
+ void tildeExpansion_data();
+ void tildeExpansion();
+#endif
private:
QByteArray userSettings;
@@ -1323,5 +1331,36 @@ void tst_QFiledialog::hooks()
QCOMPARE(QFileDialog::getSaveFileName(), QString("saveName"));
}
+#ifdef Q_OS_UNIX
+void tst_QFiledialog::tildeExpansion_data()
+{
+ QTest::addColumn<QString>("tildePath");
+ QTest::addColumn<QString>("expandedPath");
+
+ QTest::newRow("empty path") << QString() << QString();
+ QTest::newRow("~") << QString::fromLatin1("~") << QDir::homePath();
+ QTest::newRow("~/some/sub/dir/") << QString::fromLatin1("~/some/sub/dir") << QDir::homePath()
+ + QString::fromLatin1("/some/sub/dir");
+ QString userHome = QString(qgetenv("USER"));
+ userHome.prepend('~');
+ QTest::newRow("current user (~<user> syntax)") << userHome << QDir::homePath();
+ QString invalid = QString::fromLatin1("~thisIsNotAValidUserName");
+ QTest::newRow("invalid user name") << invalid << invalid;
+}
+
+
+void tst_QFiledialog::tildeExpansion()
+{
+#ifndef QT_BUILD_INTERNAL
+ QSKIP("Test case relies on developer build (AUTOTEST_EXPORT)", SkipAll);
+#else
+ QFETCH(QString, tildePath);
+ QFETCH(QString, expandedPath);
+
+ QCOMPARE(qt_tildeExpansion(tildePath), expandedPath);
+#endif
+}
+#endif
+
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"