summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
diff options
context:
space:
mode:
authorPrasanth Ullattil <prasanth.ullattil@nokia.com>2010-09-01 14:21:14 (GMT)
committerPrasanth Ullattil <prasanth.ullattil@nokia.com>2010-09-01 14:21:14 (GMT)
commitf6e118d7ec781a97e8648145d4dfdb40516b13b4 (patch)
tree97f3dcab844cbd9d79956d6914a68bab09f7eded /tests/auto/qfilesystementry/tst_qfilesystementry.cpp
parent111886749d2cc6a94de382e454916446052dd355 (diff)
downloadQt-f6e118d7ec781a97e8648145d4dfdb40516b13b4.zip
Qt-f6e118d7ec781a97e8648145d4dfdb40516b13b4.tar.gz
Qt-f6e118d7ec781a97e8648145d4dfdb40516b13b4.tar.bz2
Fix tst_QFileSystemEntry auto tests on windows
While resolving the native path, Windows implementation saves it as long absolute path. The tests are updated for this. This patch also splits the windows & unix code paths. Reviewed-by: Joao
Diffstat (limited to 'tests/auto/qfilesystementry/tst_qfilesystementry.cpp')
-rw-r--r--tests/auto/qfilesystementry/tst_qfilesystementry.cpp112
1 files changed, 83 insertions, 29 deletions
diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
index 35389b4..f4def8d 100644
--- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
+++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp
@@ -58,68 +58,121 @@ private slots:
void getSetCheck();
};
+#if defined(WIN_STUFF)
void tst_QFileSystemEntry::getSetCheck_data()
{
- QTest::addColumn<QByteArray>("nativeFilePath");
+ QTest::addColumn<QString>("nativeFilePath");
+ QTest::addColumn<QString>("internalnativeFilePath");
QTest::addColumn<QString>("filepath");
QTest::addColumn<QString>("filename");
QTest::addColumn<QString>("suffix");
QTest::addColumn<QString>("completeSuffix");
QTest::addColumn<bool>("absolute");
+ QString absPrefix = QLatin1String("\\\\?\\");
+ QString relPrefix = absPrefix
+ + QDir::toNativeSeparators(QDir::currentPath())
+ + QLatin1String("\\");
+
QTest::newRow("simple")
-#if defined(WIN_STUFF)
- << QByteArray("A:\\home\\qt\\in\\a\\dir.tar.gz")
- << "A:/home/qt/in/a/dir.tar.gz"
+ << QString("A:\\home\\qt\\in\\a\\dir.tar.gz")
+ << absPrefix + QString("A:\\home\\qt\\in\\a\\dir.tar.gz")
+ << "A:/home/qt/in/a/dir.tar.gz"
+ << "dir.tar.gz" << "gz" << "tar.gz" << true;
+
+ QTest::newRow("relative")
+ << QString("in\\a\\dir.tar.gz")
+ << relPrefix + QString("in\\a\\dir.tar.gz")
+ << "in/a/dir.tar.gz"
+ << "dir.tar.gz" << "gz" << "tar.gz" << false;
+
+ QTest::newRow("noSuffix")
+ << QString("myDir\\myfile")
+ << relPrefix + QString("myDir\\myfile")
+ << "myDir/myfile" << "myfile" << "" << "" << false;
+
+ QTest::newRow("noLongSuffix")
+ << QString("myDir\\myfile.txt")
+ << relPrefix + QString("myDir\\myfile.txt")
+ << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false;
+
+ QTest::newRow("endingSlash")
+ << QString("myDir\\myfile.bla\\")
+ << relPrefix + QString("myDir\\myfile.bla\\")
+ << "myDir/myfile.bla/" << "" << "" << "" << false;
+
+ QTest::newRow("absolutePath")
+ << QString("A:dir\\without\\leading\\backslash.bat")
+ << absPrefix + QString("A:\\dir\\without\\leading\\backslash.bat")
+ << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true;
+}
+
+void tst_QFileSystemEntry::getSetCheck()
+{
+ QFETCH(QString, nativeFilePath);
+ QFETCH(QString, internalnativeFilePath);
+ QFETCH(QString, filepath);
+ QFETCH(QString, filename);
+ QFETCH(QString, suffix);
+ QFETCH(QString, completeSuffix);
+ QFETCH(bool, absolute);
+
+ QFileSystemEntry entry1(filepath);
+ QCOMPARE(entry1.filePath(), filepath);
+ QCOMPARE(entry1.nativeFilePath().toLower(), internalnativeFilePath.toLower());
+ QCOMPARE(entry1.fileName(), filename);
+ QCOMPARE(entry1.suffix(), suffix);
+ QCOMPARE(entry1.completeSuffix(), completeSuffix);
+ QCOMPARE(entry1.isAbsolute(), absolute);
+ QCOMPARE(entry1.isRelative(), !absolute);
+
+ QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath());
+ QCOMPARE(entry2.suffix(), suffix);
+ QCOMPARE(entry2.completeSuffix(), completeSuffix);
+ QCOMPARE(entry2.isAbsolute(), absolute);
+ QCOMPARE(entry2.isRelative(), !absolute);
+ QCOMPARE(entry2.filePath(), filepath);
+ // This is entry was created using the native file path,
+ // so it should use that without any changes.
+ QCOMPARE(entry2.nativeFilePath(), nativeFilePath);
+ QCOMPARE(entry2.fileName(), filename);
+}
+
#else
+
+void tst_QFileSystemEntry::getSetCheck_data()
+{
+ QTest::addColumn<QByteArray>("nativeFilePath");
+ QTest::addColumn<QString>("filepath");
+ QTest::addColumn<QString>("filename");
+ QTest::addColumn<QString>("suffix");
+ QTest::addColumn<QString>("completeSuffix");
+ QTest::addColumn<bool>("absolute");
+
+ QTest::newRow("simple")
<< QByteArray("/home/qt/in/a/dir.tar.gz")
<< "/home/qt/in/a/dir.tar.gz"
-#endif
<< "dir.tar.gz" << "gz" << "tar.gz" << true;
-
QTest::newRow("relative")
-#if defined(WIN_STUFF)
- << QByteArray("in\\a\\dir.tar.gz")
- << "in/a/dir.tar.gz"
-#else
<< QByteArray("in/a/dir.tar.gz")
<< "in/a/dir.tar.gz"
-#endif
<< "dir.tar.gz" << "gz" << "tar.gz" << false;
QTest::newRow("noSuffix")
-#if defined(WIN_STUFF)
- << QByteArray("myDir\\myfile")
-#else
<< QByteArray("myDir/myfile")
-#endif
<< "myDir/myfile" << "myfile" << "" << "" << false;
QTest::newRow("noLongSuffix")
-#if defined(WIN_STUFF)
- << QByteArray("myDir\\myfile.txt")
-#else
<< QByteArray("myDir/myfile.txt")
-#endif
<< "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false;
QTest::newRow("endingSlash")
-#if defined(WIN_STUFF)
- << QByteArray("myDir\\myfile.bla\\")
-#else
<< QByteArray("myDir/myfile.bla/")
-#endif
<< "myDir/myfile.bla/" << "" << "" << "" << false;
-#if defined(WIN_STUFF)
- QTest::newRow("absolutePath")
- << QByteArray("A:dir\\without\\leading\\backslash.bat")
- << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true;
-#else
QTest::newRow("relativePath")
<< QByteArray("A:dir/without/leading/backslash.bat")
<< "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << false;
-#endif
}
void tst_QFileSystemEntry::getSetCheck()
@@ -149,6 +202,7 @@ void tst_QFileSystemEntry::getSetCheck()
QCOMPARE(entry2.nativeFilePath(), nativeFilePath);
QCOMPARE(entry2.fileName(), filename);
}
+#endif
QTEST_MAIN(tst_QFileSystemEntry)
#include <tst_qfilesystementry.moc>