diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-09-17 13:04:27 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-09-17 14:00:21 (GMT) |
commit | 206f49020bce11e142c4290b6655ac7c15592b43 (patch) | |
tree | 07c55b419f57a9bd6a0af71ddc79ef9309a58fa8 /tests/auto/qfilesystementry | |
parent | 3df81c23e6ab7dae949315a4f0ca4e54469ab2bf (diff) | |
download | Qt-206f49020bce11e142c4290b6655ac7c15592b43.zip Qt-206f49020bce11e142c4290b6655ac7c15592b43.tar.gz Qt-206f49020bce11e142c4290b6655ac7c15592b43.tar.bz2 |
Differntiate different types of absolute paths on windows.
QFileSystemEntry now differentiates between various types of absolute
paths on Windows and Symbian. The new behavior is shown the table below.
Anybody who uses this class should NOT treat that !isRelative() == isAbsolute().
The differentiation is puerly for internal use by the windows
and symbian implementations of QFileSystemEngine.
|============================================|
|Filename isRelative isAbsolute |
|============================================|
| Somefile.txt 1 0 |
| Some/file.txt 1 0 |
| a:Somefile.txt 0 0 |
| /Somefile.txt 0 0 |
| a:/somefile.txt 0 1 |
| //abc/somefile.txt 0 1 |
|============================================|
Reviewed-by: Joao
Reviewed-by: Shane Kearns
Diffstat (limited to 'tests/auto/qfilesystementry')
-rw-r--r-- | tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 49afab6..4375f99 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -64,6 +64,10 @@ private slots: void baseName(); void completeBaseName_data(); void completeBaseName(); +#if defined(WIN_STUFF) + void absoluteOrRelative_data(); + void absoluteOrRelative(); +#endif }; #if defined(WIN_STUFF) @@ -78,6 +82,7 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::addColumn<QString>("suffix"); QTest::addColumn<QString>("completeSuffix"); QTest::addColumn<bool>("absolute"); + QTest::addColumn<bool>("relative"); QString absPrefix = QLatin1String("\\\\?\\"); QString relPrefix = absPrefix @@ -88,33 +93,33 @@ void tst_QFileSystemEntry::getSetCheck_data() << 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" << "dir" << "dir.tar" << "gz" << "tar.gz" << true; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true << false; QTest::newRow("relative") << QString("in\\a\\dir.tar.gz") << relPrefix + QString("in\\a\\dir.tar.gz") << "in/a/dir.tar.gz" - << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false <<true; QTest::newRow("noSuffix") << QString("myDir\\myfile") << relPrefix + QString("myDir\\myfile") - << "myDir/myfile" << "myfile" << "myfile" << "myfile" << "" << "" << false; + << "myDir/myfile" << "myfile" << "myfile" << "myfile" << "" << "" << false <<true; QTest::newRow("noLongSuffix") << QString("myDir\\myfile.txt") << relPrefix + QString("myDir\\myfile.txt") - << "myDir/myfile.txt" << "myfile.txt" << "myfile" << "myfile" << "txt" << "txt" << false; + << "myDir/myfile.txt" << "myfile.txt" << "myfile" << "myfile" << "txt" << "txt" << false << true; QTest::newRow("endingSlash") << QString("myDir\\myfile.bla\\") << relPrefix + QString("myDir\\myfile.bla\\") - << "myDir/myfile.bla/" << "" << "" << "" << "" << "" << false; + << "myDir/myfile.bla/" << "" << "" << "" << "" << "" << false << true; 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" << "backslash" << "backslash" << "bat" << "bat" << true; + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "backslash" << "backslash" << "bat" << "bat" << false << false; } void tst_QFileSystemEntry::getSetCheck() @@ -128,6 +133,7 @@ void tst_QFileSystemEntry::getSetCheck() QFETCH(QString, suffix); QFETCH(QString, completeSuffix); QFETCH(bool, absolute); + QFETCH(bool, relative); QFileSystemEntry entry1(filepath); QCOMPARE(entry1.filePath(), filepath); @@ -136,7 +142,7 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry1.suffix(), suffix); QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); - QCOMPARE(entry1.isRelative(), !absolute); + QCOMPARE(entry1.isRelative(), relative); QCOMPARE(entry1.baseName(), baseName); QCOMPARE(entry1.completeBaseName(), completeBasename); @@ -144,7 +150,7 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry2.suffix(), suffix); QCOMPARE(entry2.completeSuffix(), completeSuffix); QCOMPARE(entry2.isAbsolute(), absolute); - QCOMPARE(entry2.isRelative(), !absolute); + QCOMPARE(entry2.isRelative(), relative); QCOMPARE(entry2.filePath(), filepath); // Since this entry was created using the native path, // the object shouldnot change nativeFilePath. @@ -351,6 +357,31 @@ void tst_QFileSystemEntry::completeBaseName() QCOMPARE(fi2.completeBaseName(), expected); } +#if defined(WIN_STUFF) +void tst_QFileSystemEntry::absoluteOrRelative_data() +{ + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isAbsolute"); + QTest::addColumn<bool>("isRelative"); + + QTest::newRow("data0") << "file.tar" << false << true; + QTest::newRow("data1") << "/path/file/file.tar.gz" << false << false; + QTest::newRow("data1") << "C:path/file/file.tar.gz" << false << false; + QTest::newRow("data3") << "C:/path/file" << true << false; + QTest::newRow("data3") << "//machine/share" << true << false; +} + +void tst_QFileSystemEntry::absoluteOrRelative() +{ + QFETCH(QString, path); + QFETCH(bool, isAbsolute); + QFETCH(bool, isRelative); + + QFileSystemEntry fi(path); + QCOMPARE(fi.isAbsolute(), isAbsolute); + QCOMPARE(fi.isRelative(), isRelative); +} +#endif QTEST_MAIN(tst_QFileSystemEntry) #include <tst_qfilesystementry.moc> |