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>
This commit is contained in:
parent
6b2071c697
commit
6320ca79e9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user