summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-09-25 16:28:24 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-01 18:00:17 +0200
commit2c925906f516e7e47db9e82ed8bda1f675ab414a (patch)
tree2889564f0e285dfb91d2232575599864c6abc942 /tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
parent3bcc44268e532209314b87a4dbd418022e0a8d0f (diff)
Base tst_QGuiApplication on tst_QCoreApplication to increase GUI ED coverage
The QCoreApplication test has quite a few test cases that we would like to exercise using the GUI event-dispatcher. Instead of duplicating the tests for the GUI dispatcher, we inherit tst_QCoreApplication, which also lets us add extra tests that are specific to tst_QGuiApplication. Change-Id: Ib411457131b8d3fed871f682c1c0568577f6127d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp')
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp82
1 files changed, 37 insertions, 45 deletions
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"