From 6320ca79e956241f9dfab829be9cb3800339fdb3 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 7 Sep 2016 10:40:20 +0200 Subject: [PATCH] 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 Reviewed-by: Oliver Wolff --- .../qfileopenevent/test/tst_qfileopenevent.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 #include #include @@ -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)