summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-04-24 16:03:55 +0200
committeraxis <qt-info@nokia.com>2009-04-27 09:09:01 +0200
commite74c8dc65e2feffb9a55d00aee5ca634fba41df8 (patch)
tree3a131f9235fb6a455793178d8313655e4fd0036e /tests/auto/qfile
parent8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (diff)
parent211bea9838bcc2acd7f54b65468fe1be2d81b1e0 (diff)
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Configure.exe recompiled with MSVC6. Conflicts: configure.exe examples/network/network.pro src/gui/dialogs/qfiledialog_p.h src/gui/dialogs/qfilesystemmodel_p.h src/gui/kernel/qapplication.cpp tests/auto/_Categories/qmake.txt tests/auto/qfile/test/test.pro tests/auto/qfile/tst_qfile.cpp tests/auto/qlibrary/tst_qlibrary.cpp tests/auto/qline/tst_qline.cpp tests/auto/qstyle/tst_qstyle.cpp tests/auto/qtextstream/tst_qtextstream.cpp tests/auto/qtranslator/qtranslator.pro tests/auto/qwaitcondition/tst_qwaitcondition.cpp translations/qt_ja_JP.ts
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r--tests/auto/qfile/rename-fallback.qrc5
-rw-r--r--tests/auto/qfile/test/test.pro2
-rw-r--r--tests/auto/qfile/tst_qfile.cpp78
3 files changed, 53 insertions, 32 deletions
diff --git a/tests/auto/qfile/rename-fallback.qrc b/tests/auto/qfile/rename-fallback.qrc
new file mode 100644
index 0000000000..c8a894a61d
--- /dev/null
+++ b/tests/auto/qfile/rename-fallback.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>rename-fallback.qrc</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro
index e9f8d7cc1b..b51eff6d7b 100644
--- a/tests/auto/qfile/test/test.pro
+++ b/tests/auto/qfile/test/test.pro
@@ -23,7 +23,7 @@ wince*:{
DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
-RESOURCES += ../qfile.qrc
+RESOURCES += ../qfile.qrc ../rename-fallback.qrc
TARGET = ../tst_qfile
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 8f0e3f6d50..483e978406 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -79,10 +79,6 @@
# define SRCDIR ""
#endif
-#if QT_VERSION < 0x040200
-#define symLinkTarget readLink
-#endif
-
Q_DECLARE_METATYPE(QFile::FileError)
//TESTED_CLASS=
@@ -172,6 +168,8 @@ private slots:
void rename_data();
void rename();
void renameWithAtEndSpecialFile() const;
+ void renameFallback();
+ void renameMultiple();
void appendAndRead();
void miscWithUncPathAsCurrentDir();
void standarderror();
@@ -217,6 +215,14 @@ void tst_QFile::cleanup()
{
// TODO: Add cleanup code here.
// This will be executed immediately after each test is run.
+
+ // for renameFallback()
+ QFile::remove("file-rename-destination.txt");
+
+ // for renameMultiple()
+ QFile::remove("file-to-be-renamed.txt");
+ QFile::remove("file-renamed-once.txt");
+ QFile::remove("file-renamed-twice.txt");
}
void tst_QFile::initTestCase()
@@ -994,12 +1000,8 @@ void tst_QFile::link()
#ifdef Q_OS_WIN // on windows links are always absolute
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#else
-#if QT_VERSION < 0x040101
- QCOMPARE(info2.symLinkTarget(), info1.filePath());
-#else
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#endif
-#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath());
@@ -1075,19 +1077,12 @@ void tst_QFile::readBrokenLink()
#ifdef Q_OS_WIN // on windows links are alway absolute
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#else
-#if QT_VERSION < 0x040101
- QCOMPARE(info2.symLinkTarget(), info1.filePath());
-#else
QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath());
#endif
-#endif
QVERIFY(QFile::remove(info2.absoluteFilePath()));
-
-#if QT_VERSION >= 0x040101 && !defined(Q_OS_SYMBIAN)
QVERIFY(QFile::link("ole/..", "myLink2.lnk"));
QCOMPARE(QFileInfo("myLink2.lnk").symLinkTarget(), QDir::currentPath());
-#endif
}
void tst_QFile::readTextFile_data()
@@ -1295,10 +1290,6 @@ void tst_QFile::bufferedRead()
QCOMPARE(file.pos(), qlonglong(2));
}
-#if QT_VERSION <= 0x040100
- QCOMPARE(int(ftell(stdFile)), 2);
-#endif
-
fclose(stdFile);
}
@@ -1618,12 +1609,7 @@ void tst_QFile::longFileName()
}
{
QFile file(fileName);
-#if QT_VERSION < 0x040100
-# ifdef Q_OS_WIN
- QEXPECT_FAIL("244 chars", "Fixed in 4.1", Continue);
- QEXPECT_FAIL("244 chars to absolutepath", "Fixed in 4.1", Continue);
-# endif
-#elif defined(Q_WS_WIN)
+#if defined(Q_WS_WIN)
#if !defined(Q_OS_WINCE)
QT_WA({ if (false) ; }, {
QEXPECT_FAIL("244 chars", "Full pathname must be less than 260 chars", Abort);
@@ -1852,10 +1838,6 @@ void tst_QFile::removeOpenFile()
void tst_QFile::fullDisk()
{
-#if QT_VERSION < 0x040102
- QSKIP("Fixed for 4.1.2", SkipAll);
-#endif
-
QFile file("/dev/full");
if (!file.exists())
QSKIP("/dev/full doesn't exist on this system", SkipAll);
@@ -1999,9 +1981,7 @@ void tst_QFile::virtualFile()
// read all:
data = f.readAll();
QVERIFY(f.pos() != 0);
-#if QT_VERSION >= 0x040200
QVERIFY(!data.isEmpty());
-#endif
// seeking
QVERIFY(f.seek(1));
@@ -2119,6 +2099,42 @@ void tst_QFile::renameWithAtEndSpecialFile() const
QVERIFY(QFile::rename(newName, originalName));
}
+void tst_QFile::renameFallback()
+{
+ // Using a resource file both to trigger QFile::rename's fallback handling
+ // and as a *read-only* source whose move should fail.
+ QFile file(":/rename-fallback.qrc");
+ QVERIFY(file.exists() && "(test-precondition)");
+ QFile::remove("file-rename-destination.txt");
+
+ QVERIFY(!file.rename("file-rename-destination.txt"));
+ QVERIFY(!QFile::exists("file-rename-destination.txt"));
+}
+
+void tst_QFile::renameMultiple()
+{
+ // create the file if it doesn't exist
+ QFile file("file-to-be-renamed.txt");
+ QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)");
+
+ // any stale files from previous test failures?
+ QFile::remove("file-renamed-once.txt");
+ QFile::remove("file-renamed-twice.txt");
+
+ // begin testing
+ QVERIFY(file.rename("file-renamed-once.txt"));
+ QCOMPARE(file.fileName(), QString("file-renamed-once.txt"));
+ QVERIFY(file.rename("file-renamed-twice.txt"));
+ QCOMPARE(file.fileName(), QString("file-renamed-twice.txt"));
+
+ QVERIFY(!QFile::exists("file-to-be-renamed.txt"));
+ QVERIFY(!QFile::exists("file-renamed-once.txt"));
+ QVERIFY(QFile::exists("file-renamed-twice.txt"));
+
+ file.remove();
+ QVERIFY(!QFile::exists("file-renamed-twice.txt"));
+}
+
void tst_QFile::appendAndRead()
{
QFile writeFile(QLatin1String("appendfile.txt"));