summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp')
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index a41f1aa06f..72dedf8be7 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -80,10 +80,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");
@@ -111,6 +116,8 @@ void tst_QTemporaryFile::cleanupTestCase()
{
// From QTBUG_4796
QVERIFY(QDir().rmdir("test-XXXXXX"));
+
+ QDir::setCurrent(m_previousCurrent);
}
void tst_QTemporaryFile::construction()
@@ -673,8 +680,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");
}