From f05c597ae506ea6163394dbb6b70ecc77fae3b3c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Dec 2015 13:42:28 +0100 Subject: winrt: msvc2015: refactor file handling msvc2015 reintroduced a couple of functions from the win32 API towards WinRT. Enable usage of those and simplify the file system engine. Furthermore update the autotests. Change-Id: I9eafffba0ddfd05917c184c4a6b9e166f86d71d9 Reviewed-by: Oliver Wolff --- .../auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp') diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 94e6bbaade..6e461cae17 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -85,10 +85,15 @@ private slots: void QTBUG_4796_data(); void QTBUG_4796(); void guaranteeUnique(); +private: + QString m_previousCurrent; }; void tst_QTemporaryFile::initTestCase() { + m_previousCurrent = QDir::currentPath(); + QDir::setCurrent(QDir::tempPath()); + // For QTBUG_4796 QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX")); QCoreApplication::setApplicationName("tst_qtemporaryfile"); @@ -116,6 +121,8 @@ void tst_QTemporaryFile::cleanupTestCase() { // From QTBUG_4796 QVERIFY(QDir().rmdir("test-XXXXXX")); + + QDir::setCurrent(m_previousCurrent); } void tst_QTemporaryFile::construction() @@ -678,8 +685,11 @@ void tst_QTemporaryFile::createNativeFile_data() const QString nativeFilePath = QFINDTESTDATA("resources/test.txt"); #endif - QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); - QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray(); + // File might not exist locally in case of sandboxing or remote testing + if (!nativeFilePath.startsWith(QLatin1String(":/"))) { + QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray(); + QTest::newRow("nativeFileWithPos") << nativeFilePath << (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"); } -- cgit v1.2.3