summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp25
-rw-r--r--tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp13
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro2
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp16
5 files changed, 28 insertions, 30 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 9026864b12..c173a87a41 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -405,6 +405,8 @@ void tst_QFile::cleanup()
QDir remainingDir(absoluteFilePath);
QVERIFY2(remainingDir.removeRecursively(), qPrintable(absoluteFilePath));
} else {
+ if (!(QFile::permissions(absoluteFilePath) & QFile::WriteUser))
+ QVERIFY2(QFile::setPermissions(absoluteFilePath, QFile::WriteUser), qPrintable(absoluteFilePath));
QVERIFY2(QFile::remove(absoluteFilePath), qPrintable(absoluteFilePath));
}
}
@@ -443,8 +445,6 @@ void tst_QFile::initTestCase()
m_stdinProcessDir = QFINDTESTDATA("stdinprocess");
QVERIFY(!m_stdinProcessDir.isEmpty());
#endif
- m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp");
- QVERIFY(!m_testSourceFile.isEmpty());
m_testLogFile = QFINDTESTDATA("testlog.txt");
QVERIFY(!m_testLogFile.isEmpty());
m_dosFile = QFINDTESTDATA("dosfile.txt");
@@ -457,15 +457,19 @@ void tst_QFile::initTestCase()
QVERIFY(!m_twoDotsFile.isEmpty());
#ifndef BUILTIN_TESTDATA
+ m_testSourceFile = QFINDTESTDATA("tst_qfile.cpp");
+ QVERIFY(!m_testSourceFile.isEmpty());
m_testFile = QFINDTESTDATA("testfile.txt");
QVERIFY(!m_testFile.isEmpty());
+ m_resourcesDir = QFINDTESTDATA("resources");
+ QVERIFY(!m_resourcesDir.isEmpty());
#else
m_dataDir = QEXTRACTTESTDATA("/");
QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data"));
m_testFile = m_dataDir->path() + "/testfile.txt";
+ m_testSourceFile = m_dataDir->path() + "/tst_qfile.cpp";
+ m_resourcesDir = m_dataDir->path() + "/resources";
#endif
- m_resourcesDir = QFINDTESTDATA("resources");
- QVERIFY(!m_resourcesDir.isEmpty());
m_noEndOfLineFile = QFINDTESTDATA("noendofline.txt");
QVERIFY(!m_noEndOfLineFile.isEmpty());
@@ -2189,12 +2193,20 @@ public:
if (fileName.startsWith(":!")) {
QDir dir;
- QString realFile = QFINDTESTDATA(fileName.mid(2));
+#ifndef BUILTIN_TESTDATA
+ const QString realFile = QFINDTESTDATA(fileName.mid(2));
+#else
+ const QString realFile = m_dataDir->filePath(fileName.mid(2));
+#endif
if (dir.exists(realFile))
return new QFSFileEngine(realFile);
}
return 0;
}
+
+#ifdef BUILTIN_TESTDATA
+ QSharedPointer<QTemporaryDir> m_dataDir;
+#endif
};
#endif
@@ -2203,6 +2215,9 @@ void tst_QFile::useQFileInAFileHandler()
{
// This test should not dead-lock
MyRecursiveHandler handler;
+#ifdef BUILTIN_TESTDATA
+ handler.m_dataDir = m_dataDir;
+#endif
QFile file(":!tst_qfile.cpp");
QVERIFY(file.exists());
}
diff --git a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
index 351e263093..5908648378 100644
--- a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
+++ b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
@@ -4,4 +4,4 @@ SOURCES += tst_qtemporarydir.cpp
INCLUDEPATH += ../../../../shared/
HEADERS += ../../../../shared/emulationdetector.h
-QT = core testlib
+QT = core testlib testlib-private
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index fcd9133099..76462be376 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -35,6 +35,7 @@
#include <qdir.h>
#include <qset.h>
#include <qtextcodec.h>
+#include <QtTest/private/qtesthelpers_p.h>
#ifdef Q_OS_WIN
# include <windows.h>
#endif
@@ -112,16 +113,6 @@ void tst_QTemporaryDir::getSetCheck()
QCOMPARE(true, obj1.autoRemove());
}
-static inline bool canHandleUnicodeFileNames()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- return true;
-#else
- // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
- return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
-#endif
-}
-
static QString hanTestText()
{
QString text;
@@ -159,7 +150,7 @@ void tst_QTemporaryDir::fileTemplate_data()
QTest::newRow("4Xsuffix") << "qt_XXXXXX_XXXX" << "qt_" << "_XXXX";
QTest::newRow("4Xprefix") << "qt_XXXX" << "qt_XXXX" << "";
QTest::newRow("5Xprefix") << "qt_XXXXX" << "qt_XXXXX" << "";
- if (canHandleUnicodeFileNames()) {
+ if (QTestPrivate::canHandleUnicodeFileNames()) {
// Test Umlauts (contained in Latin1)
QString prefix = "qt_" + umlautTestText();
QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << "";
diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro
index a89e5c66ff..e17cb05cd8 100644
--- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro
+++ b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_qtemporaryfile
-QT = core testlib
+QT = core testlib testlib-private
SOURCES = tst_qtemporaryfile.cpp
TESTDATA += tst_qtemporaryfile.cpp
RESOURCES += qtemporaryfile.qrc
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 11c24ca86f..f3ce902bbd 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -38,6 +38,8 @@
#include <qset.h>
#include <qtextcodec.h>
+#include <QtTest/private/qtesthelpers_p.h>
+
#if defined(Q_OS_WIN)
# include <windows.h>
#endif
@@ -143,16 +145,6 @@ void tst_QTemporaryFile::getSetCheck()
QCOMPARE(true, obj1.autoRemove());
}
-static inline bool canHandleUnicodeFileNames()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- return true;
-#else
- // Check for UTF-8 by converting the Euro symbol (see tst_utf8)
- return QFile::encodeName(QString(QChar(0x20AC))) == QByteArrayLiteral("\342\202\254");
-#endif
-}
-
static QString hanTestText()
{
QString text;
@@ -201,7 +193,7 @@ void tst_QTemporaryFile::fileTemplate_data()
QTest::newRow("set template, with xxx") << "" << "qt_" << ".xxx" << "qt_XXXXXX.xxx";
QTest::newRow("set template, with >6 X's") << "" << "qt_" << ".xxx" << "qt_XXXXXXXXXXXXXX.xxx";
QTest::newRow("set template, with >6 X's, no suffix") << "" << "qt_" << "" << "qt_XXXXXXXXXXXXXX";
- if (canHandleUnicodeFileNames()) {
+ if (QTestPrivate::canHandleUnicodeFileNames()) {
// Test Umlauts (contained in Latin1)
QString prefix = "qt_" + umlautTestText();
QTest::newRow("Umlauts") << (prefix + "XXXXXX") << prefix << QString() << QString();
@@ -824,7 +816,7 @@ void tst_QTemporaryFile::QTBUG_4796_data()
QTest::newRow("XXXXXXbla") << QString() << QString("bla") << true;
QTest::newRow("does-not-exist/qt_temp.XXXXXX") << QString("does-not-exist/qt_temp") << QString() << false;
- if (canHandleUnicodeFileNames()) {
+ if (QTestPrivate::canHandleUnicodeFileNames()) {
QTest::newRow("XXXXXX<unicode>") << QString() << unicode << true;
QTest::newRow("<unicode>XXXXXX") << unicode << QString() << true;
QTest::newRow("<unicode>XXXXXX<unicode>") << unicode << unicode << true;