Avoid namespacing QTEST_MAIN
authorRainer Keller <rainer.keller@theqtcompany.com>
Fri, 8 May 2015 07:18:03 +0000 (09:18 +0200)
committerRainer Keller <rainer.keller@theqtcompany.com>
Fri, 8 May 2015 10:09:29 +0000 (10:09 +0000)
The test tries to be smart but it won't work once GPU blacklists are
supported because QTEST_MAIN will contain some imports that cannot be
namespaced.

Change-Id: Id0538cf1ba3885736d8b177e64064bd06f8fef2e
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler.pro
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/data/test.qml [moved from tests/auto/qml/debugger/qqmldebuggingenabler/data/test.qml with 100% similarity]
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro [new file with mode: 0644]
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp [moved from tests/auto/qml/debugger/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp with 85% similarity]
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp [new file with mode: 0644]
tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro [new file with mode: 0644]

index eb41f75..4bcbc2a 100644 (file)
@@ -1,13 +1,4 @@
-CONFIG += testcase
-TARGET = tst_qqmldebuggingenabler
-QT += qml testlib gui-private core-private
-osx:CONFIG -= app_bundle
+TEMPLATE = subdirs
+SUBDIRS = qqmldebuggingenabler qqmldebuggingenablerserver
 
-SOURCES +=     tst_qqmldebuggingenabler.cpp
-
-INCLUDEPATH += ../shared
-include(../../../shared/util.pri)
-include(../shared/debugutil.pri)
-
-OTHER_FILES += data/test.qml
-DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING
+qqmldebuggingenabler.depends = qqmldebuggingenablerserver
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro
new file mode 100644 (file)
index 0000000..f8014f0
--- /dev/null
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qqmldebuggingenabler
+QT += qml testlib gui-private core-private
+CONFIG -= debug_and_release_target
+osx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmldebuggingenabler.cpp
+
+INCLUDEPATH += ../../shared
+include(../../../../shared/util.pri)
+include(../../shared/debugutil.pri)
+
+OTHER_FILES += data/test.qml
@@ -92,7 +92,7 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom,
         process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this);
         process->setMaximumBindErrors(1);
     } else {
-        process = new QQmlDebugProcess(QCoreApplication::applicationFilePath(), this);
+        process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebuggingenablerserver"), this);
         process->setMaximumBindErrors(portTo - portFrom);
     }
 
@@ -103,7 +103,6 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom,
                        testFile(QLatin1String("test.qml")));
     } else {
         QStringList args;
-        args << QLatin1String("-server");
         if (blockMode)
             args << QLatin1String("-block");
         args << QString::number(portFrom) << QString::number(portTo);
@@ -163,27 +162,7 @@ void tst_QQmlDebuggingEnabler::customBlock()
     QVERIFY(init(true, false, 5555, 5565));
 }
 
-namespace QQmlDebuggingEnablerTest {
-    QTEST_MAIN(tst_QQmlDebuggingEnabler)
-}
-
-int main(int argc, char *argv[])
-{
-    if (argc > 1 && QLatin1String(argv[1]) == QLatin1String("-server")) {
-        int one = 1;
-        QCoreApplication app(one, argv);
-        bool block = argc > 2 && QLatin1String(argv[2]) == QLatin1String("-block");
-        int portFrom = QString(QLatin1String(argv[argc - 2])).toInt();
-        int portTo = QString(QLatin1String(argv[argc - 1])).toInt();
-        while (portFrom <= portTo)
-            QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block);
-        QQmlEngine engine;
-        Q_UNUSED(engine);
-        app.exec();
-    } else {
-        QQmlDebuggingEnablerTest::main(argc, argv);
-    }
-}
+QTEST_MAIN(tst_QQmlDebuggingEnabler)
 
 #include "tst_qqmldebuggingenabler.moc"
 
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.cpp
new file mode 100644 (file)
index 0000000..6827941
--- /dev/null
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "debugutil_p.h"
+#include <QtCore/QCoreApplication>
+
+int main(int argc, char *argv[])
+{
+      bool block = false;
+      int portFrom = 0;
+      int portTo = 0;
+
+      QCoreApplication app(argc, argv);
+      QStringList arguments = app.arguments();
+      arguments.removeFirst();
+
+      if (arguments.size() && arguments.first() == QLatin1String("-block")) {
+          block = true;
+          arguments.removeFirst();
+      }
+
+      if (arguments.size() >= 2) {
+          portFrom = arguments.takeFirst().toInt();
+          portTo = arguments.takeFirst().toInt();
+      }
+
+      if (!portFrom || !portTo)
+          qFatal("Port range has to be specified.");
+
+      while (portFrom <= portTo)
+          QQmlDebuggingEnabler::startTcpDebugServer(portFrom++, block);
+      QQmlEngine engine;
+      Q_UNUSED(engine);
+      return app.exec();
+}
+
diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenablerserver/qqmldebuggingenablerserver.pro
new file mode 100644 (file)
index 0000000..fdd9ce8
--- /dev/null
@@ -0,0 +1,11 @@
+QT += qml testlib
+osx:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+INCLUDEPATH += ../../shared
+SOURCES += qqmldebuggingenablerserver.cpp
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING
+
+DESTDIR = ../qqmldebuggingenabler
+
+target.path = $$[QT_INSTALL_TESTS]/tst_qqmldebuggingenabler
+INSTALLS += target