aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/qqmldebugclient
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-13 16:38:25 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-30 14:55:19 +0000
commit6557b7118897347ccf7c5915c169cf86c818be83 (patch)
treee7e67d77b5255222edbd620bd6ae77ec50052ee4 /tests/auto/qml/debugger/qqmldebugclient
parent52e782bdc56fb3a62b045f2d1ca71f38bc7ef796 (diff)
Make QQmlDebugService::registerService() private and part of ctor
By forcing all debug services to register before the thread starts we can get rid of the complicated thread synchronization and have a more natural API for the services. We can also better enforce the thread situation when registering services in QQmlDebugServer now. QQmlProfilerService should not moveToThread() in its constructor as the thread has not been started, yet. The thread affinity of QQmlProfilerService doesn't make any difference anyway, as all relevant methods are protected by mutexes and it doesn't have any slots. Change-Id: I57db9e2bf94ec6884ede694715dadf5bfd687334 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/debugger/qqmldebugclient')
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp39
1 files changed, 13 insertions, 26 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
index 7a8411c49f..6fc6c6a914 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -42,6 +42,8 @@
#include "debugutil_p.h"
#include "qqmldebugtestservice.h"
+#include <private/qqmldebugconnector_p.h>
+
#define PORT 13770
#define STR_PORT "13770"
@@ -51,6 +53,7 @@ class tst_QQmlDebugClient : public QObject
private:
QQmlDebugConnection *m_conn;
+ QQmlDebugTestService *m_service;
private slots:
void initTestCase();
@@ -64,14 +67,21 @@ private slots:
void tst_QQmlDebugClient::initTestCase()
{
+ QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
+ QTest::ignoreMessage(QtWarningMsg,
+ "QML debugger: Cannot set plugin key after loading the plugin.");
+
+ m_service = new QQmlDebugTestService("tst_QQmlDebugClient::handshake()");
const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
+ QQmlDebuggingEnabler::startTcpDebugServer(PORT);
+
new QQmlEngine(this);
m_conn = new QQmlDebugConnection(this);
QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
- QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
for (int i = 0; i < 50; ++i) {
// try for 5 seconds ...
@@ -105,14 +115,6 @@ void tst_QQmlDebugClient::state()
QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn);
QCOMPARE(client.state(), QQmlDebugClient::Unavailable);
- {
- QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2);
- QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QCOMPARE(client.serviceVersion(), 2.0f);
- }
-
- QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable);
-
// duplicate plugin name
QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\"");
QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn);
@@ -124,8 +126,7 @@ void tst_QQmlDebugClient::state()
void tst_QQmlDebugClient::sendMessage()
{
- QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()");
- QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
QByteArray msg = "hello!";
@@ -151,7 +152,6 @@ void tst_QQmlDebugClient::sequentialConnect()
{
QQmlDebugConnection connection2;
QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2);
- QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
m_conn->close();
QVERIFY(!m_conn->isConnected());
@@ -166,20 +166,7 @@ void tst_QQmlDebugClient::sequentialConnect()
QTRY_COMPARE(client2.state(), QQmlDebugClient::Enabled);
}
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QQmlDebugClient tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
+QTEST_MAIN(tst_QQmlDebugClient)
#include "tst_qqmldebugclient.moc"