diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2011-05-20 12:16:33 (GMT) |
---|---|---|
committer | Pierre Rossi <pierre.rossi@nokia.com> | 2011-06-08 16:15:05 (GMT) |
commit | df6713b8f55fc007796f404a3615bf348d1d0782 (patch) | |
tree | 96cf40cf2448603da00f3c5e7993b40541ace9d3 /tests | |
parent | 32079bb0b348ef5f7126e69be9bcfb249c1a6412 (diff) | |
download | Qt-df6713b8f55fc007796f404a3615bf348d1d0782.zip Qt-df6713b8f55fc007796f404a3615bf348d1d0782.tar.gz Qt-df6713b8f55fc007796f404a3615bf348d1d0782.tar.bz2 |
Add tilde (both ~ and ~<userName>) expansion to QFileDialog on UNIX.
Task-number: QTBUG-3265
Reviewed-by: Thiago
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qfiledialog/tst_qfiledialog.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 42e82a9..24ac9f7 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,35 @@ 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); +#endif + QFETCH(QString, tildePath); + QFETCH(QString, expandedPath); + + QCOMPARE(qt_tildeExpansion(tildePath), expandedPath); +} +#endif + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" |