From 36cbf6a62aec4de253e935291bdd33370e7b7faa Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 10 Aug 2015 15:13:09 +0200 Subject: Properly test services arguments for QQmlDebugServer So far we have only tested that each service is still functional when the services: argument is given on the command line. This test checks that services which aren't specified are indeed not loaded. Change-Id: Ica935da0337b2215898f65cf283d6e11365432a8 Reviewed-by: Simon Hausmann --- .../qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 6 +++++ .../qqmlenginecontrol/tst_qqmlenginecontrol.cpp | 5 ++++ .../tst_qqmlenginedebuginspectorintegration.cpp | 5 ++++ .../tst_qqmlenginedebugservice.cpp | 4 ++++ .../debugger/qqmlinspector/tst_qqmlinspector.cpp | 5 ++++ .../tst_qqmlprofilerservice.cpp | 6 +++++ tests/auto/qml/debugger/shared/qqmldebugclient.cpp | 28 +++++++++++++++++++++- tests/auto/qml/debugger/shared/qqmldebugclient.h | 2 ++ 8 files changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index 7dbe35807d..c22adbcc36 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -831,6 +831,7 @@ void tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode, bool restrict connection = new QQmlDebugConnection(); process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); client = new QJSDebugClient(connection); + QList others = connection->createOtherClients(); const char *args = 0; if (blockMode) @@ -849,6 +850,11 @@ void tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode, bool restrict if (client->state() != QQmlDebugClient::Enabled) QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(enabled()))); + + foreach (QQmlDebugClient *otherClient, others) + QCOMPARE(otherClient->state(), restrictServices ? QQmlDebugClient::Unavailable : + QQmlDebugClient::Enabled); + qDeleteAll(others); } void tst_QQmlDebugJS::cleanup() diff --git a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp index 11fa56d710..6c21ba27d7 100644 --- a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp +++ b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp @@ -167,11 +167,16 @@ void tst_QQmlEngineControl::connect(const QString &testFile, bool restrictServic m_connection = new QQmlDebugConnection(); m_client = new QQmlEngineControlClient(m_connection); + QList others = m_connection->createOtherClients(); const int port = m_process->debugPort(); m_connection->connectToHost(QLatin1String("127.0.0.1"), port); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + foreach (QQmlDebugClient *other, others) + QCOMPARE(other->state(), restrictServices ? QQmlDebugClient::Unavailable : + QQmlDebugClient::Enabled); + qDeleteAll(others); } void tst_QQmlEngineControl::cleanup() diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index 0285bae189..adf46c8dab 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -111,9 +111,14 @@ void tst_QQmlEngineDebugInspectorIntegration::init(bool restrictServices) QQmlDebugConnection *m_connection = new QQmlDebugConnection(this); m_inspectorClient = new QQmlInspectorClient(m_connection); m_engineDebugClient = new QQmlEngineDebugClient(m_connection); + QList others = m_connection->createOtherClients(); m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); QVERIFY(m_connection->waitForConnected()); + foreach (QQmlDebugClient *other, others) + QCOMPARE(other->state(), restrictServices ? QQmlDebugClient::Unavailable : + QQmlDebugClient::Enabled); + qDeleteAll(others); } void tst_QQmlEngineDebugInspectorIntegration::cleanup() diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index bc3220ad8c..653af61be5 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -352,7 +352,11 @@ void tst_QQmlEngineDebugService::initTestCase() bool ok = m_conn->waitForConnected(); QVERIFY(ok); m_dbg = new QQmlEngineDebugClient(m_conn); + QList others = m_conn->createOtherClients(); QTRY_COMPARE(m_dbg->state(), QQmlEngineDebugClient::Enabled); + foreach (QQmlDebugClient *other, others) + QCOMPARE(other->state(), QQmlDebugClient::Unavailable); + qDeleteAll(others); } void tst_QQmlEngineDebugService::cleanupTestCase() diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 70833f5e2c..5d3583a5d2 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -91,11 +91,16 @@ void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */, bool re m_connection = new QQmlDebugConnection(); m_client = new QQmlInspectorClient(m_connection); + QList others = m_connection->createOtherClients(); m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + foreach (QQmlDebugClient *other, others) + QCOMPARE(other->state(), restrictServices ? QQmlDebugClient::Unavailable : + QQmlDebugClient::Enabled); + qDeleteAll(others); } void tst_QQmlInspector::cleanup() diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 0e63e18952..17e3260026 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -373,11 +373,17 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile, bool m_connection = new QQmlDebugConnection(); m_client = new QQmlProfilerClient(m_connection); + QList others = m_connection->createOtherClients(); const int port = m_process->debugPort(); m_connection->connectToHost(QLatin1String("127.0.0.1"), port); QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + foreach (QQmlDebugClient *other, others) + QCOMPARE(other->state(), restrictServices ? QQmlDebugClient::Unavailable : + QQmlDebugClient::Enabled); + qDeleteAll(others); } void tst_QQmlProfilerService::checkTraceReceived() diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp index 0f7e572e02..f350614a47 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp @@ -41,6 +41,7 @@ #include #include #include +#include const int protocolVersion = 1; const QString serverId = QLatin1String("QDeclarativeDebugServer"); @@ -70,6 +71,7 @@ public: bool gotHello; QHash serverPlugins; QHash plugins; + QStringList removedPlugins; void advertisePlugins(); void connectDeviceSignals(); @@ -224,7 +226,11 @@ void QQmlDebugConnectionPrivate::readyRead() QHash::Iterator iter = plugins.find(name); if (iter == plugins.end()) { - qWarning() << "QQmlDebugConnection: Message received for missing plugin" << name; + // We can get more messages for plugins we have removed because it takes time to + // send the advertisement message but the removal is instant locally. + if (!removedPlugins.contains(name)) + qWarning() << "QQmlDebugConnection: Message received for missing plugin" + << name; } else { (*iter)->messageReceived(message); } @@ -440,6 +446,7 @@ QQmlDebugClient::QQmlDebugClient(const QString &name, qWarning() << "QQmlDebugClient: Conflicting plugin name" << name; d->connection = 0; } else { + d->connection->d->removedPlugins.removeAll(name); d->connection->d->plugins.insert(name, this); d->connection->d->advertisePlugins(); } @@ -449,6 +456,7 @@ QQmlDebugClient::~QQmlDebugClient() { if (d->connection && d->connection->d) { d->connection->d->plugins.remove(d->name); + d->connection->d->removedPlugins.append(d->name); d->connection->d->advertisePlugins(); } delete d; @@ -500,6 +508,24 @@ void QQmlDebugClient::sendMessage(const QByteArray &message) d->connection->flush(); } +QList QQmlDebugConnection::createOtherClients() +{ + QList ret; + foreach (const QString &service, QQmlDebuggingEnabler::debuggerServices()) { + if (!d->plugins.contains(service)) + ret << new QQmlDebugClient(service, this); + } + foreach (const QString &service, QQmlDebuggingEnabler::inspectorServices()) { + if (!d->plugins.contains(service)) + ret << new QQmlDebugClient(service, this); + } + foreach (const QString &service, QQmlDebuggingEnabler::profilerServices()) { + if (!d->plugins.contains(service)) + ret << new QQmlDebugClient(service, this); + } + return ret; +} + void QQmlDebugClient::stateChanged(State) { } diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h index fe9da693c8..659f7c8631 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.h +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h @@ -36,6 +36,7 @@ #include +class QQmlDebugClient; class QQmlDebugConnectionPrivate; class QQmlDebugConnection : public QIODevice { @@ -60,6 +61,7 @@ public: bool waitForConnected(int msecs = 30000); QString stateString() const; + QList createOtherClients(); signals: void connected(); -- cgit v1.2.3