summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
commitdb8f05e257019694f5e8076845626008f2adc3dd (patch)
tree05d3959403cf15ac5f702091439e028af01f343b /tests/auto/qfile
parent8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff)
parent796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff)
downloadQt-db8f05e257019694f5e8076845626008f2adc3dd.zip
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo. Conflicts: configure.exe mkspecs/features/qttest_p4.prf qmake/generators/makefile.cpp src/corelib/io/qdir.cpp src/corelib/io/qprocess.h src/corelib/kernel/qcoreevent.h src/corelib/kernel/qobject.cpp src/corelib/kernel/qsharedmemory_unix.cpp src/corelib/thread/qthread_p.h src/corelib/tools/qvector.h src/gui/dialogs/qdialog.cpp src/gui/dialogs/qfiledialog.cpp src/gui/dialogs/qfiledialog_p.h src/gui/dialogs/qmessagebox.cpp src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsview.cpp src/gui/image/qpixmapcache.cpp src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication_p.h src/gui/kernel/qwidget.cpp src/gui/kernel/qwidget_p.h src/gui/painting/qdrawhelper.cpp src/gui/painting/qpaintengine_raster.cpp src/gui/text/qfontengine_qpf.cpp src/gui/widgets/qmenubar.cpp src/network/socket/qlocalserver.cpp src/testlib/qtestcase.cpp src/testlib/testlib.pro tests/auto/qimagereader/tst_qimagereader.cpp tests/auto/qitemdelegate/tst_qitemdelegate.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'tests/auto/qfile')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 597343f..4bd6232 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -126,6 +126,7 @@ private slots:
void permissions();
void setPermissions();
void copy();
+ void copyAfterFail();
void copyRemovesTemporaryFile() const;
void copyShouldntOverwrite();
void copyFallback();
@@ -227,8 +228,15 @@ void tst_QFile::cleanup()
// for renameFallback()
QFile::remove("file-rename-destination.txt");
+ // for copyAfterFail()
+ QFile::remove("file-to-be-copied.txt");
+ QFile::remove("existing-file.txt");
+ QFile::remove("copied-file-1.txt");
+ QFile::remove("copied-file-2.txt");
+
// for renameMultiple()
QFile::remove("file-to-be-renamed.txt");
+ QFile::remove("existing-file.txt");
QFile::remove("file-renamed-once.txt");
QFile::remove("file-renamed-twice.txt");
}
@@ -904,6 +912,39 @@ void tst_QFile::copy()
QFile::copy(QDir::currentPath(), QDir::currentPath() + QLatin1String("/test2"));
}
+void tst_QFile::copyAfterFail()
+{
+ QFile file1("file-to-be-copied.txt");
+ QFile file2("existing-file.txt");
+
+ QVERIFY(file1.open(QIODevice::ReadWrite) && "(test-precondition)");
+ QVERIFY(file2.open(QIODevice::ReadWrite) && "(test-precondition)");
+ QVERIFY(!QFile::exists("copied-file-1.txt") && "(test-precondition)");
+ QVERIFY(!QFile::exists("copied-file-2.txt") && "(test-precondition)");
+
+ QVERIFY(!file1.copy("existing-file.txt"));
+ QCOMPARE(file1.error(), QFile::CopyError);
+
+ QVERIFY(file1.copy("copied-file-1.txt"));
+ QVERIFY(!file1.isOpen());
+ QCOMPARE(file1.error(), QFile::NoError);
+
+ QVERIFY(!file1.copy("existing-file.txt"));
+ QCOMPARE(file1.error(), QFile::CopyError);
+
+ QVERIFY(file1.copy("copied-file-2.txt"));
+ QVERIFY(!file1.isOpen());
+ QCOMPARE(file1.error(), QFile::NoError);
+
+ QVERIFY(QFile::exists("copied-file-1.txt"));
+ QVERIFY(QFile::exists("copied-file-2.txt"));
+
+ QVERIFY(QFile::remove("file-to-be-copied.txt") && "(test-cleanup)");
+ QVERIFY(QFile::remove("existing-file.txt") && "(test-cleanup)");
+ QVERIFY(QFile::remove("copied-file-1.txt") && "(test-cleanup)");
+ QVERIFY(QFile::remove("copied-file-2.txt") && "(test-cleanup)");
+}
+
void tst_QFile::copyRemovesTemporaryFile() const
{
const QString newName(QLatin1String("copyRemovesTemporaryFile"));
@@ -2152,24 +2193,42 @@ void tst_QFile::renameMultiple()
{
// create the file if it doesn't exist
QFile file("file-to-be-renamed.txt");
+ QFile file2("existing-file.txt");
QVERIFY(file.open(QIODevice::ReadWrite) && "(test-precondition)");
+ QVERIFY(file2.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(QFile::exists("existing-file.txt"));
+ QVERIFY(!file.rename("existing-file.txt"));
+ QCOMPARE(file.error(), QFile::RenameError);
+ QCOMPARE(file.fileName(), QString("file-to-be-renamed.txt"));
+
QVERIFY(file.rename("file-renamed-once.txt"));
+ QVERIFY(!file.isOpen());
QCOMPARE(file.fileName(), QString("file-renamed-once.txt"));
+
+ QVERIFY(QFile::exists("existing-file.txt"));
+ QVERIFY(!file.rename("existing-file.txt"));
+ QCOMPARE(file.error(), QFile::RenameError);
+ QCOMPARE(file.fileName(), QString("file-renamed-once.txt"));
+
QVERIFY(file.rename("file-renamed-twice.txt"));
+ QVERIFY(!file.isOpen());
QCOMPARE(file.fileName(), QString("file-renamed-twice.txt"));
+ QVERIFY(QFile::exists("existing-file.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();
+ file2.remove();
QVERIFY(!QFile::exists("file-renamed-twice.txt"));
+ QVERIFY(!QFile::exists("existing-file.txt"));
}
void tst_QFile::appendAndRead()