aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktest.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@digia.com>2012-12-27 09:48:07 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-31 21:13:04 +0100
commit473ec1734751cdea889be9690bde0af6371ec111 (patch)
treea459d28a1d969d447db769abff39461fd2f2ff81 /src/qmltest/quicktest.cpp
parentdaa33ba7b99b3f4ee3ac9a738c85bca36ab0fdd7 (diff)
qmltest: Added the possibility to use QApplication
Current QML test cases in QtDesktopComponents still need to use QApplication. Added QT_QMLTEST_WITH_WIDGETS define when QtWidgets is available. Also proveded a command line switch "-widgets" for it. Change-Id: Ib6c7313538cb8875144636b6f8bd264b0f13aa8d Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/qmltest/quicktest.cpp')
-rw-r--r--src/qmltest/quicktest.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 6be10add38..705908c3c4 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -64,6 +64,10 @@
#include <QtCore/QTranslator>
#include <QtTest/QSignalSpy>
+#ifdef QT_QMLTEST_WITH_WIDGETS
+#include <QtWidgets/QApplication>
+#endif
+
QT_BEGIN_NAMESPACE
class QTestRootObject : public QObject
@@ -167,11 +171,6 @@ bool qWaitForSignal(QObject *obj, const char* signal, int timeout = 5000)
int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir)
{
- QGuiApplication* app = 0;
- if (!QCoreApplication::instance()) {
- app = new QGuiApplication(argc, argv);
- }
-
// Look for QML-specific command-line options.
// -import dir Specify an import directory.
// -input dir Specify the input directory for test cases.
@@ -179,6 +178,9 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
QStringList imports;
QString testPath;
QString translationFile;
+#ifdef QT_QMLTEST_WITH_WIDGETS
+ bool withWidgets = false;
+#endif
int outargc = 1;
int index = 1;
while (index < argc) {
@@ -190,6 +192,11 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
index += 2;
} else if (strcmp(argv[index], "-opengl") == 0) {
++index;
+#ifdef QT_QMLTEST_WITH_WIDGETS
+ } else if (strcmp(argv[index], "-widgets") == 0) {
+ withWidgets = true;
+ ++index;
+#endif
} else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
index += 2;
@@ -203,6 +210,18 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
argv[outargc] = 0;
argc = outargc;
+ QCoreApplication* app = 0;
+ if (!QCoreApplication::instance()) {
+#ifdef QT_QMLTEST_WITH_WIDGETS
+ if (withWidgets)
+ app = new QApplication(argc, argv);
+ else
+#endif
+ {
+ app = new QGuiApplication(argc, argv);
+ }
+ }
+
// Parse the command-line arguments.
// Setting currentAppname and currentTestObjectName (via setProgramName) are needed