diff options
author | Andy Shaw <andy.shaw@digia.com> | 2012-09-25 13:14:52 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 10:43:48 +0200 |
commit | ef3a544436beaecb4d26349ce115be39b680ef6a (patch) | |
tree | 540c4d2f4485794165d6d780b04296da8910db14 /tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | |
parent | f20266f9f43ab3956de271f696c769db02992e87 (diff) |
Rename createLocalFile to createNativeFile & deprecate createLocalFile
As it was confusing to use the term local file when referring
to a file that was accessible using native APIs and not just
a file that was on a hard disk somewhere already the function
name has been changed.
By renaming it to createNativeFile we keep it consistant with QFileInfo
which has an isNativeFile() function too.
Test also added.
Task-number: QTBUG-3169
Change-Id: I410e7ed28133d68fd312c6c0faf3f7191460d7ce
Reviewed-by: João Abecasis <joao@abecasis.name>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp')
-rw-r--r-- | tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index e68594ebaf..6d7a6e76ef 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -88,7 +88,8 @@ private slots: void resetTemplateAfterError(); void setTemplateAfterOpen(); void autoRemoveAfterFailedRename(); - + void createNativeFile_data(); + void createNativeFile(); void QTBUG_4796_data(); void QTBUG_4796(); }; @@ -633,6 +634,41 @@ void tst_QTemporaryFile::autoRemoveAfterFailedRename() cleaner.reset(); } +void tst_QTemporaryFile::createNativeFile_data() +{ + QTest::addColumn<QString>("filePath"); + QTest::addColumn<qint64>("currentPos"); + QTest::addColumn<bool>("valid"); + QTest::addColumn<QByteArray>("content"); + + QTest::newRow("nativeFile") << QFINDTESTDATA("resources/test.txt") << (qint64)-1 << false << QByteArray(); + QTest::newRow("nativeFileWithPos") << QFINDTESTDATA("resources/test.txt") << (qint64)5 << false << QByteArray(); + QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test"); + QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test"); +} + +void tst_QTemporaryFile::createNativeFile() +{ + QFETCH(QString, filePath); + QFETCH(qint64, currentPos); + QFETCH(bool, valid); + QFETCH(QByteArray, content); + + QFile f(filePath); + if (currentPos != -1) { + f.open(QIODevice::ReadOnly); + f.seek(currentPos); + } + QTemporaryFile *tempFile = QTemporaryFile::createNativeFile(f); + QVERIFY(valid == (bool)tempFile); + if (currentPos != -1) + QCOMPARE(currentPos, f.pos()); + if (valid) { + QCOMPARE(content, tempFile->readAll()); + delete tempFile; + } +} + void tst_QTemporaryFile::QTBUG_4796_data() { QTest::addColumn<QString>("prefix"); |