summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp52
-rw-r--r--tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp8
-rw-r--r--tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp152
-rw-r--r--tests/auto/gui/image/qimagereader/tst_qimagereader.cpp31
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp8
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp14
-rw-r--r--tests/auto/tools/qmake/testdata/.gitignore5
7 files changed, 183 insertions, 87 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 83da28767f..1c639c94a8 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -38,6 +38,7 @@
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QThread>
+#include <QtCore/QTemporaryDir>
#include <QtCore/QRegExp>
#include <QtCore/QDebug>
#include <QtCore/QMetaType>
@@ -54,14 +55,6 @@ Q_DECLARE_METATYPE(QProcess::ExitStatus);
Q_DECLARE_METATYPE(QProcess::ProcessState);
#endif
-#define QPROCESS_VERIFY(Process, Fn) \
-{ \
-const bool ret = Process.Fn; \
-if (ret == false) \
- qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \
-QVERIFY(ret); \
-}
-
typedef void (QProcess::*QProcessFinishedSignal1)(int);
typedef void (QProcess::*QProcessFinishedSignal2)(int, QProcess::ExitStatus);
typedef void (QProcess::*QProcessErrorSignal)(QProcess::ProcessError);
@@ -180,6 +173,7 @@ protected slots:
private:
qint64 bytesAvailable;
+ QTemporaryDir m_temporaryDir;
#endif //QT_NO_PROCESS
};
@@ -188,6 +182,7 @@ void tst_QProcess::initTestCase()
#ifdef QT_NO_PROCESS
QSKIP("This test requires QProcess support");
#else
+ QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
// chdir to our testdata path and execute helper apps relative to that.
QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
@@ -1717,7 +1712,7 @@ void tst_QProcess::failToStartEmptyArgs()
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::removeFileWhileProcessIsRunning()
{
- QFile file("removeFile.txt");
+ QFile file(m_temporaryDir.path() + QLatin1String("/removeFile.txt"));
QVERIFY(file.open(QFile::WriteOnly));
QProcess process;
@@ -1948,16 +1943,16 @@ void tst_QProcess::setStandardInputFile()
{
static const char data[] = "A bunch\1of\2data\3\4\5\6\7...";
QProcess process;
- QFile file("data");
+ QFile file(m_temporaryDir.path() + QLatin1String("/data-sif"));
QVERIFY(file.open(QIODevice::WriteOnly));
file.write(data, sizeof data);
file.close();
- process.setStandardInputFile("data");
+ process.setStandardInputFile(file.fileName());
process.start("testProcessEcho/testProcessEcho");
- QPROCESS_VERIFY(process, waitForFinished());
+ QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
QByteArray all = process.readAll();
@@ -1967,7 +1962,7 @@ void tst_QProcess::setStandardInputFile()
QProcess process2;
process2.setStandardInputFile(QProcess::nullDevice());
process2.start("testProcessEcho/testProcessEcho");
- QPROCESS_VERIFY(process2, waitForFinished());
+ QVERIFY(process2.waitForFinished());
all = process2.readAll();
QCOMPARE(all.size(), 0);
}
@@ -2016,7 +2011,7 @@ void tst_QProcess::setStandardOutputFile()
QIODevice::OpenMode mode = append ? QIODevice::Append : QIODevice::Truncate;
// create the destination file with data
- QFile file("data");
+ QFile file(m_temporaryDir.path() + QLatin1String("/data-stdof-") + QLatin1String(QTest::currentDataTag()));
QVERIFY(file.open(QIODevice::WriteOnly));
file.write(data, sizeof data - 1);
file.close();
@@ -2025,13 +2020,13 @@ void tst_QProcess::setStandardOutputFile()
QProcess process;
process.setReadChannelMode(channelMode);
if (channelToTest == QProcess::StandardOutput)
- process.setStandardOutputFile("data", mode);
+ process.setStandardOutputFile(file.fileName(), mode);
else
- process.setStandardErrorFile("data", mode);
+ process.setStandardErrorFile(file.fileName(), mode);
process.start("testProcessEcho2/testProcessEcho2");
process.write(testdata, sizeof testdata);
- QPROCESS_VERIFY(process,waitForFinished());
+ QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
@@ -2062,7 +2057,7 @@ void tst_QProcess::setStandardOutputFileNullDevice()
process.setStandardOutputFile(QProcess::nullDevice());
process.start("testProcessEcho2/testProcessEcho2");
process.write(testdata, sizeof testdata);
- QPROCESS_VERIFY(process,waitForFinished());
+ QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
@@ -2074,13 +2069,14 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
{
static const char testdata[] = "Test data.";
- QFile file("data");
+ QFile file(m_temporaryDir.path() + QLatin1String("/data-stdofawfbw"));
QProcess process;
process.setStandardOutputFile(file.fileName());
process.start("testProcessEcho2/testProcessEcho2");
+ QVERIFY2(process.waitForStarted(), qPrintable(process.errorString()));
process.write(testdata, sizeof testdata);
process.waitForBytesWritten();
- QPROCESS_VERIFY(process, waitForFinished());
+ QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
@@ -2122,10 +2118,10 @@ void tst_QProcess::setStandardOutputProcess()
if (waitForBytesWritten)
source.waitForBytesWritten();
source.closeWriteChannel();
- QPROCESS_VERIFY(source, waitForFinished());
+ QVERIFY(source.waitForFinished());
QCOMPARE(source.exitStatus(), QProcess::NormalExit);
QCOMPARE(source.exitCode(), 0);
- QPROCESS_VERIFY(sink, waitForFinished());
+ QVERIFY(sink.waitForFinished());
QCOMPARE(sink.exitStatus(), QProcess::NormalExit);
QCOMPARE(sink.exitCode(), 0);
QByteArray all = sink.readAll();
@@ -2151,14 +2147,15 @@ void tst_QProcess::fileWriterProcess()
QTime stopWatch;
stopWatch.start();
- const QString fileName = QLatin1String("fileWriterProcess.txt");
+ const QString fileName = m_temporaryDir.path() + QLatin1String("/fileWriterProcess.txt");
+ const QString binary = QDir::currentPath() + QLatin1String("/fileWriterProcess/fileWriterProcess");
do {
if (QFile::exists(fileName))
QVERIFY(QFile::remove(fileName));
QProcess process;
- process.start("fileWriterProcess/fileWriterProcess",
- QIODevice::ReadWrite | QIODevice::Text);
+ process.setWorkingDirectory(m_temporaryDir.path());
+ process.start(binary, QIODevice::ReadWrite | QIODevice::Text);
process.write(stdinStr);
process.closeWriteChannel();
while (process.bytesToWrite()) {
@@ -2181,8 +2178,9 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
QTest::qSleep(1000);
#endif
- QFile infoFile(QDir::currentPath() + QLatin1String("/detachedinfo.txt"));
- infoFile.remove();
+ QFile infoFile(m_temporaryDir.path() + QLatin1String("/detachedinfo.txt"));
+ if (infoFile.exists())
+ QVERIFY(infoFile.remove());
QString workingDir = QDir::currentPath() + "/testDetached";
diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
index 1531e0ac40..20ff670835 100644
--- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp
@@ -49,6 +49,9 @@ class tst_QItemModel : public QObject
{
Q_OBJECT
+public:
+ tst_QItemModel();
+
public slots:
void init();
void cleanup();
@@ -124,6 +127,11 @@ private:
bool insertRecursively;
};
+tst_QItemModel::tst_QItemModel()
+{
+ qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>();
+}
+
void tst_QItemModel::init()
{
testModels = new ModelsToTest();
diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
index dea305e3e1..df52aa4949 100644
--- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
+++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp
@@ -33,6 +33,7 @@
#include <QtTest/QtTest>
+#include <qatomic.h>
#include <qcoreapplication.h>
#include <qmutex.h>
#include <qthread.h>
@@ -54,7 +55,25 @@ private slots:
static const int iterations = 4;
static const int ThreadCount = 4;
-class wait_QMutex_Thread_1 : public QThread
+// Terminate thread in destructor for threads instantiated on the stack
+class TerminatingThread : public QThread
+{
+public:
+ explicit TerminatingThread()
+ {
+ setTerminationEnabled(true);
+ }
+
+ ~TerminatingThread()
+ {
+ if (isRunning()) {
+ qWarning() << "forcibly terminating " << objectName();
+ terminate();
+ }
+ }
+};
+
+class wait_QMutex_Thread_1 : public TerminatingThread
{
public:
QMutex mutex;
@@ -72,7 +91,7 @@ public:
}
};
-class wait_QMutex_Thread_2 : public QThread
+class wait_QMutex_Thread_2 : public TerminatingThread
{
public:
QWaitCondition started;
@@ -93,7 +112,7 @@ public:
}
};
-class wait_QReadWriteLock_Thread_1 : public QThread
+class wait_QReadWriteLock_Thread_1 : public TerminatingThread
{
public:
QReadWriteLock readWriteLock;
@@ -111,7 +130,7 @@ public:
}
};
-class wait_QReadWriteLock_Thread_2 : public QThread
+class wait_QReadWriteLock_Thread_2 : public TerminatingThread
{
public:
QWaitCondition started;
@@ -155,7 +174,11 @@ void tst_QWaitCondition::wait_QMutex()
// test multiple threads waiting on separate wait conditions
wait_QMutex_Thread_1 thread[ThreadCount];
+ const QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_mutex_")
+ + QString::number(i) + QLatin1Char('_');
+
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
thread[x].mutex.lock();
thread[x].start();
// wait for thread to start
@@ -185,8 +208,12 @@ void tst_QWaitCondition::wait_QMutex()
QWaitCondition cond1, cond2;
wait_QMutex_Thread_2 thread[ThreadCount];
+ const QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_mutex_")
+ + QString::number(i) + QLatin1Char('_');
+
mutex.lock();
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
thread[x].mutex = &mutex;
thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2;
thread[x].start();
@@ -289,7 +316,10 @@ void tst_QWaitCondition::wait_QReadWriteLock()
// test multiple threads waiting on separate wait conditions
wait_QReadWriteLock_Thread_1 thread[ThreadCount];
+ const QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_lockforread_");
+
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
thread[x].readWriteLock.lockForRead();
thread[x].start();
// wait for thread to start
@@ -319,8 +349,11 @@ void tst_QWaitCondition::wait_QReadWriteLock()
QWaitCondition cond1, cond2;
wait_QReadWriteLock_Thread_2 thread[ThreadCount];
+ const QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_lockforwrite_");
+
readWriteLock.lockForWrite();
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
thread[x].readWriteLock = &readWriteLock;
thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2;
thread[x].start();
@@ -346,11 +379,17 @@ void tst_QWaitCondition::wait_QReadWriteLock()
}
}
-class wake_Thread : public QThread
+class WakeThreadBase : public TerminatingThread
{
public:
- static int count;
+ QAtomicInt *count;
+ WakeThreadBase() : count(Q_NULLPTR) {}
+};
+
+class wake_Thread : public WakeThreadBase
+{
+public:
QWaitCondition started;
QWaitCondition dummy;
@@ -366,24 +405,23 @@ public:
void run()
{
+ Q_ASSERT(count);
+ Q_ASSERT(mutex);
+ Q_ASSERT(cond);
mutex->lock();
- ++count;
+ ++*count;
dummy.wakeOne(); // this wakeup should be lost
started.wakeOne();
dummy.wakeAll(); // this one too
cond->wait(mutex);
- --count;
+ --*count;
mutex->unlock();
}
};
-int wake_Thread::count = 0;
-
-class wake_Thread_2 : public QThread
+class wake_Thread_2 : public WakeThreadBase
{
public:
- static int count;
-
QWaitCondition started;
QWaitCondition dummy;
@@ -399,22 +437,27 @@ public:
void run()
{
+ Q_ASSERT(count);
+ Q_ASSERT(readWriteLock);
+ Q_ASSERT(cond);
readWriteLock->lockForWrite();
- ++count;
+ ++*count;
dummy.wakeOne(); // this wakeup should be lost
started.wakeOne();
dummy.wakeAll(); // this one too
cond->wait(readWriteLock);
- --count;
+ --*count;
readWriteLock->unlock();
}
};
-int wake_Thread_2::count = 0;
-
void tst_QWaitCondition::wakeOne()
{
+ static const int firstWaitInterval = 1000;
+ static const int waitInterval = 30;
+
int x;
+ QAtomicInt count;
// wake up threads, one at a time
for (int i = 0; i < iterations; ++i) {
QMutex mutex;
@@ -424,8 +467,13 @@ void tst_QWaitCondition::wakeOne()
wake_Thread thread[ThreadCount];
bool thread_exited[ThreadCount];
+ QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_mutex_")
+ + QString::number(i) + QLatin1Char('_');
+
mutex.lock();
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
+ thread[x].count = &count;
thread[x].mutex = &mutex;
thread[x].cond = &cond;
thread_exited[x] = false;
@@ -438,7 +486,7 @@ void tst_QWaitCondition::wakeOne()
}
mutex.unlock();
- QCOMPARE(wake_Thread::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up threads one at a time
for (x = 0; x < ThreadCount; ++x) {
@@ -452,24 +500,29 @@ void tst_QWaitCondition::wakeOne()
for (int y = 0; y < ThreadCount; ++y) {
if (thread_exited[y])
continue;
- if (thread[y].wait(exited > 0 ? 10 : 1000)) {
+ if (thread[y].wait(exited > 0 ? waitInterval : firstWaitInterval)) {
thread_exited[y] = true;
++exited;
}
}
QCOMPARE(exited, 1);
- QCOMPARE(wake_Thread::count, ThreadCount - (x + 1));
+ QCOMPARE(count.load(), ThreadCount - (x + 1));
}
- QCOMPARE(wake_Thread::count, 0);
+ QCOMPARE(count.load(), 0);
// QReadWriteLock
QReadWriteLock readWriteLock;
wake_Thread_2 rwthread[ThreadCount];
+ prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_readwritelock_")
+ + QString::number(i) + QLatin1Char('_');
+
readWriteLock.lockForWrite();
for (x = 0; x < ThreadCount; ++x) {
+ rwthread[x].setObjectName(prefix + QString::number(x));
+ rwthread[x].count = &count;
rwthread[x].readWriteLock = &readWriteLock;
rwthread[x].cond = &cond;
thread_exited[x] = false;
@@ -482,7 +535,7 @@ void tst_QWaitCondition::wakeOne()
}
readWriteLock.unlock();
- QCOMPARE(wake_Thread_2::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up threads one at a time
for (x = 0; x < ThreadCount; ++x) {
@@ -496,17 +549,17 @@ void tst_QWaitCondition::wakeOne()
for (int y = 0; y < ThreadCount; ++y) {
if (thread_exited[y])
continue;
- if (rwthread[y].wait(exited > 0 ? 10 : 1000)) {
+ if (rwthread[y].wait(exited > 0 ? waitInterval : firstWaitInterval)) {
thread_exited[y] = true;
++exited;
}
}
QCOMPARE(exited, 1);
- QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 1));
+ QCOMPARE(count.load(), ThreadCount - (x + 1));
}
- QCOMPARE(wake_Thread_2::count, 0);
+ QCOMPARE(count.load(), 0);
}
// wake up threads, two at a time
@@ -518,8 +571,13 @@ void tst_QWaitCondition::wakeOne()
wake_Thread thread[ThreadCount];
bool thread_exited[ThreadCount];
+ QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_mutex2_")
+ + QString::number(i) + QLatin1Char('_');
+
mutex.lock();
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
+ thread[x].count = &count;
thread[x].mutex = &mutex;
thread[x].cond = &cond;
thread_exited[x] = false;
@@ -532,7 +590,7 @@ void tst_QWaitCondition::wakeOne()
}
mutex.unlock();
- QCOMPARE(wake_Thread::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up threads one at a time
for (x = 0; x < ThreadCount; x += 2) {
@@ -548,24 +606,29 @@ void tst_QWaitCondition::wakeOne()
for (int y = 0; y < ThreadCount; ++y) {
if (thread_exited[y])
continue;
- if (thread[y].wait(exited > 0 ? 10 : 1000)) {
+ if (thread[y].wait(exited > 0 ? waitInterval : firstWaitInterval)) {
thread_exited[y] = true;
++exited;
}
}
QCOMPARE(exited, 2);
- QCOMPARE(wake_Thread::count, ThreadCount - (x + 2));
+ QCOMPARE(count.load(), ThreadCount - (x + 2));
}
- QCOMPARE(wake_Thread::count, 0);
+ QCOMPARE(count.load(), 0);
// QReadWriteLock
QReadWriteLock readWriteLock;
wake_Thread_2 rwthread[ThreadCount];
+ prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_readwritelock_")
+ + QString::number(i) + QLatin1Char('_');
+
readWriteLock.lockForWrite();
for (x = 0; x < ThreadCount; ++x) {
+ rwthread[x].setObjectName(prefix + QString::number(x));
+ rwthread[x].count = &count;
rwthread[x].readWriteLock = &readWriteLock;
rwthread[x].cond = &cond;
thread_exited[x] = false;
@@ -578,7 +641,7 @@ void tst_QWaitCondition::wakeOne()
}
readWriteLock.unlock();
- QCOMPARE(wake_Thread_2::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up threads one at a time
for (x = 0; x < ThreadCount; x += 2) {
@@ -594,23 +657,24 @@ void tst_QWaitCondition::wakeOne()
for (int y = 0; y < ThreadCount; ++y) {
if (thread_exited[y])
continue;
- if (rwthread[y].wait(exited > 0 ? 10 : 1000)) {
+ if (rwthread[y].wait(exited > 0 ? waitInterval : firstWaitInterval)) {
thread_exited[y] = true;
++exited;
}
}
QCOMPARE(exited, 2);
- QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 2));
+ QCOMPARE(count.load(), ThreadCount - (x + 2));
}
- QCOMPARE(wake_Thread_2::count, 0);
+ QCOMPARE(count.load(), 0);
}
}
void tst_QWaitCondition::wakeAll()
{
int x;
+ QAtomicInt count;
for (int i = 0; i < iterations; ++i) {
QMutex mutex;
QWaitCondition cond;
@@ -618,8 +682,13 @@ void tst_QWaitCondition::wakeAll()
// QMutex
wake_Thread thread[ThreadCount];
+ QString prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_mutex_")
+ + QString::number(i) + QLatin1Char('_');
+
mutex.lock();
for (x = 0; x < ThreadCount; ++x) {
+ thread[x].setObjectName(prefix + QString::number(x));
+ thread[x].count = &count;
thread[x].mutex = &mutex;
thread[x].cond = &cond;
thread[x].start();
@@ -628,7 +697,7 @@ void tst_QWaitCondition::wakeAll()
}
mutex.unlock();
- QCOMPARE(wake_Thread::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up all threads at once
mutex.lock();
@@ -643,14 +712,19 @@ void tst_QWaitCondition::wakeAll()
}
QCOMPARE(exited, ThreadCount);
- QCOMPARE(wake_Thread::count, 0);
+ QCOMPARE(count.load(), 0);
// QReadWriteLock
QReadWriteLock readWriteLock;
wake_Thread_2 rwthread[ThreadCount];
+ prefix = QLatin1String(QTest::currentTestFunction()) + QLatin1String("_readwritelock_")
+ + QString::number(i) + QLatin1Char('_');
+
readWriteLock.lockForWrite();
for (x = 0; x < ThreadCount; ++x) {
+ rwthread[x].setObjectName(prefix + QString::number(x));
+ rwthread[x].count = &count;
rwthread[x].readWriteLock = &readWriteLock;
rwthread[x].cond = &cond;
rwthread[x].start();
@@ -659,7 +733,7 @@ void tst_QWaitCondition::wakeAll()
}
readWriteLock.unlock();
- QCOMPARE(wake_Thread_2::count, ThreadCount);
+ QCOMPARE(count.load(), ThreadCount);
// wake up all threads at once
readWriteLock.lockForWrite();
@@ -674,11 +748,11 @@ void tst_QWaitCondition::wakeAll()
}
QCOMPARE(exited, ThreadCount);
- QCOMPARE(wake_Thread_2::count, 0);
+ QCOMPARE(count.load(), 0);
}
}
-class wait_RaceConditionThread : public QThread
+class wait_RaceConditionThread : public TerminatingThread
{
public:
wait_RaceConditionThread(QMutex *mutex, QWaitCondition *startup, QWaitCondition *waitCondition,
@@ -707,7 +781,7 @@ public:
}
};
-class wait_RaceConditionThread_2 : public QThread
+class wait_RaceConditionThread_2 : public TerminatingThread
{
public:
wait_RaceConditionThread_2(QReadWriteLock *readWriteLock,
diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
index 1425ce3c2f..68b92e1851 100644
--- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp
@@ -36,7 +36,6 @@
#include <QBuffer>
#include <QDebug>
-#include <QFile>
#include <QImage>
#include <QImageReader>
#include <QImageWriter>
@@ -46,6 +45,7 @@
#include <QTcpServer>
#include <QTimer>
#include <QTemporaryDir>
+#include <QTemporaryFile>
#include <algorithm>
@@ -53,6 +53,22 @@ typedef QMap<QString, QString> QStringMap;
typedef QList<int> QIntList;
Q_DECLARE_METATYPE(QImage::Format)
+static QByteArray msgFileOpenWriteFailed(const QFile &file)
+{
+ const QString result = QLatin1String("Cannot open \"")
+ + QDir::toNativeSeparators(file.fileName())
+ + QLatin1String("\" for writing: ") + file.errorString();
+ return result.toLocal8Bit();
+}
+
+static QByteArray msgFileOpenReadFailed(const QFile &file)
+{
+ const QString result = QLatin1String("Cannot open \"")
+ + QDir::toNativeSeparators(file.fileName())
+ + QLatin1String("\" for reading: ") + file.errorString();
+ return result.toLocal8Bit();
+}
+
class tst_QImageReader : public QObject
{
Q_OBJECT
@@ -1051,7 +1067,7 @@ void tst_QImageReader::readFromDevice()
const QString imageFileName = prefix + fileName;
QImage expectedImage(imageFileName, format);
QFile file(imageFileName);
- QVERIFY(file.open(QFile::ReadOnly));
+ QVERIFY2(file.open(QFile::ReadOnly), msgFileOpenReadFailed(file).constData());
QByteArray imageData = file.readAll();
QVERIFY(!imageData.isEmpty());
{
@@ -1129,12 +1145,11 @@ void tst_QImageReader::readFromFileAfterJunk()
SKIP_IF_UNSUPPORTED(format);
- QFile::remove("junk");
- QFile junkFile("junk");
- QVERIFY(junkFile.open(QFile::WriteOnly));
+ QTemporaryFile junkFile(m_temporaryDir.path() + QLatin1String("/junkXXXXXX"));
+ QVERIFY2(junkFile.open(), msgFileOpenWriteFailed(junkFile).constData());
QFile imageFile(prefix + fileName);
- QVERIFY(imageFile.open(QFile::ReadOnly));
+ QVERIFY2(imageFile.open(QFile::ReadOnly), msgFileOpenReadFailed(imageFile).constData());
QByteArray imageData = imageFile.readAll();
QVERIFY(!imageData.isNull());
@@ -1155,7 +1170,7 @@ void tst_QImageReader::readFromFileAfterJunk()
}
}
junkFile.close();
- junkFile.open(QFile::ReadOnly);
+ QVERIFY2(junkFile.open(), msgFileOpenReadFailed(junkFile).constData());
for (int i = 0; i < iterations; ++i) {
QByteArray ole = junkFile.read(9);
@@ -1205,7 +1220,7 @@ void tst_QImageReader::devicePosition()
QVERIFY(!expected.isNull());
QFile imageFile(prefix + fileName);
- QVERIFY(imageFile.open(QFile::ReadOnly));
+ QVERIFY2(imageFile.open(QFile::ReadOnly), msgFileOpenReadFailed(imageFile).constData());
QByteArray imageData = imageFile.readAll();
QVERIFY(!imageData.isNull());
int imageDataSize = imageData.size();
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index 6c22c47f0e..c49c9c9129 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -89,6 +89,7 @@ private slots:
void saveToTemporaryFile();
private:
+ QTemporaryDir m_temporaryDir;
QString prefix;
QString writePrefix;
};
@@ -112,14 +113,11 @@ static void initializePadding(QImage *image)
void tst_QImageWriter::initTestCase()
{
+ QVERIFY(m_temporaryDir.isValid());
prefix = QFINDTESTDATA("images/");
if (prefix.isEmpty())
QFAIL("Can't find images directory!");
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
- writePrefix = QDir::homePath();
-#else
- writePrefix = prefix;
-#endif
+ writePrefix = m_temporaryDir.path();
}
// Testing get/set functions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index a84d290661..66aa26ccea 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -202,8 +202,7 @@ protected Q_SLOTS:
void notEnoughData();
private Q_SLOTS:
- void init();
- void cleanup();
+ void cleanup() { cleanupTestData(); }
void initTestCase();
void cleanupTestCase();
@@ -487,6 +486,8 @@ private Q_SLOTS:
// NOTE: This test must be last!
void parentingRepliesToTheApp();
private:
+ void cleanupTestData();
+
QString testDataDir;
bool notEnoughDataForFastSender;
};
@@ -1499,6 +1500,8 @@ void tst_QNetworkReply::initTestCase()
echoProcessDir = QFINDTESTDATA("echo");
QVERIFY2(!echoProcessDir.isEmpty(), qPrintable(
QString::fromLatin1("Couldn't find echo dir starting from %1.").arg(QDir::currentPath())));
+
+ cleanupTestData();
}
void tst_QNetworkReply::cleanupTestCase()
@@ -1514,12 +1517,7 @@ void tst_QNetworkReply::cleanupTestCase()
#endif
}
-void tst_QNetworkReply::init()
-{
- cleanup();
-}
-
-void tst_QNetworkReply::cleanup()
+void tst_QNetworkReply::cleanupTestData()
{
QFile file(testFileName);
QVERIFY(!file.exists() || file.remove());
diff --git a/tests/auto/tools/qmake/testdata/.gitignore b/tests/auto/tools/qmake/testdata/.gitignore
new file mode 100644
index 0000000000..1e997b287b
--- /dev/null
+++ b/tests/auto/tools/qmake/testdata/.gitignore
@@ -0,0 +1,5 @@
+# Created by various tests, even for shadow builds:
+/pro_file_cache/include.pri
+/quotedfilenames/cpp folder/
+/quotedfilenames/quotedfilenames
+/resources/resources