summaryrefslogtreecommitdiffstats
path: root/tests/auto/qdir/tst_qdir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qdir/tst_qdir.cpp')
-rw-r--r--tests/auto/qdir/tst_qdir.cpp116
1 files changed, 91 insertions, 25 deletions
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index 91ce5b3..19fee40 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -48,10 +48,13 @@
#include <qfileinfo.h>
#include <qregexp.h>
#include <qstringlist.h>
-
#include "../network-settings.h"
-
+#if defined(Q_OS_SYMBIAN)
+# define STRINGIFY(x) #x
+# define TOSTRING(x) STRINGIFY(x)
+# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/"
+#endif
//TESTED_CLASS=
//TESTED_FILES=
@@ -196,7 +199,7 @@ void tst_QDir::setPath_data()
QTest::addColumn<QString>("dir2");
QTest::newRow("data0") << QString(".") << QString("..");
-#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_WS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QTest::newRow("data1") << QString("c:/") << QDir::currentPath();
#endif
}
@@ -293,7 +296,7 @@ void tst_QDir::exists_data()
QTest::newRow("simple dir") << SRCDIR "resources" << true;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true;
QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true;
QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true;
@@ -303,7 +306,8 @@ void tst_QDir::exists_data()
QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << false;
QTest::newRow("unc 8") << "//" + QtNetworkSettings::winServerName() + "/asharethatshouldnotexist" << false;
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
-
+#endif
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QTest::newRow("This drive should exist") << "C:/" << true;
// find a non-existing drive and check if it does not exist
QFileInfoList drives = QFSFileEngine::drives();
@@ -339,7 +343,7 @@ void tst_QDir::isRelativePath_data()
QTest::addColumn<bool>("relative");
QTest::newRow("data0") << "../somedir" << true;
-#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_WS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QTest::newRow("data1") << "C:/sOmedir" << false;
#endif
QTest::newRow("data2") << "somedir" << true;
@@ -536,17 +540,61 @@ void tst_QDir::entryList()
QFile::remove(SRCDIR "entrylist/brokenlink.lnk");
QFile::remove(SRCDIR "entrylist/brokenlink");
- // WinCE does not have . and .. in the directory listing
-#ifdef Q_OS_WINCE
+ // WinCE/Symbian does not have . and .. in the directory listing
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
expected.removeAll(".");
expected.removeAll("..");
#endif
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN)
// ### Sadly, this is a platform difference right now.
QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk");
QFile::link(SRCDIR "entryList/directory", SRCDIR "entrylist/linktodirectory.lnk");
QFile::link(SRCDIR "entryList/nothing", SRCDIR "entrylist/brokenlink.lnk");
+#elif defined(Q_OS_SYMBIAN)
+ // Symbian doesn't support links to directories
+ expected.removeAll("linktodirectory.lnk");
+
+ // Expecting failures from a couple of OpenC bugs. Do checks only once.
+ static int xFailChecked = false;
+ static int expectedFail1 = false;
+ static int expectedFail2 = false;
+
+ if (!expectedFail1) {
+ // Can't create link if file doesn't exist in symbian, so create file temporarily,
+ // But only if testing for
+ QFile tempFile(SRCDIR "entryList/nothing");
+ tempFile.open(QIODevice::WriteOnly);
+ tempFile.link(SRCDIR "entryList/brokenlink.lnk");
+ tempFile.remove();
+ }
+
+ if (!expectedFail2) {
+ QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk");
+ }
+
+ if (!xFailChecked) {
+ // ### Until OpenC supports stat correctly for symbolic links, expect them to fail.
+ expectedFail1 = QFileInfo(SRCDIR "entryList/brokenlink.lnk").exists();
+ expectedFail2 = !(QFileInfo(SRCDIR "entryList/linktofile.lnk").isFile());
+
+ QEXPECT_FAIL("", "OpenC bug, stat for broken links returns normally, when it should return error.", Continue);
+ QVERIFY(!expectedFail1);
+
+ QEXPECT_FAIL("", "OpenC bug, stat for file links doesn't indicate them as such.", Continue);
+ QVERIFY(!expectedFail2);
+ xFailChecked = true;
+ }
+
+ if (expectedFail1) {
+ expected.removeAll("brokenlink.lnk");
+ QFile::remove(SRCDIR "entrylist/brokenlink.lnk");
+ }
+
+ if (expectedFail2) {
+ expected.removeAll("linktofile.lnk");
+ QFile::remove(SRCDIR "entrylist/linktofile.lnk");
+ }
#else
QFile::link("file", SRCDIR "entrylist/linktofile.lnk");
QFile::link("directory", SRCDIR "entrylist/linktodirectory.lnk");
@@ -570,12 +618,16 @@ void tst_QDir::entryList()
// lock up. The actual result depends on the file system.
return;
}
-
for (int i=0; i<max; ++i)
QCOMPARE(actual[i], expected[i]);
QCOMPARE(actual.count(), expected.count());
+#if defined(Q_OS_SYMBIAN)
+ // Test cleanup on device requires setting the permissions back to normal
+ QFile(SRCDIR "entrylist/file").setPermissions(QFile::WriteUser | QFile::ReadUser);
+#endif
+
QFile::remove(SRCDIR "entrylist/writable");
QFile::remove(SRCDIR "entrylist/linktofile");
QFile::remove(SRCDIR "entrylist/linktodirectory");
@@ -591,7 +643,7 @@ void tst_QDir::entryListSimple_data()
QTest::addColumn<int>("countMin");
QTest::newRow("data2") << "do_not_expect_this_path_to_exist/" << 0;
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
QTest::newRow("simple dir") << SRCDIR "resources" << 0;
QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 0;
#else
@@ -630,19 +682,28 @@ void tst_QDir::entryListWithSymLinks()
QDir dir;
dir.mkdir("myDir");
QFile("testfile.cpp").open(QIODevice::WriteOnly);
+#if !defined(Q_OS_SYMBIAN)
QVERIFY(QFile::link("myDir", "myLinkToDir.lnk"));
+#endif
QVERIFY(QFile::link("testfile.cpp", "myLinkToFile.lnk"));
{
QStringList entryList = QDir().entryList();
QVERIFY(entryList.contains("myDir"));
+#if !defined(Q_OS_SYMBIAN)
QVERIFY(entryList.contains("myLinkToDir.lnk"));
+#endif
QVERIFY(entryList.contains("myLinkToFile.lnk"));
}
{
QStringList entryList = QDir().entryList(QDir::Dirs);
QVERIFY(entryList.contains("myDir"));
+#if !defined(Q_OS_SYMBIAN)
QVERIFY(entryList.contains("myLinkToDir.lnk"));
+#endif
+#if defined(Q_OS_SYMBIAN)
+ QEXPECT_FAIL("", "OpenC stat for symlinks is buggy.", Continue);
+#endif
QVERIFY(!entryList.contains("myLinkToFile.lnk"));
}
{
@@ -704,7 +765,7 @@ void tst_QDir::canonicalPath()
QFETCH(QString, canonicalPath);
QDir dir(path);
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QCOMPARE(dir.canonicalPath().toLower(), canonicalPath.toLower());
#else
QCOMPARE(dir.canonicalPath(), canonicalPath);
@@ -759,7 +820,7 @@ void tst_QDir::current()
if (!currentDir.isEmpty()) {
QDir newCurrent = QDir::current();
QDir::setCurrent(oldDir);
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QCOMPARE(newCurrent.absolutePath().toLower(), currentDir.toLower());
#else
QCOMPARE(newCurrent.absolutePath(), currentDir);
@@ -780,7 +841,7 @@ void tst_QDir::cd_data()
int index = appPath.lastIndexOf("/");
QTest::newRow("cdUp") << QDir::currentPath() << ".." << true << appPath.left(index==0?1:index);
QTest::newRow("noChange") << QDir::currentPath() << "." << true << appPath;
-#ifdef Q_OS_WIN // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root
QTest::newRow("absolute") << QDir::currentPath() << "/" << true << "/";
#else
QTest::newRow("absolute") << QDir::currentPath() << "/" << true << QDir::root().absolutePath();
@@ -859,7 +920,7 @@ tst_QDir::cleanPath_data()
QTest::newRow("data3") << QDir::cleanPath("../.") << "..";
QTest::newRow("data4") << QDir::cleanPath("../..") << "../..";
#if !defined(Q_OS_WINCE)
-#if defined Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QTest::newRow("data5") << "d:\\a\\bc\\def\\.." << "d:/a/bc";
QTest::newRow("data6") << "d:\\a\\bc\\def\\../../.." << "d:/";
#else
@@ -912,10 +973,12 @@ void tst_QDir::absolutePath_data()
QTest::addColumn<QString>("expectedPath");
QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1";
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1";
+# if !defined(Q_OS_SYMBIAN)
QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1";
QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1";
+# endif
QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1";
QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1";
#endif
@@ -952,7 +1015,7 @@ void tst_QDir::relativeFilePath_data()
QTest::newRow("11") << "" << "" << "";
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
QTest::newRow("12") << "C:/foo/bar" << "ding" << "ding";
QTest::newRow("13") << "C:/foo/bar" << "C:/ding/dong" << "../../ding/dong";
QTest::newRow("14") << "C:/foo/bar" << "/ding/dong" << "../../ding/dong";
@@ -971,10 +1034,12 @@ void tst_QDir::relativeFilePath_data()
QTest::newRow("22") << "C:" << "D:/" << "D:/";
QTest::newRow("23") << "C:/" << "D:" << "D:";
QTest::newRow("24") << "C:/" << "D:/" << "D:/";
+# if !defined(Q_OS_SYMBIAN)
QTest::newRow("25") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar";
QTest::newRow("26") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar";
QTest::newRow("27") << "//anotherHost/foo" << "bar" << "bar";
QTest::newRow("28") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar";
+# endif
#endif
}
@@ -1031,7 +1096,8 @@ void tst_QDir::rename()
QVERIFY(dir.rename("rename-test-renamed", "rename-test"));
#if defined(Q_OS_MAC)
QVERIFY(!dir.rename("rename-test", "/etc/rename-test-renamed"));
-#elif !defined(Q_OS_WIN) // on windows this is possible maybe make the test a bit better
+#elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN)
+ // on windows/symbian this is possible - maybe make the test a bit better
QVERIFY(!dir.rename("rename-test", "/rename-test-renamed"));
#endif
QVERIFY(dir.remove("rename-test"));
@@ -1080,7 +1146,7 @@ void tst_QDir::dirName_data()
QTest::newRow("slash0") << "c:/winnt/system32" << "system32";
QTest::newRow("slash1") << "/winnt/system32" << "system32";
QTest::newRow("slash2") << "c:/winnt/system32/kernel32.dll" << "kernel32.dll";
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QTest::newRow("bslash0") << "c:\\winnt\\system32" << "system32";
QTest::newRow("bslash1") << "\\winnt\\system32" << "system32";
QTest::newRow("bslash2") << "c:\\winnt\\system32\\kernel32.dll" << "kernel32.dll";
@@ -1105,8 +1171,8 @@ void tst_QDir::operator_eq()
void tst_QDir::dotAndDotDot()
{
-#ifdef Q_OS_WINCE
- QSKIP("WinCE does not have . nor ..", SkipAll);
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
+ QSKIP("WinCE and Symbian do not have . nor ..", SkipAll);
#endif
QDir dir(QString(SRCDIR "testdir/"));
QStringList entryList = dir.entryList(QDir::Dirs);
@@ -1147,7 +1213,7 @@ void tst_QDir::homePath()
#ifdef Q_OS_UNIX
if (strHome.length() > 1) // root dir = "/"
QVERIFY(!strHome.endsWith('/'));
-#elif defined(Q_OS_WIN)
+#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
if (strHome.length() > 3) // root dir = "c:/"; "//" is not really valid...
QVERIFY(!strHome.endsWith('/'));
#endif
@@ -1171,7 +1237,7 @@ void tst_QDir::tempPath()
#ifdef Q_OS_UNIX
if (path.length() > 1) // root dir = "/"
QVERIFY(!path.endsWith('/'));
-#elif defined(Q_OS_WIN)
+#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
if (path.length() > 3) // root dir = "c:/"; "//" is not really valid...
QVERIFY(!path.endsWith('/'));
#endif
@@ -1186,14 +1252,14 @@ void tst_QDir::rootPath()
QCOMPARE(path, dir.absolutePath());
QVERIFY(QDir::isAbsolutePath(path));
-#ifdef Q_OS_UNIX
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
QCOMPARE(path, QString("/"));
#endif
}
void tst_QDir::nativeSeparators()
{
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
QCOMPARE(QDir::toNativeSeparators(QLatin1String("/")), QString("\\"));
QCOMPARE(QDir::toNativeSeparators(QLatin1String("\\")), QString("\\"));
QCOMPARE(QDir::fromNativeSeparators(QLatin1String("/")), QString("/"));