summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-10-09 15:50:11 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-09 15:50:11 +0200
commitda0cb32b8ee7cc4a991a59420a411898e63a660e (patch)
tree9ed8e190a6543518f9b082afc5a380f659da0220 /tests
parent7f3e3c1099f42cff46bbd267c70587bcf72024fc (diff)
parentd8fc0da235b2bd566b2b6f1e21218afdf2f34eb3 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp108
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp13
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro1
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp82
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h73
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp30
-rw-r--r--tests/auto/gui/kernel/qguiapplication/qguiapplication.pro11
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp4
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp28
-rw-r--r--tests/auto/other/lancelot/tst_lancelot.cpp4
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp63
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp11
12 files changed, 267 insertions, 161 deletions
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index d9292b8460..04c083e653 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -56,6 +56,29 @@
# include <windows.h>
#endif
+// Restore permissions so that the QTemporaryDir cleanup can happen
+class PermissionRestorer
+{
+ Q_DISABLE_COPY(PermissionRestorer)
+public:
+ explicit PermissionRestorer(const QString& path) : m_path(path) {}
+ ~PermissionRestorer() { restore(); }
+
+ inline void restore()
+ {
+ QFile file(m_path);
+#ifdef Q_OS_UNIX
+ file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner));
+#else
+ file.setPermissions(QFile::WriteOwner);
+ file.remove();
+#endif
+ }
+
+private:
+ const QString m_path;
+};
+
class tst_QSaveFile : public QObject
{
Q_OBJECT
@@ -73,13 +96,21 @@ private slots:
void transactionalWriteErrorRenaming();
};
+static inline QByteArray msgCannotOpen(const QFileDevice &f)
+{
+ QString result = QStringLiteral("Cannot open ") + QDir::toNativeSeparators(f.fileName())
+ + QStringLiteral(": ") + f.errorString();
+ return result.toLocal8Bit();
+}
+
void tst_QSaveFile::transactionalWrite()
{
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile::remove(targetFile);
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QVERIFY(file.isOpen());
QCOMPARE(file.fileName(), targetFile);
QVERIFY(!QFile::exists(targetFile));
@@ -102,27 +133,29 @@ void tst_QSaveFile::saveTwice()
// Check that we can reuse a QSaveFile object
// (and test the case of an existing target file)
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE(file.write("Hello"), Q_INT64_C(5));
QVERIFY2(file.commit(), qPrintable(file.errorString()));
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE(file.write("World"), Q_INT64_C(5));
QVERIFY2(file.commit(), qPrintable(file.errorString()));
QFile reader(targetFile);
- QVERIFY(reader.open(QIODevice::ReadOnly));
+ QVERIFY2(reader.open(QIODevice::ReadOnly), msgCannotOpen(reader).constData());
QCOMPARE(QString::fromLatin1(reader.readAll()), QString::fromLatin1("World"));
}
void tst_QSaveFile::textStreamManualFlush()
{
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QTextStream ts(&file);
ts << "Manual flush";
@@ -140,9 +173,10 @@ void tst_QSaveFile::textStreamManualFlush()
void tst_QSaveFile::textStreamAutoFlush()
{
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QTextStream ts(&file);
ts << "Auto-flush.";
@@ -166,28 +200,8 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
{
#ifdef Q_OS_UNIX
QFETCH(bool, directWriteFallback);
- // Restore permissions so that the QTemporaryDir cleanup can happen
- class PermissionRestorer
- {
- QString m_path;
- public:
- PermissionRestorer(const QString& path)
- : m_path(path)
- {}
-
- ~PermissionRestorer()
- {
- restore();
- }
- void restore()
- {
- QFile file(m_path);
- file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner));
- }
- };
-
-
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
QVERIFY(QFile(dir.path()).setPermissions(QFile::ReadOwner | QFile::ExeOwner));
PermissionRestorer permissionRestorer(dir.path());
@@ -212,7 +226,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
file.setDirectWriteFallback(directWriteFallback);
QCOMPARE(file.directWriteFallback(), directWriteFallback);
if (directWriteFallback) {
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE((int)file.error(), (int)QFile::NoError);
QCOMPARE(file.write("World"), Q_INT64_C(5));
QVERIFY(file.commit());
@@ -222,7 +236,7 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnDir()
QCOMPARE(QString::fromLatin1(reader.readAll()), QString::fromLatin1("World"));
reader.close();
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE((int)file.error(), (int)QFile::NoError);
QCOMPARE(file.write("W"), Q_INT64_C(1));
file.cancelWriting(); // no effect, as per the documentation
@@ -241,9 +255,11 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile()
{
// Setup an existing but readonly file
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ PermissionRestorer permissionRestorer(targetFile);
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE(file.write("Hello"), Q_INT64_C(5));
file.close();
file.setPermissions(QFile::ReadOwner);
@@ -260,10 +276,11 @@ void tst_QSaveFile::transactionalWriteNoPermissionsOnFile()
void tst_QSaveFile::transactionalWriteCanceled()
{
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QFile::remove(targetFile);
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QTextStream ts(&file);
ts << "This writing operation will soon be canceled.\n";
@@ -283,35 +300,12 @@ void tst_QSaveFile::transactionalWriteCanceled()
void tst_QSaveFile::transactionalWriteErrorRenaming()
{
QTemporaryDir dir;
+ QVERIFY(dir.isValid());
const QString targetFile = dir.path() + QString::fromLatin1("/outfile");
QSaveFile file(targetFile);
- QVERIFY(file.open(QIODevice::WriteOnly));
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
QCOMPARE(file.write("Hello"), qint64(5));
QVERIFY(!QFile::exists(targetFile));
-
- // Restore permissions so that the QTemporaryDir cleanup can happen
- class PermissionRestorer
- {
- public:
- PermissionRestorer(const QString& path)
- : m_path(path)
- {}
-
- ~PermissionRestorer()
- {
- QFile file(m_path);
-#ifdef Q_OS_UNIX
- file.setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner));
-#else
- file.setPermissions(QFile::WriteOwner);
- file.remove();
-#endif
- }
-
- private:
- QString m_path;
- };
-
#ifdef Q_OS_UNIX
// Make rename() fail for lack of permissions in the directory
QFile dirAsFile(dir.path()); // yay, I have to use QFile to change a dir's permissions...
@@ -320,7 +314,7 @@ void tst_QSaveFile::transactionalWriteErrorRenaming()
#else
// Windows: Make rename() fail for lack of permissions on an existing target file
QFile existingTargetFile(targetFile);
- QVERIFY(existingTargetFile.open(QIODevice::WriteOnly));
+ QVERIFY2(existingTargetFile.open(QIODevice::WriteOnly), msgCannotOpen(existingTargetFile).constData());
QCOMPARE(file.write("Target"), qint64(6));
existingTargetFile.close();
QVERIFY(existingTargetFile.setPermissions(QFile::ReadOwner));
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index b63dbc449c..9ac1526f07 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -308,13 +308,16 @@ void tst_qstandardpaths::testDataLocation()
#ifndef Q_OS_WIN
// Find "sh" on Unix.
+// It may exist twice, in /bin/sh and /usr/bin/sh, in that case use the PATH order.
static inline QFileInfo findSh()
{
- const char *shPaths[] = {"/bin/sh", "/usr/bin/sh", 0};
- for (const char **shPath = shPaths; *shPath; ++shPath) {
- const QFileInfo fi = QFileInfo(QLatin1String(*shPath));
- if (fi.exists())
- return fi;
+ QLatin1String sh("/sh");
+ QByteArray pEnv = qgetenv("PATH");
+ const QLatin1Char pathSep(':');
+ const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
+ foreach (const QString &path, rawPaths) {
+ if (QFile::exists(path + sh))
+ return path + sh;
}
return QFileInfo();
}
diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
index 14df20c986..0602b9fc38 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
+++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro
@@ -2,3 +2,4 @@ CONFIG += testcase parallel_test
TARGET = tst_qcoreapplication
QT = core testlib core-private
SOURCES = tst_qcoreapplication.cpp
+HEADERS = tst_qcoreapplication.h
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index 78f2cdae69..760303a027 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+#include "tst_qcoreapplication.h"
+
#include <QtCore/QtCore>
#include <QtTest/QtTest>
@@ -46,31 +48,12 @@
#include <private/qeventloop_p.h>
#include <private/qthread_p.h>
-class tst_QCoreApplication: public QObject
-{
- Q_OBJECT
-private slots:
- void sendEventsOnProcessEvents(); // this must be the first test
- void getSetCheck();
- void qAppName();
-#ifndef Q_OS_WIN
- void argc();
-#endif
- void postEvent();
- void removePostedEvents();
-#ifndef QT_NO_THREAD
- void deliverInDefinedOrder();
+#ifdef QT_GUI_LIB
+#include <QtGui/QGuiApplication>
+typedef QGuiApplication TestApplication;
+#else
+typedef QCoreApplication TestApplication;
#endif
- void applicationPid();
- void globalPostedEventsCount();
- void processEventsAlwaysSendsPostedEvents();
- void reexec();
- void execAfterExit();
- void eventLoopExecAfterExit();
- void customEventDispatcher();
- void testQuitLock();
- void QTBUG31606_QEventDestructorDeadLock();
-};
class EventSpy : public QObject
{
@@ -89,7 +72,7 @@ void tst_QCoreApplication::sendEventsOnProcessEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
EventSpy spy;
app.installEventFilter(&spy);
@@ -111,7 +94,7 @@ void tst_QCoreApplication::getSetCheck()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCOMPARE(app.property("applicationVersion").toString(), v);
}
v = QString();
@@ -121,11 +104,17 @@ void tst_QCoreApplication::getSetCheck()
void tst_QCoreApplication::qAppName()
{
+#ifdef QT_GUI_LIB
+ const char* appName = "tst_qguiapplication";
+#else
+ const char* appName = "tst_qcoreapplication";
+#endif
+
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
- QCoreApplication app(argc, argv);
- QCOMPARE(::qAppName(), QString::fromLatin1("tst_qcoreapplication"));
- QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1("tst_qcoreapplication"));
+ char *argv[] = { const_cast<char*>(appName) };
+ TestApplication app(argc, argv);
+ QCOMPARE(::qAppName(), QString::fromLatin1(appName));
+ QCOMPARE(QCoreApplication::applicationName(), QString::fromLatin1(appName));
}
// "QCoreApplication::arguments() always parses arguments from actual command line on Windows
@@ -136,7 +125,7 @@ void tst_QCoreApplication::argc()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.arguments().count(), 1);
}
@@ -147,7 +136,7 @@ void tst_QCoreApplication::argc()
const_cast<char*>("arg1"),
const_cast<char*>("arg2"),
const_cast<char*>("arg3") };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCOMPARE(argc, 4);
QCOMPARE(app.arguments().count(), 4);
}
@@ -155,7 +144,7 @@ void tst_QCoreApplication::argc()
{
int argc = 0;
char **argv = 0;
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCOMPARE(argc, 0);
QCOMPARE(app.arguments().count(), 0);
}
@@ -164,7 +153,7 @@ void tst_QCoreApplication::argc()
int argc = 2;
char *argv[] = { const_cast<char*>(QTest::currentAppName()),
const_cast<char*>("-qmljsdebugger=port:3768,block") };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.arguments().count(), 1);
}
@@ -197,7 +186,7 @@ void tst_QCoreApplication::postEvent()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
EventSpy spy;
EventGenerator odd, even;
@@ -282,7 +271,7 @@ void tst_QCoreApplication::removePostedEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
EventSpy spy;
QObject one, two;
@@ -461,7 +450,7 @@ void tst_QCoreApplication::deliverInDefinedOrder()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
DeliverInDefinedOrderObject obj(&app);
// causes sendPostedEvents() to recurse twice
@@ -501,7 +490,7 @@ void tst_QCoreApplication::globalPostedEventsCount()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QCoreApplication::sendPostedEvents();
QCOMPARE(qGlobalPostedEventsCount(), 0u);
@@ -547,7 +536,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
ProcessEventsAlwaysSendsPostedEventsObject object;
QTime t;
@@ -565,7 +554,7 @@ void tst_QCoreApplication::reexec()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
// exec once
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
@@ -580,7 +569,7 @@ void tst_QCoreApplication::execAfterExit()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
app.exit(1);
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
@@ -591,7 +580,7 @@ void tst_QCoreApplication::eventLoopExecAfterExit()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
// exec once and exit
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
@@ -649,7 +638,7 @@ void tst_QCoreApplication::customEventDispatcher()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
// instantiating app should not overwrite the ED
QCOMPARE(QCoreApplication::eventDispatcher(), ed);
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
@@ -764,7 +753,7 @@ void tst_QCoreApplication::testQuitLock()
{
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
QuitTester tester;
app.exec();
@@ -783,7 +772,7 @@ void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock()
int argc = 1;
char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
- QCoreApplication app(argc, argv);
+ TestApplication app(argc, argv);
EventSpy spy;
app.installEventFilter(&spy);
@@ -810,5 +799,8 @@ static void createQObjectOnDestruction()
}
Q_DESTRUCTOR_FUNCTION(createQObjectOnDestruction)
+#ifndef QT_GUI_LIB
QTEST_APPLESS_MAIN(tst_QCoreApplication)
+#endif
+
#include "tst_qcoreapplication.moc"
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
new file mode 100644
index 0000000000..16ade27f83
--- /dev/null
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TST_QCOREAPPLICATION_H
+#define TST_QCOREAPPLICATION_H
+
+#include <QtCore/QtCore>
+
+class tst_QCoreApplication: public QObject
+{
+ Q_OBJECT
+private slots:
+ void sendEventsOnProcessEvents(); // this must be the first test
+ void getSetCheck();
+ void qAppName();
+#ifndef Q_OS_WIN
+ void argc();
+#endif
+ void postEvent();
+ void removePostedEvents();
+#ifndef QT_NO_THREAD
+ void deliverInDefinedOrder();
+#endif
+ void applicationPid();
+ void globalPostedEventsCount();
+ void processEventsAlwaysSendsPostedEvents();
+ void reexec();
+ void execAfterExit();
+ void eventLoopExecAfterExit();
+ void customEventDispatcher();
+ void testQuitLock();
+ void QTBUG31606_QEventDestructorDeadLock();
+};
+
+#endif // TST_QCOREAPPLICATION_H
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 039f5cbc44..ffc4baa55d 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -2387,8 +2387,6 @@ void tst_QDateTime::daylightTransitions() const
// 2011-10-30 03:00:00 CEST became 02:00:00 CET at msecs = 1319936400000
// 2012-03-25 02:00:00 CET became 03:00:00 CEST at msecs = 1332637200000
// 2012-10-28 03:00:00 CEST became 02:00:00 CET at msecs = 1351386000000
- const qint64 daylight2011 = 1301187600000;
- const qint64 standard2011 = 1319936400000;
const qint64 daylight2012 = 1332637200000;
const qint64 standard2012 = 1351386000000;
const qint64 msecsOneHour = 3600000;
@@ -2538,10 +2536,6 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(hourBefore.isValid());
QCOMPARE(hourBefore.date(), QDate(2012, 10, 28));
QCOMPARE(hourBefore.time(), QTime(2, 0, 0));
-#ifndef Q_OS_MAC
- // Linux mktime bug uses last calculation
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
QCOMPARE(hourBefore.toMSecsSinceEpoch(), standard2012 - msecsOneHour);
// 1 msec before transition is 2:59:59.999 FirstOccurrence
@@ -2549,7 +2543,6 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(msecBefore.isValid());
QCOMPARE(msecBefore.date(), QDate(2012, 10, 28));
QCOMPARE(msecBefore.time(), QTime(2, 59, 59, 999));
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(msecBefore.toMSecsSinceEpoch(), standard2012 - 1);
// At transition is 2:00:00 SecondOccurrence
@@ -2557,10 +2550,6 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(atTran.isValid());
QCOMPARE(atTran.date(), QDate(2012, 10, 28));
QCOMPARE(atTran.time(), QTime(2, 0, 0));
-#ifdef Q_OS_MAC
- // Mac defaults to FirstOccurrence here
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
QCOMPARE(atTran.toMSecsSinceEpoch(), standard2012);
// 59:59.999 after transition is 2:59:59.999 SecondOccurrence
@@ -2711,10 +2700,6 @@ void tst_QDateTime::daylightTransitions() const
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
QCOMPARE(test.time(), QTime(2, 0, 0));
-#ifdef Q_OS_WIN
- // Windows uses SecondOccurrence
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012 - msecsOneHour);
// Add hour to tran FirstOccurrence to get to tran SecondOccurrence
@@ -2727,11 +2712,10 @@ void tst_QDateTime::daylightTransitions() const
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_WIN
QCOMPARE(test.time(), QTime(2, 0, 0));
-#ifndef Q_OS_MAC
+#ifdef Q_OS_WIN
// Windows uses SecondOccurrence
- // Linux mktime bug uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
-#endif // Q_OS_MAC
+#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012);
// Add hour to tran SecondOccurrence to get to after tran FirstOccurrence
@@ -2739,15 +2723,13 @@ void tst_QDateTime::daylightTransitions() const
test = test.addMSecs(msecsOneHour);
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 10, 28));
-#ifndef Q_OS_WIN
- // Mac uses FirstOccurrence
- // Linux mktime bug uses last calculation
+#ifdef Q_OS_MAC
+ // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_WIN
QCOMPARE(test.time(), QTime(3, 0, 0));
-#ifndef Q_OS_WIN
- // Mac uses FirstOccurrence
- // Linux mktime bug uses last calculation
+#ifdef Q_OS_MAC
+ // Mac uses FirstOccurrence, Windows uses SecondOccurrence, Linux uses last calculation
QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
#endif // Q_OS_WIN
QCOMPARE(test.toMSecsSinceEpoch(), standard2012 + msecsOneHour);
diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
index a9baf29996..79acb9e5f1 100644
--- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
+++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro
@@ -1,4 +1,9 @@
-CONFIG += testcase
+CORE_TEST_PATH = ../../../corelib/kernel/qcoreapplication
+
+VPATH += $$CORE_TEST_PATH
+include($${CORE_TEST_PATH}/qcoreapplication.pro)
+INCLUDEPATH += $$CORE_TEST_PATH
+
TARGET = tst_qguiapplication
-QT += core gui gui-private testlib
-SOURCES = tst_qguiapplication.cpp
+QT += gui gui-private
+SOURCES += tst_qguiapplication.cpp
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index 7884426d68..d4237b135f 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
@@ -50,9 +50,11 @@
#include <QDebug>
+#include "tst_qcoreapplication.h"
+
enum { spacing = 50, windowSize = 200 };
-class tst_QGuiApplication: public QObject
+class tst_QGuiApplication: public tst_QCoreApplication
{
Q_OBJECT
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 97f3ec128d..4defbe181f 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -171,8 +171,8 @@ void tst_QOpenGL::sharedResourceCleanup()
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext *ctx = new QOpenGLContext;
- ctx->create();
- ctx->makeCurrent(surface.data());
+ QVERIFY(ctx->create());
+ QVERIFY(ctx->makeCurrent(surface.data()));
SharedResourceTracker tracker;
SharedResource *resource = new SharedResource(&tracker);
@@ -188,7 +188,7 @@ void tst_QOpenGL::sharedResourceCleanup()
QOpenGLContext *ctx2 = new QOpenGLContext;
ctx2->setShareContext(ctx);
- ctx2->create();
+ QVERIFY(ctx2->create());
delete ctx;
@@ -238,7 +238,7 @@ void tst_QOpenGL::multiGroupSharedResourceCleanup()
for (int i = 0; i < 10; ++i) {
QOpenGLContext *gl = new QOpenGLContext();
- gl->create();
+ QVERIFY(gl->create());
gl->makeCurrent(surface.data());
{
// Cause QOpenGLMultiGroupSharedResource instantiation.
@@ -262,8 +262,8 @@ void tst_QOpenGL::multiGroupSharedResourceCleanupCustom()
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext *ctx = new QOpenGLContext();
- ctx->create();
- ctx->makeCurrent(surface.data());
+ QVERIFY(ctx->create());
+ QVERIFY(ctx->makeCurrent(surface.data()));
QOpenGLMultiGroupSharedResource multiGroupSharedResource;
SharedResource *resource = multiGroupSharedResource.value<SharedResource>(ctx);
@@ -401,7 +401,7 @@ void tst_QOpenGL::fboSimpleRendering()
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
- ctx.create();
+ QVERIFY(ctx.create());
ctx.makeCurrent(surface.data());
@@ -449,7 +449,7 @@ void tst_QOpenGL::fboRendering()
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
- ctx.create();
+ QVERIFY(ctx.create());
ctx.makeCurrent(surface.data());
@@ -493,7 +493,7 @@ void tst_QOpenGL::fboHandleNulledAfterContextDestroyed()
{
QOpenGLContext ctx;
- ctx.create();
+ QVERIFY(ctx.create());
ctx.makeCurrent(&window);
@@ -523,7 +523,7 @@ void tst_QOpenGL::openGLPaintDevice()
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
- ctx.create();
+ QVERIFY(ctx.create());
QSurfaceFormat format = ctx.format();
if (format.majorVersion() < 2)
@@ -576,8 +576,8 @@ void tst_QOpenGL::aboutToBeDestroyed()
QOpenGLContext *context = new QOpenGLContext;
QSignalSpy spy(context, SIGNAL(aboutToBeDestroyed()));
- context->create();
- context->makeCurrent(&window);
+ QVERIFY(context->create());
+ QVERIFY(context->makeCurrent(&window));
QCOMPARE(spy.size(), 0);
@@ -598,8 +598,8 @@ void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero()
window.create();
QOpenGLContext ctx;
- ctx.create();
- ctx.makeCurrent(&window);
+ QVERIFY(ctx.create());
+ QVERIFY(ctx.makeCurrent(&window));
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp
index fff8884d67..a99b041bfc 100644
--- a/tests/auto/other/lancelot/tst_lancelot.cpp
+++ b/tests/auto/other/lancelot/tst_lancelot.cpp
@@ -228,8 +228,8 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format)
fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
fmt.setSamples(4);
QOpenGLContext ctx;
- ctx.create();
- ctx.makeCurrent(&win);
+ QVERIFY(ctx.create());
+ QVERIFY(ctx.makeCurrent(&win));
QOpenGLFramebufferObject fbo(800, 800, fmt);
fbo.bind();
QOpenGLPaintDevice pdv(800, 800);
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 0a705949f3..092995c0aa 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -3181,11 +3181,16 @@ void tst_QAccessibility::comboBoxTest()
void tst_QAccessibility::labelTest()
{
+ QWidget *window = new QWidget;
QString text = "Hello World";
- QLabel *label = new QLabel(text);
+ QLabel *label = new QLabel(text, window);
setFrameless(label);
- label->show();
+ QLineEdit *buddy = new QLineEdit(window);
+ label->setBuddy(buddy);
+ window->resize(320, 200);
+ window->show();
+ QTest::qWaitForWindowExposed(window);
#if defined(Q_OS_UNIX)
QCoreApplication::processEvents();
#endif
@@ -3196,7 +3201,15 @@ void tst_QAccessibility::labelTest()
QCOMPARE(acc_label->text(QAccessible::Name), text);
- delete label;
+ QVector<QPair<QAccessibleInterface *, QAccessible::Relation> > rels = acc_label->relations();
+ QCOMPARE(rels.count(), 1);
+ QAccessibleInterface *iface = rels.first().first;
+ QAccessible::Relation rel = rels.first().second;
+
+ QCOMPARE(rel, QAccessible::Labelled);
+ QCOMPARE(iface->role(), QAccessible::EditableText);
+
+ delete window;
QTestAccessibility::clearEvents();
QPixmap testPixmap(50, 50);
@@ -3313,9 +3326,13 @@ void tst_QAccessibility::bridgeTest()
tableWidget->setFixedSize(600, 600);
+ QLabel *label = new QLabel(tr("Push my buddy"));
+ label->setBuddy(button);
+
lay->addWidget(button);
lay->addWidget(te);
lay->addWidget(tableWidget);
+ lay->addWidget(label);
window->show();
QVERIFY(QTest::qWaitForWindowExposed(window));
@@ -3387,9 +3404,47 @@ void tst_QAccessibility::bridgeTest()
BSTR actionName;
ia2Action->get_name(0, &actionName);
QString name((QChar*)actionName);
+ ::SysFreeString(actionName);
QCOMPARE(name, QAccessibleActionInterface::pressAction());
ia2Action->Release();
+ /***** Test IAccessibleRelation *****/
+ long nRelations = 0;
+ hr = ia2Button->get_nRelations(&nRelations);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(nRelations, (long)1);
+
+ IAccessibleRelation **relations = (IAccessibleRelation **)::CoTaskMemAlloc(sizeof(IAccessibleRelation *) * 4);
+ hr = ia2Button->get_relations(4, relations, &nRelations);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(nRelations, (long)1);
+
+ IAccessibleRelation *relation = relations[0];
+ BSTR relType;
+ hr = relation->get_relationType(&relType);
+ QCOMPARE(QString::fromWCharArray(relType), QLatin1String("labelFor"));
+ ::SysFreeString(relType);
+
+ long nTargets;
+ relation->get_nTargets(&nTargets);
+ QCOMPARE(nTargets, (long)1);
+ IAccessible *target; // target is the label
+ hr = relation->get_target(0, (IUnknown**)&target);
+ QVERIFY(SUCCEEDED(hr));
+
+ VARIANT varRole;
+ hr = target->get_accRole(varSELF, &varRole);
+ QVERIFY(SUCCEEDED(hr));
+ Q_ASSERT(varRole.vt == (VARTYPE)VT_I4);
+ QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_STATICTEXT);
+
+ BSTR buttonName;
+ hr = target->get_accName(varSELF, &buttonName);
+ QVERIFY(SUCCEEDED(hr));
+
+ QCOMPARE(QString::fromWCharArray(buttonName), QLatin1String("Push my buddy"));
+ ::SysFreeString(buttonName);
+ ::CoTaskMemFree(relations);
// Done testing
ia2Button->Release();
@@ -3416,7 +3471,7 @@ void tst_QAccessibility::bridgeTest()
long nChildren;
hr = iaccWindow->get_accChildCount(&nChildren);
QVERIFY(SUCCEEDED(hr));
- QCOMPARE(nChildren, (long)3);
+ QCOMPARE(nChildren, (long)4);
/**************************************************
* QTextEdit
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 98b096031e..b9e6c82d84 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -1199,10 +1199,9 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
{
QString tempPath = tempDir.path();
- QTemporaryFile *t;
- t = new QTemporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX");
- t->open();
- QNonNativeFileDialog fd(0, "TestFileDialog", t->fileName());
+ QTemporaryFile temporaryFile(tempPath + "/tst_qfiledialog2_lineEditSelectAll.XXXXXX");
+ QVERIFY(temporaryFile.open());
+ QNonNativeFileDialog fd(0, "TestFileDialog", temporaryFile.fileName());
fd.setDirectory(tempPath);
fd.setViewMode(QFileDialog::List);
@@ -1218,8 +1217,8 @@ void tst_QFileDialog2::QTBUG4419_lineEditSelectAll()
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit);
- QTRY_COMPARE(tempPath + QChar('/') + lineEdit->text(), t->fileName());
- QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), t->fileName());
+ QTRY_COMPARE(tempPath + QChar('/') + lineEdit->text(), temporaryFile.fileName());
+ QCOMPARE(tempPath + QChar('/') + lineEdit->selectedText(), temporaryFile.fileName());
}
void tst_QFileDialog2::QTBUG6558_showDirsOnly()