QTextStream test: Change current directory
For platforms with builtin testdata/sandboxed platforms we need to change the current directory to be able to create files. Change-Id: I440205c95dd6df1308c6bf24b1b0f67fd697feab Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
parent
e363817498
commit
eef3afaa97
@ -21,3 +21,7 @@ TESTDATA += \
|
|||||||
../tst_qtextstream.cpp \
|
../tst_qtextstream.cpp \
|
||||||
../resources
|
../resources
|
||||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||||
|
|
||||||
|
builtin_testdata {
|
||||||
|
DEFINES += BUILTIN_TESTDATA
|
||||||
|
}
|
||||||
|
@ -65,6 +65,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
void cleanupTestCase();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void getSetCheck();
|
void getSetCheck();
|
||||||
@ -241,6 +242,9 @@ private:
|
|||||||
|
|
||||||
QTemporaryDir tempDir;
|
QTemporaryDir tempDir;
|
||||||
QString testFileName;
|
QString testFileName;
|
||||||
|
#ifdef BUILTIN_TESTDATA
|
||||||
|
QSharedPointer<QTemporaryDir> m_dataDir;
|
||||||
|
#endif
|
||||||
const QString m_rfc3261FilePath;
|
const QString m_rfc3261FilePath;
|
||||||
const QString m_shiftJisFilePath;
|
const QString m_shiftJisFilePath;
|
||||||
};
|
};
|
||||||
@ -267,9 +271,14 @@ void tst_QTextStream::initTestCase()
|
|||||||
|
|
||||||
testFileName = tempDir.path() + "/testfile";
|
testFileName = tempDir.path() + "/testfile";
|
||||||
|
|
||||||
|
#ifdef BUILTIN_TESTDATA
|
||||||
|
m_dataDir = QEXTRACTTESTDATA("/");
|
||||||
|
QVERIFY2(QDir::setCurrent(m_dataDir->path()), qPrintable("Could not chdir to " + m_dataDir->path()));
|
||||||
|
#else
|
||||||
// chdir into the testdata dir and refer to our helper apps with relative paths
|
// chdir into the testdata dir and refer to our helper apps with relative paths
|
||||||
QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath();
|
QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath();
|
||||||
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
|
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing get/set functions
|
// Testing get/set functions
|
||||||
@ -392,6 +401,13 @@ void tst_QTextStream::cleanup()
|
|||||||
QCoreApplication::instance()->processEvents();
|
QCoreApplication::instance()->processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTextStream::cleanupTestCase()
|
||||||
|
{
|
||||||
|
#ifdef BUILTIN_TESTDATA
|
||||||
|
QDir::setCurrent(QCoreApplication::applicationDirPath());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
void tst_QTextStream::construction()
|
void tst_QTextStream::construction()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user