Allow specification of loadable debug services via command line
authorUlf Hermann <ulf.hermann@theqtcompany.com>
Wed, 5 Aug 2015 15:27:08 +0000 (17:27 +0200)
committerUlf Hermann <ulf.hermann@theqtcompany.com>
Thu, 13 Aug 2015 08:30:47 +0000 (08:30 +0000)
We don't want to load the debugger when profiling and vice versa. This
makes it easier to prevent unwanted services from getting loaded.

Task-number: QTBUG-47623
Change-Id: I28893b6218110274a6d30b27805d89dbb443add3
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
src/qml/debugger/qqmldebugconnector.cpp
src/qml/debugger/qqmldebugconnector_p.h
tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp
tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
tools/qmlprofiler/qmlprofilerapplication.cpp

index 2983c95356cd569bc772f6083f073f2ff17906ba..1cfebea03cc51ebe9b74a7986fe20f1596e340bb 100644 (file)
@@ -333,6 +333,7 @@ void QQmlDebugServerImpl::parseArguments()
     bool ok = false;
     QString hostAddress;
     QString fileName;
+    QStringList services;
 
     const QStringList lstjsDebugArguments = args.split(QLatin1Char(','));
     QStringList::const_iterator argsItEnd = lstjsDebugArguments.cend();
@@ -361,6 +362,10 @@ void QQmlDebugServerImpl::parseArguments()
         } else if (strArgument.startsWith(QLatin1String("file:"))) {
             fileName = strArgument.mid(5);
             ok = !fileName.isEmpty();
+        } else if (strArgument.startsWith(QLatin1String("services:"))) {
+            services.append(strArgument.mid(9));
+        } else if (!services.isEmpty()) {
+            services.append(strArgument);
         } else {
             qWarning() << QString::fromLatin1("QML Debugger: Invalid argument '%1' "
                                               "detected. Ignoring the same.")
@@ -369,6 +374,7 @@ void QQmlDebugServerImpl::parseArguments()
     }
 
     if (ok) {
+        setServices(services);
         m_blockingMode = block;
         if (!fileName.isEmpty())
             m_thread.setFileName(fileName);
index 393185bf0d00af752e726ad310afe33be1a1742c..8de734fa6813478350351f3b3643e838c0a598bd 100644 (file)
@@ -56,6 +56,7 @@ Q_QML_IMPORT_DEBUG_PLUGIN(QQmlDebuggerServiceFactory)
 
 struct QQmlDebugConnectorParams {
     QString pluginKey;
+    QStringList services;
     QString arguments;
     QQmlDebugConnector *instance;
 
@@ -83,6 +84,13 @@ void QQmlDebugConnector::setPluginKey(const QString &key)
     }
 }
 
+void QQmlDebugConnector::setServices(const QStringList &services)
+{
+    QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
+    if (params)
+        params->services = services;
+}
+
 QString QQmlDebugConnector::commandLineArguments()
 {
     QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
@@ -119,7 +127,9 @@ QQmlDebugConnector *QQmlDebugConnector::instance()
             foreach (const QJsonObject &object, metaDataForQQmlDebugService()) {
                 foreach (const QJsonValue &key, object.value(QLatin1String("MetaData")).toObject()
                          .value(QLatin1String("Keys")).toArray()) {
-                    loadQQmlDebugService(key.toString());
+                    QString keyString = key.toString();
+                    if (params->services.isEmpty() || params->services.contains(keyString))
+                        loadQQmlDebugService(keyString);
                 }
             }
         }
index 02e94811a6fdba8315a2233c93f3047eaa2f5f92..f5f5a87b562b66f9e2e027ec7a2680c75aac19fc 100644 (file)
@@ -58,6 +58,7 @@ class Q_QML_PRIVATE_EXPORT QQmlDebugConnector : public QObject
     Q_OBJECT
 public:
     static void setPluginKey(const QString &key);
+    static void setServices(const QStringList &services);
     static QQmlDebugConnector *instance();
 
     virtual bool blockingMode() const = 0;
index ed424b5a67d2944ab0402547a55743379b794556..7dbe35807d7de85e24e6aad1c949e72390dc8e44 100644 (file)
@@ -120,6 +120,8 @@ const char *UNCAUGHT = "uncaught";
 
 const char *BLOCKMODE = "-qmljsdebugger=port:3771,3800,block";
 const char *NORMALMODE = "-qmljsdebugger=port:3771,3800";
+const char *BLOCKRESTRICTEDMODE = "-qmljsdebugger=port:3771,3800,block,services:V8Debugger";
+const char *NORMALRESTRICTEDMODE = "-qmljsdebugger=port:3771,3800,services:V8Debugger";
 const char *TEST_QMLFILE = "test.qml";
 const char *TEST_JSFILE = "test.js";
 const char *TIMER_QMLFILE = "timer.qml";
@@ -157,7 +159,8 @@ class tst_QQmlDebugJS : public QQmlDataTest
 {
     Q_OBJECT
 
-    bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true);
+    void init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true,
+              bool restrictServices = false);
 
 private slots:
     void initTestCase();
@@ -165,6 +168,7 @@ private slots:
 
     void cleanup();
 
+    void connect_data();
     void connect();
     void interrupt();
     void getVersion();
@@ -822,33 +826,29 @@ void tst_QQmlDebugJS::cleanupTestCase()
 //    qDebug() << "Time Elapsed:" << t.elapsed();
 }
 
-bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode)
+void tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode, bool restrictServices)
 {
     connection = new QQmlDebugConnection();
     process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this);
     client = new QJSDebugClient(connection);
 
+    const char *args = 0;
     if (blockMode)
-        process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
+        args = restrictServices ? BLOCKRESTRICTEDMODE : BLOCKMODE;
     else
-        process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
+        args = restrictServices ? NORMALRESTRICTEDMODE : NORMALMODE;
 
-    if (!process->waitForSessionStart()) {
-        qDebug() << "could not launch application, or did not get 'Waiting for connection'.";
-        return false;
-    }
+    process->start(QStringList() << QLatin1String(args) << testFile(qmlFile));
+
+    QVERIFY(process->waitForSessionStart());
 
     const int port = process->debugPort();
     connection->connectToHost("127.0.0.1", port);
-    if (!connection->waitForConnected()) {
-        qDebug() << "could not connect to host!";
-        return false;
-    }
+    QVERIFY(connection->waitForConnected());
 
-    if (client->state() == QQmlDebugClient::Enabled)
-        return true;
 
-    return QQmlDebugTest::waitForSignal(client, SIGNAL(enabled()));
+    if (client->state() != QQmlDebugClient::Enabled)
+        QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(enabled())));
 }
 
 void tst_QQmlDebugJS::cleanup()
@@ -874,11 +874,21 @@ void tst_QQmlDebugJS::cleanup()
     connection = 0;
 }
 
-void tst_QQmlDebugJS::connect()
+void tst_QQmlDebugJS::connect_data()
 {
-    //void connect()
+    QTest::addColumn<bool>("blockMode");
+    QTest::addColumn<bool>("restrictMode");
+    QTest::newRow("normal/unrestricted") << false << false;
+    QTest::newRow("block/unrestricted") << true << false;
+    QTest::newRow("normal/restricted") << false << true;
+    QTest::newRow("block/restricted") << true << true;
+}
 
-    QVERIFY(init());
+void tst_QQmlDebugJS::connect()
+{
+    QFETCH(bool, blockMode);
+    QFETCH(bool, restrictMode);
+    init(QString(TEST_QMLFILE), blockMode, restrictMode);
     client->connect();
     QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
 }
@@ -887,7 +897,7 @@ void tst_QQmlDebugJS::interrupt()
 {
     //void connect()
 
-    QVERIFY(init());
+    init();
     client->connect();
 
     client->interrupt();
@@ -898,7 +908,7 @@ void tst_QQmlDebugJS::getVersion()
 {
     //void version()
 
-    QVERIFY(init());
+    init();
     client->connect();
     QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
 
@@ -923,7 +933,7 @@ void tst_QQmlDebugJS::disconnect()
 {
     //void disconnect()
 
-    QVERIFY(init());
+    init();
     client->connect();
 
     client->disconnect();
@@ -935,7 +945,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
     //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
 
     int sourceLine = 39;
-    QVERIFY(init(ONCOMPLETED_QMLFILE));
+    init(ONCOMPLETED_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -955,7 +965,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
     //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
 
     int sourceLine = 39;
-    QVERIFY(init(CREATECOMPONENT_QMLFILE));
+    init(CREATECOMPONENT_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -973,7 +983,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
 void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
 {
     int sourceLine = 40;
-    QVERIFY(init(TIMER_QMLFILE));
+    init(TIMER_QMLFILE);
 
     client->connect();
     //We can set the breakpoint after connect() here because the timer is repeating and if we miss
@@ -995,7 +1005,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
     //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
 
     int sourceLine = 35;
-    QVERIFY(init(LOADJSFILE_QMLFILE));
+    init(LOADJSFILE_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true);
     client->connect();
@@ -1016,7 +1026,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
 
     int sourceLine = 39;
     int actualLine = 41;
-    QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+    init(BREAKPOINTRELOCATION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1038,7 +1048,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
 
     int sourceLine = 40;
     int actualLine = 41;
-    QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+    init(BREAKPOINTRELOCATION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1059,7 +1069,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding()
     //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
 
     int sourceLine = 44;
-    QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+    init(BREAKPOINTRELOCATION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1078,7 +1088,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
 {
     int out = 10;
     int sourceLine = 42;
-    QVERIFY(init(CONDITION_QMLFILE));
+    init(CONDITION_QMLFILE);
 
     client->connect();
     //The breakpoint is in a timer loop so we can set it after connect().
@@ -1112,7 +1122,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
 
 void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
 {
-    QVERIFY(init(QUIT_QMLFILE));
+    init(QUIT_QMLFILE);
 
     int sourceLine = 41;
 
@@ -1153,7 +1163,7 @@ void tst_QQmlDebugJS::setBreakpointOnEvent()
 
     //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
 
-    QVERIFY(init(TIMER_QMLFILE));
+    init(TIMER_QMLFILE);
 
     client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true);
     client->connect();
@@ -1174,7 +1184,7 @@ void tst_QQmlDebugJS::clearBreakpoint()
 
     int sourceLine1 = 42;
     int sourceLine2 = 43;
-    QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+    init(CHANGEBREAKPOINT_QMLFILE);
 
     client->connect();
     //The breakpoints are in a timer loop so we can set them after connect().
@@ -1219,7 +1229,7 @@ void tst_QQmlDebugJS::setExceptionBreak()
 {
     //void setExceptionBreak(QString type, bool enabled = false);
 
-    QVERIFY(init(EXCEPTION_QMLFILE));
+    init(EXCEPTION_QMLFILE);
     client->setExceptionBreak(QJSDebugClient::All,true);
     client->connect();
     QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
@@ -1230,7 +1240,7 @@ void tst_QQmlDebugJS::stepNext()
     //void continueDebugging(StepAction stepAction, int stepCount = 1);
 
     int sourceLine = 42;
-    QVERIFY(init(STEPACTION_QMLFILE));
+    init(STEPACTION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1254,7 +1264,7 @@ void tst_QQmlDebugJS::stepIn()
 
     int sourceLine = 46;
     int actualLine = 42;
-    QVERIFY(init(STEPACTION_QMLFILE));
+    init(STEPACTION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
     client->connect();
@@ -1278,7 +1288,7 @@ void tst_QQmlDebugJS::stepOut()
 
     int sourceLine = 42;
     int actualLine = 46;
-    QVERIFY(init(STEPACTION_QMLFILE));
+    init(STEPACTION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1302,7 +1312,7 @@ void tst_QQmlDebugJS::continueDebugging()
 
     int sourceLine1 = 46;
     int sourceLine2 = 43;
-    QVERIFY(init(STEPACTION_QMLFILE));
+    init(STEPACTION_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
@@ -1326,7 +1336,7 @@ void tst_QQmlDebugJS::backtrace()
     //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
 
     int sourceLine = 39;
-    QVERIFY(init(ONCOMPLETED_QMLFILE));
+    init(ONCOMPLETED_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1341,7 +1351,7 @@ void tst_QQmlDebugJS::getFrameDetails()
     //void frame(int number = -1);
 
     int sourceLine = 39;
-    QVERIFY(init(ONCOMPLETED_QMLFILE));
+    init(ONCOMPLETED_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1356,7 +1366,7 @@ void tst_QQmlDebugJS::getScopeDetails()
     //void scope(int number = -1, int frameNumber = -1);
 
     int sourceLine = 39;
-    QVERIFY(init(ONCOMPLETED_QMLFILE));
+    init(ONCOMPLETED_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1371,7 +1381,7 @@ void tst_QQmlDebugJS::evaluateInGlobalScope()
 {
     //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
 
-    QVERIFY(init());
+    init();
 
     client->connect();
     client->evaluate(QLatin1String("console.log('Hello World')"), true);
@@ -1393,7 +1403,7 @@ void tst_QQmlDebugJS::evaluateInLocalScope()
     //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
 
     int sourceLine = 47;
-    QVERIFY(init(ONCOMPLETED_QMLFILE));
+    init(ONCOMPLETED_QMLFILE);
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
     client->connect();
@@ -1427,7 +1437,7 @@ void tst_QQmlDebugJS::getScripts()
 {
     //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
 
-    QVERIFY(init());
+    init();
 
     client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QString(TEST_QMLFILE), 40, -1, true);
     client->connect();
index f6cf9dae6047ec4d6b9586ab2b915b9f3ec7d2ac..11fa56d7101c0ae6664158e951cae4a0552d2041 100644 (file)
@@ -103,12 +103,15 @@ private:
     QQmlDebugConnection *m_connection;
     QQmlEngineControlClient *m_client;
 
-    void connect(const QString &testFile);
+    void connect(const QString &testFile, bool restrictServices);
+    void engine_data();
 
 private slots:
     void cleanup();
 
+    void startEngine_data();
     void startEngine();
+    void stopEngine_data();
     void stopEngine();
 };
 
@@ -148,11 +151,13 @@ void QQmlEngineControlClient::messageReceived(const QByteArray &message)
     QVERIFY(stream.atEnd());
 }
 
-void tst_QQmlEngineControl::connect(const QString &testFile)
+void tst_QQmlEngineControl::connect(const QString &testFile, bool restrictServices)
 {
     const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
     QStringList arguments;
-    arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block");
+    arguments << QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3")
+                 .arg(STR_PORT_FROM).arg(STR_PORT_TO)
+                 .arg(restrictServices ? QStringLiteral(",services:EngineControl") : QString());
 
     arguments << QQmlDataTest::instance()->testFile(testFile);
 
@@ -165,6 +170,8 @@ void tst_QQmlEngineControl::connect(const QString &testFile)
 
     const int port = m_process->debugPort();
     m_connection->connectToHost(QLatin1String("127.0.0.1"), port);
+
+    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 }
 
 void tst_QQmlEngineControl::cleanup()
@@ -183,11 +190,23 @@ void tst_QQmlEngineControl::cleanup()
     m_connection = 0;
 }
 
+void tst_QQmlEngineControl::engine_data()
+{
+    QTest::addColumn<bool>("restrictMode");
+    QTest::newRow("unrestricted") << false;
+    QTest::newRow("restricted") << true;
+}
+
+void tst_QQmlEngineControl::startEngine_data()
+{
+    engine_data();
+}
+
 void tst_QQmlEngineControl::startEngine()
 {
-    connect("test.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+    QFETCH(bool, restrictMode);
+
+    connect("test.qml", restrictMode);
 
     QTRY_VERIFY(!m_client->startingEngines.empty());
     m_client->command(QQmlEngineControlClient::StartWaitingEngine, m_client->startingEngines.last());
@@ -196,11 +215,16 @@ void tst_QQmlEngineControl::startEngine()
              "No engine start message received in time.");
 }
 
+void tst_QQmlEngineControl::stopEngine_data()
+{
+    engine_data();
+}
+
 void tst_QQmlEngineControl::stopEngine()
 {
-    connect("exit.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+    QFETCH(bool, restrictMode);
+
+    connect("exit.qml", restrictMode);
 
     QTRY_VERIFY(!m_client->startingEngines.empty());
     m_client->command(QQmlEngineControlClient::StartWaitingEngine, m_client->startingEngines.last());
index 8d119a30d7340cc6ef64056bd117cb5940f49651..0285bae189ddd7bd5edc006fb404c2a68c4d7924 100644 (file)
@@ -61,6 +61,7 @@ public:
 
 
 private:
+    void init(bool restrictServices);
     QmlDebugObjectReference findRootObject();
 
     QQmlDebugProcess *m_process;
@@ -68,9 +69,9 @@ private:
     QQmlEngineDebugClient *m_engineDebugClient;
 
 private slots:
-    void init();
     void cleanup();
 
+    void connect_data();
     void connect();
     void clearObjectReferenceHashonReloadQml();
 };
@@ -93,9 +94,12 @@ QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject(
 }
 
 
-void tst_QQmlEngineDebugInspectorIntegration::init()
+void tst_QQmlEngineDebugInspectorIntegration::init(bool restrictServices)
 {
-    const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block";
+    const QString argument = QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3")
+            .arg(STR_PORT_FROM).arg(STR_PORT_TO)
+            .arg(restrictServices ? QStringLiteral(",services:QmlDebugger,QmlInspector") :
+                                    QString());
 
     // ### Still using qmlscene because of QTBUG-33376
     m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath)
@@ -108,10 +112,8 @@ void tst_QQmlEngineDebugInspectorIntegration::init()
     m_inspectorClient = new QQmlInspectorClient(m_connection);
     m_engineDebugClient = new QQmlEngineDebugClient(m_connection);
 
-    const int port = m_process->debugPort();
-    m_connection->connectToHost(QLatin1String("127.0.0.1"), port);
-    bool ok = m_connection->waitForConnected();
-    QVERIFY(ok);
+    m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort());
+    QVERIFY(m_connection->waitForConnected());
 }
 
 void tst_QQmlEngineDebugInspectorIntegration::cleanup()
@@ -125,14 +127,24 @@ void tst_QQmlEngineDebugInspectorIntegration::cleanup()
     delete m_inspectorClient;
 }
 
+void tst_QQmlEngineDebugInspectorIntegration::connect_data()
+{
+    QTest::addColumn<bool>("restrictMode");
+    QTest::newRow("unrestricted") << false;
+    QTest::newRow("restricted") << true;
+}
+
 void tst_QQmlEngineDebugInspectorIntegration::connect()
 {
+    QFETCH(bool, restrictMode);
+    init(restrictMode);
     QTRY_COMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled);
     QTRY_COMPARE(m_engineDebugClient->state(), QQmlDebugClient::Enabled);
 }
 
 void tst_QQmlEngineDebugInspectorIntegration::clearObjectReferenceHashonReloadQml()
 {
+    init(true);
     QTRY_COMPARE(m_engineDebugClient->state(), QQmlDebugClient::Enabled);
     bool success = false;
     QmlDebugObjectReference rootObject = findRootObject();
index 2db544d6614acfb760158031b94d08b3b8b64040..bc3220ad8c0b2503e59e7b4b7c499d0cfa69e50c 100644 (file)
@@ -1225,7 +1225,7 @@ int main(int argc, char *argv[])
     char **_argv = new char*[_argc];
     for (int i = 0; i < argc; ++i)
         _argv[i] = argv[i];
-    char arg[] = "-qmljsdebugger=port:3768";
+    char arg[] = "-qmljsdebugger=port:3768,services:QmlDebugger";
     _argv[_argc - 1] = arg;
 
     QGuiApplication app(_argc, _argv);
index 3769b1b9c49f1e4f90412b3fe941aa8e6aff5651..70833f5e2cd2170bc1dfbe7d7e8ae62d83a6cce3 100644 (file)
@@ -60,7 +60,7 @@ public:
     }
 
 private:
-    void startQmlsceneProcess(const char *qmlFile);
+    void startQmlsceneProcess(const char *qmlFile, bool restrictMode = true);
 
 private:
     QQmlDebugProcess *m_process;
@@ -68,18 +68,20 @@ private:
     QQmlInspectorClient *m_client;
 
 private slots:
-    void init();
     void cleanup();
 
+    void connect_data();
     void connect();
     void showAppOnTop();
     void reloadQml();
     void reloadQmlWindow();
 };
 
-void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */)
+void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */, bool restrictServices)
 {
-    const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block";
+    const QString argument = QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3")
+            .arg(STR_PORT_FROM).arg(STR_PORT_TO)
+            .arg(restrictServices ? QStringLiteral(",services:QmlInspector") : QString());
 
     // ### This should be using qml instead of qmlscene, but can't because of QTBUG-33376 (same as the XFAIL testcase)
     m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this);
@@ -87,15 +89,13 @@ void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */)
     QVERIFY2(m_process->waitForSessionStart(),
              "Could not launch application, or did not get 'Waiting for connection'.");
 
-    QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+    m_connection = new QQmlDebugConnection();
     m_client = new QQmlInspectorClient(m_connection);
 
-    const int port = m_process->debugPort();
-    m_connection->connectToHost(QLatin1String("127.0.0.1"), port);
-}
+    m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort());
+    QVERIFY(m_client);
+    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
-void tst_QQmlInspector::init()
-{
 }
 
 void tst_QQmlInspector::cleanup()
@@ -104,16 +104,25 @@ void tst_QQmlInspector::cleanup()
         qDebug() << "Process State:" << m_process->state();
         qDebug() << "Application Output:" << m_process->output();
     }
-    delete m_process;
-    delete m_connection;
     delete m_client;
+    m_client = 0;
+    delete m_connection;
+    m_connection = 0;
+    delete m_process;
+    m_process = 0;
+}
+
+void tst_QQmlInspector::connect_data()
+{
+    QTest::addColumn<bool>("restrictMode");
+    QTest::newRow("unrestricted") << false;
+    QTest::newRow("restricted") << true;
 }
 
 void tst_QQmlInspector::connect()
 {
-    startQmlsceneProcess("qtquick2.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+    QFETCH(bool, restrictMode);
+    startQmlsceneProcess("qtquick2.qml", restrictMode);
 }
 
 void tst_QQmlInspector::showAppOnTop()
index 744830b55b9c13fc66b89901e0f76502ba592ba2..0e63e18952d10c5a7f6baaf4ec42fdb6d0fcd2ca 100644 (file)
@@ -197,7 +197,7 @@ private:
         CheckAll = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckDataEndsWith
     };
 
-    void connect(bool block, const QString &testFile);
+    void connect(bool block, const QString &testFile, bool restrictServices = true);
     void checkTraceReceived();
     void checkJsHeap();
     bool verify(MessageListType type, int expectedPosition, const QQmlProfilerData &expected,
@@ -206,9 +206,8 @@ private:
 private slots:
     void cleanup();
 
-    void blockingConnectWithTraceEnabled();
-    void blockingConnectWithTraceDisabled();
-    void nonBlockingConnect();
+    void connect_data();
+    void connect();
     void pixmapCacheData();
     void scenegraphData();
     void profileOnExit();
@@ -357,17 +356,16 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message)
         qmlMessages.append(data);
 }
 
-void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
+void tst_QQmlProfilerService::connect(bool block, const QString &testFile, bool restrictServices)
 {
     // ### Still using qmlscene due to QTBUG-33377
     const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
     QStringList arguments;
-    if (block)
-        arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block");
-    else
-        arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO );
-
-    arguments << QQmlDataTest::instance()->testFile(testFile);
+    arguments << QString::fromLatin1("-qmljsdebugger=port:%1,%2%3%4")
+                 .arg(STR_PORT_FROM).arg(STR_PORT_TO)
+                 .arg(block ? QStringLiteral(",block") : QString())
+                 .arg(restrictServices ? QStringLiteral(",services:CanvasFrameRate") : QString())
+              << QQmlDataTest::instance()->testFile(testFile);
 
     m_process = new QQmlDebugProcess(executable, this);
     m_process->start(QStringList() << arguments);
@@ -378,6 +376,8 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
 
     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);
 }
 
 void tst_QQmlProfilerService::checkTraceReceived()
@@ -560,37 +560,32 @@ void tst_QQmlProfilerService::cleanup()
     m_connection = 0;
 }
 
-void tst_QQmlProfilerService::blockingConnectWithTraceEnabled()
+void tst_QQmlProfilerService::connect_data()
 {
-    connect(true, "test.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
-
-    m_client->setTraceState(true);
-    m_client->setTraceState(false);
-    checkTraceReceived();
-    checkJsHeap();
+    QTest::addColumn<bool>("blockMode");
+    QTest::addColumn<bool>("restrictMode");
+    QTest::addColumn<bool>("traceEnabled");
+    QTest::newRow("normal/unrestricted/disabled") << false << false << false;
+    QTest::newRow("block/unrestricted/disabled") << true << false << false;
+    QTest::newRow("normal/restricted/disabled") << false << true << false;
+    QTest::newRow("block/restricted/disabled") << true << true << false;
+    QTest::newRow("normal/unrestricted/enabled") << false << false << true;
+    QTest::newRow("block/unrestricted/enabled") << true << false << true;
+    QTest::newRow("normal/restricted/enabled") << false << true << true;
+    QTest::newRow("block/restricted/enabled") << true << true << true;
 }
 
-void tst_QQmlProfilerService::blockingConnectWithTraceDisabled()
+void tst_QQmlProfilerService::connect()
 {
-    connect(true, "test.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+    QFETCH(bool, blockMode);
+    QFETCH(bool, restrictMode);
+    QFETCH(bool, traceEnabled);
 
-    m_client->setTraceState(false);
-    m_client->setTraceState(true);
-    m_client->setTraceState(false);
-    checkTraceReceived();
-    checkJsHeap();
-}
-
-void tst_QQmlProfilerService::nonBlockingConnect()
-{
-    connect(false, "test.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+    connect(blockMode, "test.qml", restrictMode);
 
+    // if the engine is waiting, then the first message determines if it starts with trace enabled
+    if (!traceEnabled)
+        m_client->setTraceState(false);
     m_client->setTraceState(true);
     m_client->setTraceState(false);
     checkTraceReceived();
@@ -600,8 +595,6 @@ void tst_QQmlProfilerService::nonBlockingConnect()
 void tst_QQmlProfilerService::pixmapCacheData()
 {
     connect(true, "pixmapCacheTest.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true);
     QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput())));
@@ -639,8 +632,6 @@ void tst_QQmlProfilerService::pixmapCacheData()
 void tst_QQmlProfilerService::scenegraphData()
 {
     connect(true, "scenegraphTest.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true);
 
@@ -693,8 +684,6 @@ void tst_QQmlProfilerService::scenegraphData()
 void tst_QQmlProfilerService::profileOnExit()
 {
     connect(true, "exit.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true);
 
@@ -705,8 +694,6 @@ void tst_QQmlProfilerService::profileOnExit()
 void tst_QQmlProfilerService::controlFromJS()
 {
     connect(true, "controlFromJS.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(false);
     checkTraceReceived();
@@ -716,8 +703,6 @@ void tst_QQmlProfilerService::controlFromJS()
 void tst_QQmlProfilerService::signalSourceLocation()
 {
     connect(true, "signalSourceLocation.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true);
     while (!(m_process->output().contains(QLatin1String("500"))))
@@ -741,8 +726,6 @@ void tst_QQmlProfilerService::signalSourceLocation()
 void tst_QQmlProfilerService::javascript()
 {
     connect(true, "javascript.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true);
     while (!(m_process->output().contains(QLatin1String("done"))))
@@ -772,8 +755,6 @@ void tst_QQmlProfilerService::javascript()
 void tst_QQmlProfilerService::flushInterval()
 {
     connect(true, "timer.qml");
-    QVERIFY(m_client);
-    QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
 
     m_client->setTraceState(true, 1);
 
index 188373ccc6037c7b46191eb1a00f9ac58929765b..1eab1a0a8cc03596e6f129e6687a82487644adf1 100644 (file)
@@ -476,7 +476,8 @@ void QmlProfilerApplication::run()
     if (m_runMode == LaunchMode) {
         m_process = new QProcess(this);
         QStringList arguments;
-        arguments << QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_port);
+        arguments << QString::fromLatin1("-qmljsdebugger=port:%1,block,services:CanvasFrameRate")
+                     .arg(m_port);
         arguments << m_programArguments;
 
         m_process->setProcessChannelMode(QProcess::MergedChannels);