diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-09-07 10:40:20 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-09-15 14:25:50 +0000 |
commit | 6320ca79e956241f9dfab829be9cb3800339fdb3 (patch) | |
tree | ac510764e06d9c14075f416ce2c69c04383cd730 /tests/auto | |
parent | 6b2071c697d4c48f0cd289b28b443ebffc3432e6 (diff) |
Fix test for sandboxed targets
Instead of creating files relative to the application binary, use a
temporary directory. This also cleans up the test data after execution.
Change-Id: I5d680fd01c60b0d33df06f9cb9aaef7c86279710
Reviewed-by: Jesus Fernandez <jesus.fernandez@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp index 9d42ae5850..43b2b79698 100644 --- a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp +++ b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <QtCore/QTemporaryDir> #include <QtTest/QtTest> #include <QtGui/qevent.h> @@ -38,6 +39,7 @@ public: public slots: void initTestCase(); + void cleanupTestCase(); private slots: void constructor(); @@ -54,6 +56,9 @@ private: bool appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent); bool event(QEvent *); + + QTemporaryDir m_temporaryDir; + QString m_originalCurrent; }; tst_qfileopenevent::~tst_qfileopenevent() @@ -62,6 +67,13 @@ tst_qfileopenevent::~tst_qfileopenevent() void tst_qfileopenevent::initTestCase() { + m_originalCurrent = QDir::currentPath(); + QDir::setCurrent(m_temporaryDir.path()); +} + +void tst_qfileopenevent::cleanupTestCase() +{ + QDir::setCurrent(m_originalCurrent); } void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content) |