summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qtextstream
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-03-21 09:02:57 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-21 09:02:57 +0100
commit6cb8121a44ee0f94f2c9fcb075d1d3c802d8c5c7 (patch)
tree25822898b71068f820d25a9e8372dfb348190ec1 /tests/auto/corelib/io/qtextstream
parent96740193e1e0f0608f67660811a44b696924ad4c (diff)
parent2e02de165115c9d67ac343ff0960ed80f9c09bc8 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/widgets/styles/qgtkstyle_p.cpp tests/auto/corelib/io/qtextstream/test/test.pro tests/auto/corelib/plugin/plugin.pro Change-Id: I512bc1b36acf3933ed2b96c00f476ee3819c1f4b
Diffstat (limited to 'tests/auto/corelib/io/qtextstream')
-rw-r--r--tests/auto/corelib/io/qtextstream/test/test.pro4
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp22
2 files changed, 22 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qtextstream/test/test.pro b/tests/auto/corelib/io/qtextstream/test/test.pro
index 93fb6d232f..50335524d3 100644
--- a/tests/auto/corelib/io/qtextstream/test/test.pro
+++ b/tests/auto/corelib/io/qtextstream/test/test.pro
@@ -19,3 +19,7 @@ TESTDATA += \
../qtextstream.qrc \
../tst_qtextstream.cpp \
../resources
+
+builtin_testdata {
+ DEFINES += BUILTIN_TESTDATA
+}
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 2852420557..104873b85e 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -60,6 +60,7 @@ public:
public slots:
void initTestCase();
void cleanup();
+ void cleanupTestCase();
private slots:
void getSetCheck();
@@ -236,6 +237,9 @@ private:
QTemporaryDir tempDir;
QString testFileName;
+#ifdef BUILTIN_TESTDATA
+ QSharedPointer<QTemporaryDir> m_dataDir;
+#endif
const QString m_rfc3261FilePath;
const QString m_shiftJisFilePath;
};
@@ -262,9 +266,14 @@ void tst_QTextStream::initTestCase()
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
QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
+#endif
}
// Testing get/set functions
@@ -387,6 +396,13 @@ void tst_QTextStream::cleanup()
QCoreApplication::instance()->processEvents();
}
+void tst_QTextStream::cleanupTestCase()
+{
+#ifdef BUILTIN_TESTDATA
+ QDir::setCurrent(QCoreApplication::applicationDirPath());
+#endif
+}
+
// ------------------------------------------------------------------------------
void tst_QTextStream::construction()
{
@@ -3044,12 +3060,10 @@ void tst_QTextStream::int_write_with_locale()
void tst_QTextStream::textModeOnEmptyRead()
{
- const QString filename("textmodetest.txt");
- QFile::remove(filename); // Remove file if exists
-
+ const QString filename(tempDir.path() + QLatin1String("/textmodetest.txt"));
QFile file(filename);
- QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Text));
+ QVERIFY2(file.open(QIODevice::ReadWrite | QIODevice::Text), qPrintable(file.errorString()));
QTextStream stream(&file);
QVERIFY(file.isTextModeEnabled());
QString emptyLine = stream.readLine(); // Text mode flag cleared here