diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2010-05-05 14:36:02 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2010-05-07 10:53:14 (GMT) |
commit | 8955e088aa9e4b0496c32f27206fd6211a85782f (patch) | |
tree | 99d41e95a163be5fa70acf98a2727fb14968ffa5 /tests/auto/qdir | |
parent | 9a46da1a9b045354e936ff0e3c5ca3d79baef655 (diff) | |
download | Qt-8955e088aa9e4b0496c32f27206fd6211a85782f.zip Qt-8955e088aa9e4b0496c32f27206fd6211a85782f.tar.gz Qt-8955e088aa9e4b0496c32f27206fd6211a85782f.tar.bz2 |
Fix for qfsfileengine_win to return proper absolute path for C:\
When using canonicalPath on a QDir that currently just represents
a root directory, a valid path name such as "C:\" should be returned.
Previously we returned "C:" which in fact would point to the current
working directory on drive C: and therefor is not necessarily the same.
Reviewed-by: Thiago
Task-number: QTBUG-6680
Diffstat (limited to 'tests/auto/qdir')
-rw-r--r-- | tests/auto/qdir/tst_qdir.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 71469bb..b2dc960 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -172,6 +172,11 @@ private slots: void longFileName(); void updateFileLists(); + +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + void isRoot_data(); + void isRoot(); +#endif }; // Testing get/set functions @@ -805,6 +810,16 @@ void tst_QDir::canonicalPath_data() QTest::newRow("absPath") << appPath + "\\testData\\..\\testData" << appPath + "/testData"; #endif QTest::newRow("nonexistant") << "testd" << QString(); + +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QTest::newRow("drive:/") << QDir::rootPath() << QDir::rootPath(); + QTest::newRow("drive:\\") << QDir::toNativeSeparators(QDir::rootPath()) << QDir::rootPath(); + QTest::newRow("drive:/./") << QDir::rootPath().append("./") << QDir::rootPath(); + QTest::newRow("drive:/../.. ") << QDir::rootPath().append("../..") << QDir::rootPath(); + QTest::newRow("drive:\\.\\") << QDir::toNativeSeparators(QDir::rootPath().append("./")) << QDir::rootPath(); + QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath(); + QTest::newRow("drive:") << QDir::rootPath().left(2) << QDir::currentPath(); +#endif } void tst_QDir::canonicalPath() @@ -1546,6 +1561,32 @@ void tst_QDir::updateFileLists() QCOMPARE(dir.entryList(), QStringList() << "sub-dir1" << "sub-dir2" << "file1.txt"); } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +void tst_QDir::isRoot_data() +{ + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isRoot"); + + QString test = QDir::rootPath(); + QTest::newRow("rootPath " + test) << test << true; + test = QDir::rootPath().append("./"); + QTest::newRow("./ appended " + test) << test << false; + test = QDir(QDir::rootPath().append("./")).canonicalPath(); + QTest::newRow("canonicalPath " + test) << test << true; + test = QDir::rootPath().left(2); + QTest::newRow("drive relative " + test) << test << false; +} + +void tst_QDir::isRoot() +{ + QFETCH(QString, path); + QFETCH(bool, isRoot); + + QDir dir(path); + QCOMPARE(dir.isRoot(),isRoot); +} +#endif + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" |