diff options
Diffstat (limited to 'tests/auto/qml/debugger')
27 files changed, 551 insertions, 795 deletions
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro index 6c729ab235..9cf323ba36 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro +++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro @@ -5,8 +5,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qdebugmessageservice.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/debugutil.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index f193d3928a..f851688b5e 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -28,7 +28,6 @@ //QQmlDebugTest #include "debugutil_p.h" -#include "../../../shared/util.h" #include <private/qqmldebugclient_p.h> #include <private/qqmldebugconnection_p.h> @@ -38,31 +37,19 @@ #include <QtCore/qlibraryinfo.h> #include <QtTest/qtest.h> -const char *NORMALMODE = "-qmljsdebugger=port:3777,3787,block"; const char *QMLFILE = "test.qml"; class QQmlDebugMsgClient; -class tst_QDebugMessageService : public QQmlDataTest +class tst_QDebugMessageService : public QQmlDebugTest { Q_OBJECT -public: - tst_QDebugMessageService(); - - void init(); - private slots: - void initTestCase(); - void cleanupTestCase(); - - void cleanup(); - void retrieveDebugOutput(); private: - QQmlDebugProcess *m_process; - QQmlDebugMsgClient *m_client; - QQmlDebugConnection *m_connection; + QList<QQmlDebugClient *> createClients() override; + QPointer<QQmlDebugMsgClient> m_client; }; struct LogEntry { @@ -150,73 +137,16 @@ void QQmlDebugMsgClient::messageReceived(const QByteArray &data) } } -tst_QDebugMessageService::tst_QDebugMessageService() -{ -} - -void tst_QDebugMessageService::initTestCase() -{ - QQmlDataTest::initTestCase(); - m_process = 0; - m_client = 0; - m_connection = 0; -} - -void tst_QDebugMessageService::cleanupTestCase() +QList<QQmlDebugClient *> tst_QDebugMessageService::createClients() { - if (m_process) - delete m_process; - - if (m_client) - delete m_client; - - if (m_connection) - delete m_connection; -} - -void tst_QDebugMessageService::init() -{ - m_connection = new QQmlDebugConnection(); - m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", this); m_client = new QQmlDebugMsgClient(m_connection); - - m_process->start(QStringList() << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE)); - QVERIFY2(m_process->waitForSessionStart(), - "Could not launch application, or did not get 'Waiting for connection'."); - - const int port = m_process->debugPort(); - m_connection->connectToHost("127.0.0.1", port); - QVERIFY(m_connection->waitForConnected()); - - if (m_client->state() != QQmlDebugClient::Enabled) - QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled())); - - QCOMPARE(m_client->state(), QQmlDebugClient::Enabled); -} - -void tst_QDebugMessageService::cleanup() -{ - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << m_process->state(); - qDebug() << "Application Output:" << m_process->output(); - } - if (m_process) - delete m_process; - - if (m_client) - delete m_client; - - if (m_connection) - delete m_connection; - - m_process = 0; - m_client = 0; - m_connection = 0; + return QList<QQmlDebugClient *>({m_client}); } void tst_QDebugMessageService::retrieveDebugOutput() { - init(); + QCOMPARE(QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", + QString(), testFile(QMLFILE), true), ConnectSuccess); QTRY_VERIFY(m_client->logBuffer.size() >= 2); diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro index a7c0fa7f8e..b1e3835844 100644 --- a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro +++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro @@ -4,7 +4,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qpacketprotocol.cpp -INCLUDEPATH += ../shared include(../shared/debugutil.pri) QT += qml network testlib gui-private core-private diff --git a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro index 622b373692..673330a3cf 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro +++ b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro @@ -7,7 +7,6 @@ HEADERS += ../shared/qqmldebugtestservice.h SOURCES += tst_qqmldebugclient.cpp \ ../shared/qqmldebugtestservice.cpp -INCLUDEPATH += ../shared include(../shared/debugutil.pri) DEFINES += QT_QML_DEBUG_NO_WARNING diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro index f8014f04f4..bd382ebaab 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/qqmldebuggingenabler.pro @@ -6,8 +6,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmldebuggingenabler.cpp -INCLUDEPATH += ../../shared -include(../../../../shared/util.pri) include(../../shared/debugutil.pri) OTHER_FILES += data/test.qml diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 3aa3a5c87e..134de44858 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -32,6 +32,8 @@ #include <private/qqmldebugclient_p.h> #include <private/qqmldebugconnection_p.h> +#include <QtQml/qqmldebug.h> + #include <QtTest/qtest.h> #include <QtCore/qprocess.h> #include <QtCore/qtimer.h> @@ -40,17 +42,11 @@ #include <QtCore/qmutex.h> #include <QtCore/qlibraryinfo.h> -class tst_QQmlDebuggingEnabler : public QQmlDataTest +class tst_QQmlDebuggingEnabler : public QQmlDebugTest { Q_OBJECT - bool init(bool blockMode, bool qmlscene, int portFrom, int portTo); - private slots: - void initTestCase(); - void cleanupTestCase(); - void cleanup(); - void qmlscene_data(); void qmlscene(); void custom_data(); @@ -58,88 +54,8 @@ private slots: private: void data(); - QQmlDebugProcess *process; - QQmlDebugConnection *connection; - QTime t; }; -void tst_QQmlDebuggingEnabler::initTestCase() -{ - QQmlDataTest::initTestCase(); - t.start(); - process = 0; - connection = 0; -} - -void tst_QQmlDebuggingEnabler::cleanupTestCase() -{ - if (process) { - process->stop(); - delete process; - } - - if (connection) - delete connection; -} - -bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom, int portTo) -{ - connection = new QQmlDebugConnection(); - - if (qmlscene) { - process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - process->setMaximumBindErrors(1); - } else { - process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebuggingenablerserver"), this); - process->setMaximumBindErrors(portTo - portFrom); - } - - if (qmlscene) { - process->start(QStringList() << QLatin1String("-qmljsdebugger=port:") + - QString::number(portFrom) + QLatin1Char(',') + QString::number(portTo) + - QLatin1String(blockMode ? ",block": "") << - testFile(QLatin1String("test.qml"))); - } else { - QStringList args; - if (blockMode) - args << QLatin1String("-block"); - args << QString::number(portFrom) << QString::number(portTo); - process->start(args); - } - - if (!process->waitForSessionStart()) { - return false; - } - - const int port = process->debugPort(); - connection->connectToHost("127.0.0.1", port); - if (!connection->waitForConnected()) { - qDebug() << "could not connect to host!"; - return false; - } - return true; -} - -void tst_QQmlDebuggingEnabler::cleanup() -{ - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << process->state(); - qDebug() << "Application Output:" << process->output(); - } - - if (process) { - process->stop(); - delete process; - } - - - if (connection) - delete connection; - - process = 0; - connection = 0; -} - void tst_QQmlDebuggingEnabler::data() { QTest::addColumn<QString>("connector"); @@ -185,32 +101,32 @@ void tst_QQmlDebuggingEnabler::qmlscene() QFETCH(bool, blockMode); QFETCH(QStringList, services); - process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", - this); - process->setMaximumBindErrors(1); - process->start(QStringList() - << QString::fromLatin1("-qmljsdebugger=connector:%1%2%3%4") - .arg(connector + (connector == QLatin1String("QQmlDebugServer") ? - QLatin1String(",port:5555,5565") : QString())) - .arg(blockMode ? QLatin1String(",block") : QString()) - .arg(services.isEmpty() ? QString() : QString::fromLatin1(",services:")) - .arg(services.isEmpty() ? QString() : services.join(",")) - << testFile(QLatin1String("test.qml"))); + m_process = new QQmlDebugProcess( + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); + m_process->setMaximumBindErrors(1); + m_process->start(QStringList() + << QString::fromLatin1("-qmljsdebugger=connector:%1%2%3%4") + .arg(connector + (connector == QLatin1String("QQmlDebugServer") + ? QLatin1String(",port:5555,5565") : QString())) + .arg(blockMode ? QLatin1String(",block") : QString()) + .arg(services.isEmpty() ? QString() : QString::fromLatin1(",services:")) + .arg(services.isEmpty() ? QString() : services.join(",")) + << testFile(QLatin1String("test.qml"))); if (connector == QLatin1String("QQmlDebugServer")) { - QVERIFY(process->waitForSessionStart()); - connection = new QQmlDebugConnection(); - QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) + QVERIFY(m_process->waitForSessionStart()); + m_connection = new QQmlDebugConnection(); + m_clients = QQmlDebugTest::createOtherClients(m_connection); + m_connection->connectToHost("127.0.0.1", m_process->debugPort()); + QVERIFY(m_connection->waitForConnected()); + foreach (QQmlDebugClient *client, m_clients) QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); } - QCOMPARE(process->state(), QLatin1String("running")); + QCOMPARE(m_process->state(), QLatin1String("running")); if (!blockMode) - QTRY_VERIFY(process->output().contains(QLatin1String("qml: Component.onCompleted"))); + QTRY_VERIFY(m_process->output().contains(QLatin1String("qml: Component.onCompleted"))); } void tst_QQmlDebuggingEnabler::custom_data() @@ -226,9 +142,9 @@ void tst_QQmlDebuggingEnabler::custom() const int portFrom = 5555; const int portTo = 5565; - process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + - QLatin1String("/qqmldebuggingenablerserver"), this); - process->setMaximumBindErrors(portTo - portFrom); + m_process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + + QLatin1String("/qqmldebuggingenablerserver"), this); + m_process->setMaximumBindErrors(portTo - portFrom); QStringList args; if (blockMode) @@ -240,22 +156,22 @@ void tst_QQmlDebuggingEnabler::custom() if (!services.isEmpty()) args << QLatin1String("-services") << services; - process->start(args); + m_process->start(args); if (connector == QLatin1String("QQmlDebugServer")) { - QVERIFY(process->waitForSessionStart()); - connection = new QQmlDebugConnection(); - QList<QQmlDebugClient *> clients = QQmlDebugTest::createOtherClients(connection); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); - foreach (QQmlDebugClient *client, clients) + QVERIFY(m_process->waitForSessionStart()); + m_connection = new QQmlDebugConnection(); + m_clients = QQmlDebugTest::createOtherClients(m_connection); + m_connection->connectToHost("127.0.0.1", m_process->debugPort()); + QVERIFY(m_connection->waitForConnected()); + for (QQmlDebugClient *client : qAsConst(m_clients)) QCOMPARE(client->state(), (services.isEmpty() || services.contains(client->name())) ? QQmlDebugClient::Enabled : QQmlDebugClient::Unavailable); } - QCOMPARE(process->state(), QLatin1String("running")); + QCOMPARE(m_process->state(), QLatin1String("running")); if (!blockMode) - QTRY_VERIFY(process->output().contains(QLatin1String("QQmlEngine created"))); + QTRY_VERIFY(m_process->output().contains(QLatin1String("QQmlEngine created"))); } QTEST_MAIN(tst_QQmlDebuggingEnabler) diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro index cbaf3b5309..90623c75a6 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro @@ -6,8 +6,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmldebugjs.cpp -INCLUDEPATH += ../../shared -include(../../../../shared/util.pri) include(../../shared/debugutil.pri) include(../../shared/qqmlenginedebugclient.pri) diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp index d248cf9708..59483d75da 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp @@ -136,7 +136,7 @@ const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml"; do {\ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\ if (QTest::currentTestFailed()) \ - qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\ + qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << m_process->output();\ return;\ }\ } while (0) @@ -144,18 +144,12 @@ do {\ class QJSDebugClient; -class tst_QQmlDebugJS : public QQmlDataTest +class tst_QQmlDebugJS : public QQmlDebugTest { Q_OBJECT - void init(bool qmlscene, const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true, - bool restrictServices = false); - private slots: - void initTestCase(); - void cleanupTestCase(); - - void cleanup(); + void initTestCase() override; void connect_data(); void connect(); @@ -223,11 +217,12 @@ private slots: void getScripts(); private: - void targetData(); + ConnectResult init(bool qmlscene, const QString &qmlFile = QString(TEST_QMLFILE), + bool blockMode = true, bool restrictServices = false); + QList<QQmlDebugClient *> createClients() override; + QPointer<QJSDebugClient> m_client; - QQmlDebugProcess *process; - QJSDebugClient *client; - QQmlDebugConnection *connection; + void targetData(); QTime t; }; @@ -280,7 +275,6 @@ protected: void messageReceived(const QByteArray &data); signals: - void enabled(); void connected(); void interruptRequested(); void result(); @@ -667,10 +661,8 @@ void QJSDebugClient::disconnect() void QJSDebugClient::stateChanged(State state) { - if (state == Enabled) { + if (state == Enabled) flushSendBuffer(); - emit enabled(); - } } void QJSDebugClient::messageReceived(const QByteArray &data) @@ -763,85 +755,19 @@ QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray void tst_QQmlDebugJS::initTestCase() { - QQmlDataTest::initTestCase(); + QQmlDebugTest::initTestCase(); t.start(); - process = 0; - client = 0; - connection = 0; -} - -void tst_QQmlDebugJS::cleanupTestCase() -{ - if (process) { - process->stop(); - delete process; - } - - if (client) - delete client; - - if (connection) - delete connection; } -void tst_QQmlDebugJS::init(bool qmlscene, const QString &qmlFile, bool blockMode, - bool restrictServices) +QQmlDebugTest::ConnectResult tst_QQmlDebugJS::init(bool qmlscene, const QString &qmlFile, + bool blockMode, bool restrictServices) { - connection = new QQmlDebugConnection(); - if (qmlscene) - process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + - "/qmlscene", this); - else - process = new QQmlDebugProcess(QCoreApplication::applicationDirPath() + - QLatin1String("/qqmldebugjsserver"), this); - client = new QJSDebugClient(connection); - QList<QQmlDebugClient *> others = QQmlDebugTest::createOtherClients(connection); - - const char *args = 0; - if (blockMode) - args = restrictServices ? BLOCKRESTRICTEDMODE : BLOCKMODE; - else - args = restrictServices ? NORMALRESTRICTEDMODE : NORMALMODE; - - process->start(QStringList() << QLatin1String(args) << testFile(qmlFile)); - - QVERIFY(process->waitForSessionStart()); - - const int port = process->debugPort(); - connection->connectToHost("127.0.0.1", port); - QVERIFY(connection->waitForConnected()); - - - 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() -{ - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << process->state(); - qDebug() << "Application Output:" << process->output(); - } - - if (process) { - process->stop(); - delete process; - } - - if (client) - delete client; - - if (connection) - delete connection; - - process = 0; - client = 0; - connection = 0; + const QString executable = qmlscene + ? QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene" + : QCoreApplication::applicationDirPath() + QLatin1String("/qqmldebugjsserver"); + return QQmlDebugTest::connect( + executable, restrictServices ? QStringLiteral("V8Debugger") : QString(), + testFile(qmlFile), blockMode); } void tst_QQmlDebugJS::connect_data() @@ -864,9 +790,9 @@ void tst_QQmlDebugJS::connect() QFETCH(bool, blockMode); QFETCH(bool, restrictMode); QFETCH(bool, qmlscene); - init(qmlscene, QString(TEST_QMLFILE), blockMode, restrictMode); - client->connect(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); + QCOMPARE(init(qmlscene, QString(TEST_QMLFILE), blockMode, restrictMode), ConnectSuccess); + m_client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(connected()))); } void tst_QQmlDebugJS::interrupt() @@ -876,11 +802,11 @@ void tst_QQmlDebugJS::interrupt() QFETCH(bool, qmlscene); QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene); - client->connect(redundantRefs, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); + m_client->connect(redundantRefs, namesAsObjects); - client->interrupt(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(interruptRequested()))); + m_client->interrupt(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(interruptRequested()))); } void tst_QQmlDebugJS::getVersion() @@ -890,12 +816,12 @@ void tst_QQmlDebugJS::getVersion() QFETCH(bool, qmlscene); QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); + QCOMPARE(init(qmlscene), ConnectSuccess); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(connected()))); - client->version(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->version(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::getVersionWhenAttaching() @@ -905,11 +831,11 @@ void tst_QQmlDebugJS::getVersionWhenAttaching() QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene, QLatin1String(TIMER_QMLFILE), false); - client->connect(redundantRefs, namesAsObjects); + QCOMPARE(init(qmlscene, QLatin1String(TIMER_QMLFILE), false), ConnectSuccess); + m_client->connect(redundantRefs, namesAsObjects); - client->version(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->version(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::disconnect() @@ -919,11 +845,11 @@ void tst_QQmlDebugJS::disconnect() QFETCH(bool, qmlscene); QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene); - client->connect(redundantRefs, namesAsObjects); + QCOMPARE(init(qmlscene), ConnectSuccess); + m_client->connect(redundantRefs, namesAsObjects); - client->disconnect(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->disconnect(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() @@ -934,14 +860,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, ONCOMPLETED_QMLFILE); + QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -957,14 +883,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, CREATECOMPONENT_QMLFILE); + QCOMPARE(init(qmlscene, CREATECOMPONENT_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -978,16 +904,16 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback() QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 35; - init(qmlscene, TIMER_QMLFILE); + QCOMPARE(init(qmlscene, TIMER_QMLFILE), ConnectSuccess); - client->connect(redundantRefs, namesAsObjects); + m_client->connect(redundantRefs, namesAsObjects); //We can set the breakpoint after connect() here because the timer is repeating and if we miss //its first iteration we can still catch the second one. - client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1003,14 +929,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile() QFETCH(bool, namesAsObjects); int sourceLine = 31; - init(qmlscene, LOADJSFILE_QMLFILE); + QCOMPARE(init(qmlscene, LOADJSFILE_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(TEST_JSFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(TEST_JSFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1027,15 +953,15 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment() int sourceLine = 34; int actualLine = 36; - init(qmlscene, BREAKPOINTRELOCATION_QMLFILE); + QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); + m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()), 1)); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1052,15 +978,15 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine() int sourceLine = 35; int actualLine = 36; - init(qmlscene, BREAKPOINTRELOCATION_QMLFILE); + QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); + m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()), 1)); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1076,14 +1002,14 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() QFETCH(bool, namesAsObjects); int sourceLine = 39; - init(qmlscene, BREAKPOINTRELOCATION_QMLFILE); + QCOMPARE(init(qmlscene, BREAKPOINTRELOCATION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1098,28 +1024,28 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() QFETCH(bool, namesAsObjects); int out = 10; int sourceLine = 37; - init(qmlscene, CONDITION_QMLFILE); + QCOMPARE(init(qmlscene, CONDITION_QMLFILE), ConnectSuccess); - client->connect(redundantRefs, namesAsObjects); + m_client->connect(redundantRefs, namesAsObjects); //The breakpoint is in a timer loop so we can set it after connect(). - client->setBreakpoint(QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10")); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10")); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); //Get the frame index - QString jsonString = client->response; - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString = m_client->response; + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); { QVariantMap body = value.value("body").toMap(); int frameIndex = body.value("index").toInt(); //Verify the value of 'result' - client->evaluate(QLatin1String("a"),frameIndex); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->evaluate(QLatin1String("a"),frameIndex); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } - jsonString = client->response; - QJSValue val = client->parser.call(QJSValueList() << QJSValue(jsonString)); + jsonString = m_client->response; + QJSValue val = m_client->parser.call(QJSValueList() << QJSValue(jsonString)); QVERIFY(val.isObject()); QJSValue body = val.property(QStringLiteral("body")); QVERIFY(body.isObject()); @@ -1135,42 +1061,42 @@ void tst_QQmlDebugJS::setBreakpointInScriptThatQuits() QFETCH(bool, qmlscene); QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene, QUIT_QMLFILE); + QCOMPARE(init(qmlscene, QUIT_QMLFILE), ConnectSuccess); int sourceLine = 36; - client->setBreakpoint(QLatin1String(QUIT_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(QUIT_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine); QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QUIT_QMLFILE)); - client->continueDebugging(QJSDebugClient::Continue); - QVERIFY(process->waitForFinished()); - QCOMPARE(process->exitStatus(), QProcess::NormalExit); + m_client->continueDebugging(QJSDebugClient::Continue); + QVERIFY(m_process->waitForFinished()); + QCOMPARE(m_process->exitStatus(), QProcess::NormalExit); } void tst_QQmlDebugJS::setBreakpointWhenAttaching() { int sourceLine = 35; - init(true, QLatin1String(TIMER_QMLFILE), false); + QCOMPARE(init(true, QLatin1String(TIMER_QMLFILE), false), ConnectSuccess); - client->connect(); + m_client->connect(); QSKIP("\nThe breakpoint may not hit because the engine may run in JIT mode or not have debug\n" "instructions, as we've connected in non-blocking mode above. That means we may have\n" "connected after the engine was already running, with all the QML already compiled."); //The breakpoint is in a timer loop so we can set it after connect(). - client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine); + m_client->setBreakpoint(QLatin1String(TIMER_QMLFILE), sourceLine); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); } void tst_QQmlDebugJS::clearBreakpoint() @@ -1182,41 +1108,41 @@ void tst_QQmlDebugJS::clearBreakpoint() int sourceLine1 = 37; int sourceLine2 = 38; - init(qmlscene, CHANGEBREAKPOINT_QMLFILE); + QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess); - client->connect(redundantRefs, namesAsObjects); + m_client->connect(redundantRefs, namesAsObjects); //The breakpoints are in a timer loop so we can set them after connect(). //Furthermore the breakpoints should be hit in the right order because setting of breakpoints //can only occur in the QML event loop. (see QCOMPARE for sourceLine2 below) - client->setBreakpoint(QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); + m_client->setBreakpoint(QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + m_client->setBreakpoint(QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); //Will hit 1st brakpoint, change this breakpoint enable = false - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); QList<QVariant> breakpointsHit = body.value("breakpoints").toList(); int breakpoint = breakpointsHit.at(0).toInt(); - client->clearBreakpoint(breakpoint); + m_client->clearBreakpoint(breakpoint); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); + m_client->continueDebugging(QJSDebugClient::Continue); //Hit 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); //Continue with debugging - client->continueDebugging(QJSDebugClient::Continue); + m_client->continueDebugging(QJSDebugClient::Continue); //Should stop at 2nd breakpoint - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - jsonString = client->response; - value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + jsonString = m_client->response; + value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); body = value.value("body").toMap(); @@ -1230,10 +1156,10 @@ void tst_QQmlDebugJS::setExceptionBreak() QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene, EXCEPTION_QMLFILE); - client->setExceptionBreak(QJSDebugClient::All,true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + QCOMPARE(init(qmlscene, EXCEPTION_QMLFILE), ConnectSuccess); + m_client->setExceptionBreak(QJSDebugClient::All,true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); } void tst_QQmlDebugJS::stepNext() @@ -1244,17 +1170,17 @@ void tst_QQmlDebugJS::stepNext() QFETCH(bool, namesAsObjects); int sourceLine = 37; - init(qmlscene, STEPACTION_QMLFILE); + QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->continueDebugging(QJSDebugClient::Next); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->continueDebugging(QJSDebugClient::Next); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1271,17 +1197,17 @@ void tst_QQmlDebugJS::stepIn() int sourceLine = 41; int actualLine = 37; - init(qmlscene, STEPACTION_QMLFILE); + QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->continueDebugging(QJSDebugClient::In); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->continueDebugging(QJSDebugClient::In); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1298,17 +1224,17 @@ void tst_QQmlDebugJS::stepOut() int sourceLine = 37; int actualLine = 41; - init(qmlscene, STEPACTION_QMLFILE); + QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->continueDebugging(QJSDebugClient::Out); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->continueDebugging(QJSDebugClient::Out); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1325,18 +1251,18 @@ void tst_QQmlDebugJS::continueDebugging() int sourceLine1 = 41; int sourceLine2 = 38; - init(qmlscene, STEPACTION_QMLFILE); + QCOMPARE(init(qmlscene, STEPACTION_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); - client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); + m_client->setBreakpoint(QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->continueDebugging(QJSDebugClient::Continue); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->continueDebugging(QJSDebugClient::Continue); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); @@ -1352,14 +1278,14 @@ void tst_QQmlDebugJS::backtrace() QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, ONCOMPLETED_QMLFILE); + QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->backtrace(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->backtrace(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::getFrameDetails() @@ -1370,14 +1296,14 @@ void tst_QQmlDebugJS::getFrameDetails() QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, ONCOMPLETED_QMLFILE); + QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->frame(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->frame(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::getScopeDetails() @@ -1388,31 +1314,31 @@ void tst_QQmlDebugJS::getScopeDetails() QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, ONCOMPLETED_QMLFILE); + QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->scope(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->scope(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); } void tst_QQmlDebugJS::evaluateInGlobalScope() { //void evaluate(QString expr, int frame = -1); - init(true); + QCOMPARE(init(true), ConnectSuccess); - client->connect(); + m_client->connect(); do { // The engine might not be initialized, yet. We just try until it shows up. - client->evaluate(QLatin1String("console.log('Hello World')")); - } while (!QQmlDebugTest::waitForSignal(client, SIGNAL(result()), 500)); + m_client->evaluate(QLatin1String("console.log('Hello World')")); + } while (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()), 500)); //Verify the return value of 'console.log()', which is "undefined" - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); QCOMPARE(body.value("type").toString(),QLatin1String("undefined")); } @@ -1425,29 +1351,29 @@ void tst_QQmlDebugJS::evaluateInLocalScope() QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); int sourceLine = 34; - init(qmlscene, ONCOMPLETED_QMLFILE); + QCOMPARE(init(qmlscene, ONCOMPLETED_QMLFILE), ConnectSuccess); - client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->frame(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->frame(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); //Get the frame index - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); int frameIndex = body.value("index").toInt(); - client->evaluate(QLatin1String("root.a"), frameIndex); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->evaluate(QLatin1String("root.a"), frameIndex); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); //Verify the value of 'timer.interval' - jsonString = client->response; - value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + jsonString = m_client->response; + value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); body = value.value("body").toMap(); @@ -1456,25 +1382,25 @@ void tst_QQmlDebugJS::evaluateInLocalScope() void tst_QQmlDebugJS::evaluateInContext() { - connection = new QQmlDebugConnection(); - process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + m_connection = new QQmlDebugConnection(); + m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); - client = new QJSDebugClient(connection); - QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(connection)); - process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE)); + m_client = new QJSDebugClient(m_connection); + QScopedPointer<QQmlEngineDebugClient> engineClient(new QQmlEngineDebugClient(m_connection)); + m_process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE)); - QVERIFY(process->waitForSessionStart()); + QVERIFY(m_process->waitForSessionStart()); - connection->connectToHost("127.0.0.1", process->debugPort()); - QVERIFY(connection->waitForConnected()); + m_connection->connectToHost("127.0.0.1", m_process->debugPort()); + QVERIFY(m_connection->waitForConnected()); - QTRY_COMPARE(client->state(), QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(m_client->state(), QQmlEngineDebugClient::Enabled); QTRY_COMPARE(engineClient->state(), QQmlEngineDebugClient::Enabled); - client->connect(); + m_client->connect(); // "a" not accessible without extra context - client->evaluate(QLatin1String("a + 10"), -1, -1); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(failure()))); + m_client->evaluate(QLatin1String("a + 10"), -1, -1); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(failure()))); bool success = false; engineClient->queryAvailableEngines(&success); @@ -1496,11 +1422,11 @@ void tst_QQmlDebugJS::evaluateInContext() auto object = engineClient->object(); // "a" accessible in context of surrounding object - client->evaluate(QLatin1String("a + 10"), -1, object.debugId); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + m_client->evaluate(QLatin1String("a + 10"), -1, object.debugId); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); - QString jsonString = client->response; - QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString jsonString = m_client->response; + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QVariantMap body = value.value("body").toMap(); QTRY_COMPARE(body.value("value").toInt(), 20); @@ -1513,16 +1439,16 @@ void tst_QQmlDebugJS::getScripts() QFETCH(bool, qmlscene); QFETCH(bool, redundantRefs); QFETCH(bool, namesAsObjects); - init(qmlscene); + QCOMPARE(init(qmlscene), ConnectSuccess); - client->setBreakpoint(QString(TEST_QMLFILE), 35, -1, true); - client->connect(redundantRefs, namesAsObjects); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + m_client->setBreakpoint(QString(TEST_QMLFILE), 35, -1, true); + m_client->connect(redundantRefs, namesAsObjects); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(stopped()))); - client->scripts(); - QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); - QString jsonString(client->response); - QVariantMap value = client->parser.call(QJSValueList() + m_client->scripts(); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(result()))); + QString jsonString(m_client->response); + QVariantMap value = m_client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); QList<QVariant> scripts = value.value("body").toList(); @@ -1531,6 +1457,12 @@ void tst_QQmlDebugJS::getScripts() QVERIFY(scripts.first().toMap()[QStringLiteral("name")].toString().endsWith(QStringLiteral("data/test.qml"))); } +QList<QQmlDebugClient *> tst_QQmlDebugJS::createClients() +{ + m_client = new QJSDebugClient(m_connection); + return QList<QQmlDebugClient *>({m_client}); +} + void tst_QQmlDebugJS::targetData() { QTest::addColumn<bool>("qmlscene"); diff --git a/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro b/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro index 860d39cca4..1dc9de8f34 100644 --- a/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro +++ b/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro @@ -7,7 +7,6 @@ HEADERS += ../shared/qqmldebugtestservice.h SOURCES += tst_qqmldebuglocal.cpp \ ../shared/qqmldebugtestservice.cpp -INCLUDEPATH += ../shared include(../shared/debugutil.pri) QT += qml-private testlib gui-private core-private diff --git a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro index 79cbe52331..3101d09ea5 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro +++ b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro @@ -7,8 +7,6 @@ HEADERS += ../shared/qqmldebugtestservice.h SOURCES += tst_qqmldebugservice.cpp \ ../shared/qqmldebugtestservice.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/debugutil.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 8092faba04..06e4a4bfcc 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -105,10 +105,13 @@ void tst_QQmlDebugService::initTestCase() void tst_QQmlDebugService::checkPortRange() { - QQmlDebugConnection *connection1 = new QQmlDebugConnection(); - QQmlDebugProcess *process1 = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); + QScopedPointer<QQmlDebugConnection> connection1(new QQmlDebugConnection()); + QScopedPointer<QQmlDebugProcess> process1( + new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + + "/qmlscene", this)); - process1->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") << testFile("test.qml")); + process1->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") + << testFile("test.qml")); if (!process1->waitForSessionStart()) QFAIL("could not launch application, or did not get 'Waiting for connection'."); @@ -119,10 +122,13 @@ void tst_QQmlDebugService::checkPortRange() QFAIL("could not connect to host!"); // Second instance - QQmlDebugConnection *connection2 = new QQmlDebugConnection(); - QQmlDebugProcess *process2 = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); + QScopedPointer<QQmlDebugConnection> connection2(new QQmlDebugConnection()); + QScopedPointer<QQmlDebugProcess> process2( + new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + + "/qmlscene", this)); - process2->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") << testFile("test.qml")); + process2->start(QStringList() << QLatin1String("-qmljsdebugger=port:3782,3792") + << testFile("test.qml")); if (!process2->waitForSessionStart()) QFAIL("could not launch application, or did not get 'Waiting for connection'."); @@ -131,11 +137,6 @@ void tst_QQmlDebugService::checkPortRange() connection2->connectToHost("127.0.0.1", port2); if (!connection2->waitForConnected()) QFAIL("could not connect to host!"); - - delete connection1; - delete process1; - delete connection2; - delete process2; } void tst_QQmlDebugService::name() diff --git a/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro b/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro index 40ec1230d6..73455bd903 100644 --- a/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro +++ b/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro @@ -4,13 +4,11 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmlenginecontrol.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/debugutil.pri) TESTDATA = data/* -QT += core qml testlib testlib-private gui-private core-private +QT += core qml testlib gui-private core-private OTHER_FILES += \ data/test.qml \ diff --git a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp index 2c515d7cf5..18ba133876 100644 --- a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp +++ b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp @@ -35,12 +35,8 @@ #include <private/qqmlenginecontrolclient_p.h> #include <QtTest/qtest.h> -#include <private/qtestresult_p.h> #include <QtCore/qlibraryinfo.h> -#define STR_PORT_FROM "13773" -#define STR_PORT_TO "13783" - class QQmlEngineBlocker : public QObject { Q_OBJECT @@ -65,77 +61,37 @@ void QQmlEngineBlocker::blockEngine(int engineId, const QString &name) static_cast<QQmlEngineControlClient *>(parent())->blockEngine(engineId); } -class tst_QQmlEngineControl : public QQmlDataTest +class tst_QQmlEngineControl : public QQmlDebugTest { Q_OBJECT -public: - tst_QQmlEngineControl() - : m_process(0) - , m_connection(0) - , m_client(0) - {} - private: - QQmlDebugProcess *m_process; - QQmlDebugConnection *m_connection; - QQmlEngineControlClient *m_client; + ConnectResult connect(const QString &testFile, bool restrictServices); + QList<QQmlDebugClient *> createClients() override; - void connect(const QString &testFile, bool restrictServices); void engine_data(); + QPointer<QQmlEngineControlClient> m_client; private slots: - void cleanup(); - void startEngine_data(); void startEngine(); void stopEngine_data(); void stopEngine(); }; -void tst_QQmlEngineControl::connect(const QString &testFile, bool restrictServices) +QQmlDebugTest::ConnectResult tst_QQmlEngineControl::connect(const QString &file, + bool restrictServices) { - const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; - QStringList arguments; - 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); - - m_process = new QQmlDebugProcess(executable, this); - m_process->start(QStringList() << arguments); - QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); - - m_connection = new QQmlDebugConnection(); - m_client = new QQmlEngineControlClient(m_connection); - new QQmlEngineBlocker(m_client); - QList<QQmlDebugClient *> others = QQmlDebugTest::createOtherClients(m_connection); - - 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); + return QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", + restrictServices ? QStringLiteral("EngineControl") : QString(), + testFile(file), true); } -void tst_QQmlEngineControl::cleanup() +QList<QQmlDebugClient *> tst_QQmlEngineControl::createClients() { - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << (m_process ? m_process->state() : QLatin1String("null")); - qDebug() << "Application Output:" << (m_process ? m_process->output() : QLatin1String("null")); - qDebug() << "Connection State:" << QQmlDebugTest::connectionStateString(m_connection); - qDebug() << "Client State:" << QQmlDebugTest::clientStateString(m_client); - } - delete m_process; - m_process = 0; - delete m_client; - m_client = 0; - delete m_connection; - m_connection = 0; + m_client = new QQmlEngineControlClient(m_connection); + new QQmlEngineBlocker(m_client); + return QList<QQmlDebugClient *>({m_client}); } void tst_QQmlEngineControl::engine_data() @@ -153,10 +109,7 @@ void tst_QQmlEngineControl::startEngine_data() void tst_QQmlEngineControl::startEngine() { QFETCH(bool, restrictMode); - - connect("test.qml", restrictMode); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect("test.qml", restrictMode), ConnectSuccess); QTRY_VERIFY(!m_client->blockedEngines().empty()); m_client->releaseEngine(m_client->blockedEngines().last()); @@ -174,9 +127,7 @@ void tst_QQmlEngineControl::stopEngine() { QFETCH(bool, restrictMode); - connect("exit.qml", restrictMode); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect("exit.qml", restrictMode), ConnectSuccess); QTRY_VERIFY(!m_client->blockedEngines().empty()); m_client->releaseEngine(m_client->blockedEngines().last()); diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST new file mode 100644 index 0000000000..5fb1dc193b --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/BLACKLIST @@ -0,0 +1,2 @@ +# QTQAINFRA-1334 +windows gcc diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro index b8b4c3fc8b..5f58e5ec7f 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro @@ -1,13 +1,11 @@ CONFIG += testcase TARGET = tst_qqmlenginedebuginspectorintegration -QT += qml testlib testlib-private gui-private core-private +QT += qml testlib gui-private core-private osx:CONFIG -= app_bundle SOURCES += tst_qqmlenginedebuginspectorintegration.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/qqmlinspectorclient.pri) include(../shared/qqmlenginedebugclient.pri) include(../shared/debugutil.pri) diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index aba9eb39ab..249416a3b9 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -34,7 +34,6 @@ #include <private/qqmldebugconnection_p.h> #include <QtTest/qtest.h> -#include <private/qtestresult_p.h> #include <QtTest/qsignalspy.h> #include <QtNetwork/qhostaddress.h> #include <QtCore/qtimer.h> @@ -42,35 +41,21 @@ #include <QtCore/qthread.h> #include <QtCore/qlibraryinfo.h> -#define STR_PORT_FROM "3776" -#define STR_PORT_TO "3786" - -class tst_QQmlEngineDebugInspectorIntegration : public QQmlDataTest +class tst_QQmlEngineDebugInspectorIntegration : public QQmlDebugTest { Q_OBJECT -public: - tst_QQmlEngineDebugInspectorIntegration() - : m_process(0) - , m_inspectorClient(0) - , m_engineDebugClient(0) - , m_recipient(0) - { - } - - private: - void init(bool restrictServices); + ConnectResult init(bool restrictServices); + QList<QQmlDebugClient *> createClients() override; + QmlDebugObjectReference findRootObject(); - QQmlDebugProcess *m_process; - QQmlInspectorClient *m_inspectorClient; - QQmlEngineDebugClient *m_engineDebugClient; - QQmlInspectorResultRecipient *m_recipient; + QPointer<QQmlInspectorClient> m_inspectorClient; + QPointer<QQmlEngineDebugClient> m_engineDebugClient; + QPointer<QQmlInspectorResultRecipient> m_recipient; private slots: - void cleanup(); - void connect_data(); void connect(); void objectLocationLookup(); @@ -100,53 +85,22 @@ QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject( return m_engineDebugClient->object(); } -void tst_QQmlEngineDebugInspectorIntegration::init(bool restrictServices) +QQmlDebugTest::ConnectResult tst_QQmlEngineDebugInspectorIntegration::init(bool restrictServices) { - 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()); - - m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", - this); - m_process->start(QStringList() << argument << testFile("qtquick2.qml")); - QVERIFY2(m_process->waitForSessionStart(), - "Could not launch application, or did not get 'Waiting for connection'."); - - QQmlDebugConnection *m_connection = new QQmlDebugConnection(this); - m_inspectorClient = new QQmlInspectorClient(m_connection); - m_engineDebugClient = new QQmlEngineDebugClient(m_connection); - m_recipient = new QQmlInspectorResultRecipient(this); - QObject::connect(m_inspectorClient, &QQmlInspectorClient::responseReceived, - m_recipient, &QQmlInspectorResultRecipient::recordResponse); - - QList<QQmlDebugClient *> others = QQmlDebugTest::createOtherClients(m_connection); - - 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); - - QTRY_COMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled); - QTRY_COMPARE(m_engineDebugClient->state(), QQmlDebugClient::Enabled); + return QQmlDebugTest::connect( + QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", + restrictServices ? QStringLiteral("QmlDebugger,QmlInspector") : QString(), + testFile("qtquick2.qml"), true); } -void tst_QQmlEngineDebugInspectorIntegration::cleanup() +QList<QQmlDebugClient *> tst_QQmlEngineDebugInspectorIntegration::createClients() { - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << m_process->state(); - qDebug() << "Application Output:" << m_process->output(); - } - delete m_process; - m_process = 0; - delete m_engineDebugClient; - m_engineDebugClient = 0; - delete m_inspectorClient; - m_inspectorClient = 0; - delete m_recipient; - m_recipient = 0; + m_inspectorClient = new QQmlInspectorClient(m_connection); + m_engineDebugClient = new QQmlEngineDebugClient(m_connection); + m_recipient = new QQmlInspectorResultRecipient(m_inspectorClient); + QObject::connect(m_inspectorClient.data(), &QQmlInspectorClient::responseReceived, + m_recipient.data(), &QQmlInspectorResultRecipient::recordResponse); + return QList<QQmlDebugClient *>({m_inspectorClient, m_engineDebugClient}); } void tst_QQmlEngineDebugInspectorIntegration::connect_data() @@ -159,14 +113,12 @@ void tst_QQmlEngineDebugInspectorIntegration::connect_data() void tst_QQmlEngineDebugInspectorIntegration::connect() { QFETCH(bool, restrictMode); - init(restrictMode); + QCOMPARE(init(restrictMode), ConnectSuccess); } void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup() { - init(true); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(init(true), ConnectSuccess); bool success = false; QmlDebugObjectReference rootObject = findRootObject(); @@ -192,9 +144,7 @@ void tst_QQmlEngineDebugInspectorIntegration::objectLocationLookup() void tst_QQmlEngineDebugInspectorIntegration::select() { - init(true); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(init(true), ConnectSuccess); QmlDebugObjectReference rootObject = findRootObject(); QList<int> childIds; @@ -212,9 +162,7 @@ void tst_QQmlEngineDebugInspectorIntegration::select() void tst_QQmlEngineDebugInspectorIntegration::createObject() { - init(true); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(init(true), ConnectSuccess); QString qml = QLatin1String("Rectangle {\n" " id: xxxyxxx\n" @@ -241,9 +189,7 @@ void tst_QQmlEngineDebugInspectorIntegration::createObject() void tst_QQmlEngineDebugInspectorIntegration::moveObject() { - init(true); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(init(true), ConnectSuccess); QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled); QmlDebugObjectReference rootObject = findRootObject(); @@ -268,9 +214,7 @@ void tst_QQmlEngineDebugInspectorIntegration::moveObject() void tst_QQmlEngineDebugInspectorIntegration::destroyObject() { - init(true); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(init(true), ConnectSuccess); QCOMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled); QmlDebugObjectReference rootObject = findRootObject(); diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro index 06250d9940..33ee023c06 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro @@ -5,8 +5,6 @@ osx:CONFIG -= app_bundle SOURCES += \ tst_qqmlenginedebugservice.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/qqmlenginedebugclient.pri) include(../shared/debugutil.pri) diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro index ee5f3c708a..fd07255ae5 100644 --- a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro +++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro @@ -6,8 +6,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmlinspector.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/qqmlinspectorclient.pri) include(../shared/debugutil.pri) diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 9461922eff..a4cf932ee1 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -40,64 +40,32 @@ #include <QtCore/qlibraryinfo.h> #include <QtNetwork/qhostaddress.h> -#define STR_PORT_FROM "3772" -#define STR_PORT_TO "3782" - - -class tst_QQmlInspector : public QQmlDataTest +class tst_QQmlInspector : public QQmlDebugTest { Q_OBJECT private: - void startQmlProcess(const QString &qmlFile, bool restrictMode = true); + ConnectResult startQmlProcess(const QString &qmlFile, bool restrictMode = true); void checkAnimationSpeed(int targetMillisPerDegree); + QList<QQmlDebugClient *> createClients() override; + QQmlDebugProcess *createProcess(const QString &executable) override; -private: - QScopedPointer<QQmlDebugProcess> m_process; - QScopedPointer<QQmlDebugConnection> m_connection; - QScopedPointer<QQmlInspectorClient> m_client; - QScopedPointer<QQmlInspectorResultRecipient> m_recipient; + QPointer<QQmlInspectorClient> m_client; + QPointer<QQmlInspectorResultRecipient> m_recipient; private slots: - void cleanup(); - void connect_data(); void connect(); void setAnimationSpeed(); void showAppOnTop(); }; -void tst_QQmlInspector::startQmlProcess(const QString &qmlFile, bool restrictServices) +QQmlDebugTest::ConnectResult tst_QQmlInspector::startQmlProcess(const QString &qmlFile, + bool restrictServices) { - 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()); - - m_process.reset(new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + - "/qml")); - // Make sure the animation timing is exact - m_process->addEnvironment(QLatin1String("QSG_RENDER_LOOP=basic")); - m_process->start(QStringList() << argument << testFile(qmlFile)); - QVERIFY2(m_process->waitForSessionStart(), - "Could not launch application, or did not get 'Waiting for connection'."); - - m_client.reset(); - m_connection.reset(new QQmlDebugConnection); - m_client.reset(new QQmlInspectorClient(m_connection.data())); - - m_recipient.reset(new QQmlInspectorResultRecipient); - QObject::connect(m_client.data(), &QQmlInspectorClient::responseReceived, - m_recipient.data(), &QQmlInspectorResultRecipient::recordResponse); - - QList<QQmlDebugClient *> others = QQmlDebugTest::createOtherClients(m_connection.data()); - - m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - foreach (QQmlDebugClient *other, others) - QCOMPARE(other->state(), restrictServices ? QQmlDebugClient::Unavailable : - QQmlDebugClient::Enabled); - qDeleteAll(others); + return QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml", + restrictServices ? QStringLiteral("QmlInspector") : QString(), + testFile(qmlFile), true); } void tst_QQmlInspector::checkAnimationSpeed(int targetMillisPerDegree) @@ -114,8 +82,7 @@ void tst_QQmlInspector::checkAnimationSpeed(int targetMillisPerDegree) QString output = m_process->output(); int position = output.length(); do { - QVERIFY(QQmlDebugTest::waitForSignal(m_process.data(), - SIGNAL(readyReadStandardOutput()))); + QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); output = m_process->output(); } while (!output.mid(position).contains(markerString)); @@ -144,12 +111,21 @@ void tst_QQmlInspector::checkAnimationSpeed(int targetMillisPerDegree) .arg(targetMillisPerDegree).toLocal8Bit().constData()); } -void tst_QQmlInspector::cleanup() +QList<QQmlDebugClient *> tst_QQmlInspector::createClients() { - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << m_process->state(); - qDebug() << "Application Output:" << m_process->output(); - } + m_client = new QQmlInspectorClient(m_connection); + m_recipient = new QQmlInspectorResultRecipient(m_client); + QObject::connect(m_client.data(), &QQmlInspectorClient::responseReceived, + m_recipient.data(), &QQmlInspectorResultRecipient::recordResponse); + return QList<QQmlDebugClient *>({m_client}); +} + +QQmlDebugProcess *tst_QQmlInspector::createProcess(const QString &executable) +{ + QQmlDebugProcess *process = QQmlDebugTest::createProcess(executable); + // Make sure the animation timing is exact + process->addEnvironment(QLatin1String("QSG_RENDER_LOOP=basic")); + return process; } void tst_QQmlInspector::connect_data() @@ -166,7 +142,7 @@ void tst_QQmlInspector::connect() { QFETCH(QString, file); QFETCH(bool, restrictMode); - startQmlProcess(file, restrictMode); + QCOMPARE(startQmlProcess(file, restrictMode), ConnectSuccess); QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); @@ -181,7 +157,7 @@ void tst_QQmlInspector::connect() void tst_QQmlInspector::showAppOnTop() { - startQmlProcess("qtquick2.qml"); + QCOMPARE(startQmlProcess("qtquick2.qml"), ConnectSuccess); QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); @@ -196,7 +172,7 @@ void tst_QQmlInspector::showAppOnTop() void tst_QQmlInspector::setAnimationSpeed() { - startQmlProcess("qtquick2.qml"); + QCOMPARE(startQmlProcess("qtquick2.qml"), ConnectSuccess); QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); checkAnimationSpeed(10); diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST b/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST new file mode 100644 index 0000000000..5fb1dc193b --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/BLACKLIST @@ -0,0 +1,2 @@ +# QTQAINFRA-1334 +windows gcc diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/qstr.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/qstr.qml new file mode 100644 index 0000000000..09dcd34b5c --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/qstr.qml @@ -0,0 +1,9 @@ +import QtQml 2.0 + +Timer { + property string stuff: qsTr("foo") + + running: true + interval: 1 + onTriggered: Qt.quit(); +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index 56840d5c8f..7c78b5fcb3 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -4,8 +4,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmlprofilerservice.cpp -INCLUDEPATH += ../shared -include(../../../shared/util.pri) include(../shared/debugutil.pri) TESTDATA = data/* @@ -22,4 +20,5 @@ OTHER_FILES += \ data/signalSourceLocation.qml \ data/javascript.qml \ data/timer.qml \ + data/qstr.qml \ data/memory.qml diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index bc6c51707a..f60e821071 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -36,9 +36,6 @@ #include <private/qtestresult_p.h> #include <QtCore/qlibraryinfo.h> -#define STR_PORT_FROM "13773" -#define STR_PORT_TO "13783" - struct QQmlProfilerData { QQmlProfilerData(qint64 time = -2, int messageType = -1, int detailType = -1, @@ -258,24 +255,11 @@ void QQmlProfilerTestClient::complete() emit recordingFinished(); } -class tst_QQmlProfilerService : public QQmlDataTest +class tst_QQmlProfilerService : public QQmlDebugTest { Q_OBJECT -public: - tst_QQmlProfilerService() - : m_process(0) - , m_connection(0) - , m_client(0) - { - } - - private: - QQmlDebugProcess *m_process; - QQmlDebugConnection *m_connection; - QQmlProfilerTestClient *m_client; - enum MessageListType { MessageListQML, MessageListJavaScript, @@ -294,14 +278,17 @@ private: CheckAll = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckDataEndsWith }; - void connect(bool block, const QString &testFile, bool restrictServices = true); + ConnectResult connect(bool block, const QString &testFile, bool restrictServices = true); void checkTraceReceived(); void checkJsHeap(); bool verify(MessageListType type, int expectedPosition, const QQmlProfilerData &expected, quint32 checks); + QList<QQmlDebugClient *> createClients() override; + QPointer<QQmlProfilerTestClient> m_client; + private slots: - void cleanup(); + void cleanup() override; void connect_data(); void connect(); @@ -312,39 +299,19 @@ private slots: void signalSourceLocation(); void javascript(); void flushInterval(); + void translationBinding(); void memory(); }; #define VERIFY(type, position, expected, checks) QVERIFY(verify(type, position, expected, checks)) -void tst_QQmlProfilerService::connect(bool block, const QString &testFile, bool restrictServices) +QQmlDebugTest::ConnectResult tst_QQmlProfilerService::connect(bool block, const QString &file, + bool restrictServices) { // ### Still using qmlscene due to QTBUG-33377 - const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; - QStringList arguments; - 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); - QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); - - m_connection = new QQmlDebugConnection(); - m_client = new QQmlProfilerTestClient(m_connection); - QList<QQmlDebugClient *> others = QQmlDebugTest::createOtherClients(m_connection); - - 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); + return QQmlDebugTest::connect(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", + restrictServices ? QStringLiteral("CanvasFrameRate") : QString(), + testFile(file), block); } void tst_QQmlProfilerService::checkTraceReceived() @@ -479,6 +446,12 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty return false; } +QList<QQmlDebugClient *> tst_QQmlProfilerService::createClients() +{ + m_client = new QQmlProfilerTestClient(m_connection); + return QList<QQmlDebugClient *>({m_client}); +} + void tst_QQmlProfilerService::cleanup() { if (m_client && QTest::currentTestFailed()) { @@ -516,17 +489,9 @@ void tst_QQmlProfilerService::cleanup() qDebug() << i++ << data.time << data.messageType << data.detailType; } qDebug() << " "; - qDebug() << "Process State:" << (m_process ? m_process->state() : QLatin1String("null")); - qDebug() << "Application Output:" << (m_process ? m_process->output() : QLatin1String("null")); - qDebug() << "Connection State:" << QQmlDebugTest::connectionStateString(m_connection); - qDebug() << "Client State:" << QQmlDebugTest::clientStateString(m_client); } - delete m_process; - m_process = 0; - delete m_client; - m_client = 0; - delete m_connection; - m_connection = 0; + + QQmlDebugTest::cleanup(); } void tst_QQmlProfilerService::connect_data() @@ -550,7 +515,7 @@ void tst_QQmlProfilerService::connect() QFETCH(bool, restrictMode); QFETCH(bool, traceEnabled); - connect(blockMode, "test.qml", restrictMode); + QCOMPARE(connect(blockMode, "test.qml", restrictMode), ConnectSuccess); // if the engine is waiting, then the first message determines if it starts with trace enabled if (!traceEnabled) @@ -563,9 +528,7 @@ void tst_QQmlProfilerService::connect() void tst_QQmlProfilerService::pixmapCacheData() { - connect(true, "pixmapCacheTest.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "pixmapCacheTest.qml"), ConnectSuccess); m_client->sendRecordingStatus(true); QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); @@ -602,9 +565,7 @@ void tst_QQmlProfilerService::pixmapCacheData() void tst_QQmlProfilerService::scenegraphData() { - connect(true, "scenegraphTest.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "scenegraphTest.qml"), ConnectSuccess); m_client->sendRecordingStatus(true); @@ -661,9 +622,7 @@ void tst_QQmlProfilerService::scenegraphData() void tst_QQmlProfilerService::profileOnExit() { - connect(true, "exit.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "exit.qml"), ConnectSuccess); m_client->sendRecordingStatus(true); @@ -673,9 +632,7 @@ void tst_QQmlProfilerService::profileOnExit() void tst_QQmlProfilerService::controlFromJS() { - connect(true, "controlFromJS.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "controlFromJS.qml"), ConnectSuccess); m_client->sendRecordingStatus(false); checkTraceReceived(); @@ -684,9 +641,7 @@ void tst_QQmlProfilerService::controlFromJS() void tst_QQmlProfilerService::signalSourceLocation() { - connect(true, "signalSourceLocation.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "signalSourceLocation.qml"), ConnectSuccess); m_client->sendRecordingStatus(true); while (!(m_process->output().contains(QLatin1String("500")))) @@ -709,9 +664,7 @@ void tst_QQmlProfilerService::signalSourceLocation() void tst_QQmlProfilerService::javascript() { - connect(true, "javascript.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "javascript.qml"), ConnectSuccess); m_client->sendRecordingStatus(true); while (!(m_process->output().contains(QLatin1String("done")))) @@ -741,9 +694,7 @@ void tst_QQmlProfilerService::javascript() void tst_QQmlProfilerService::flushInterval() { - connect(true, "timer.qml"); - if (QTest::currentTestFailed() || QTestResult::skipCurrentTest()) - return; + QCOMPARE(connect(true, "timer.qml"), ConnectSuccess); m_client->sendRecordingStatus(true, -1, 1); @@ -757,6 +708,25 @@ void tst_QQmlProfilerService::flushInterval() checkJsHeap(); } +void tst_QQmlProfilerService::translationBinding() +{ + QCOMPARE(connect(true, "qstr.qml"), ConnectSuccess); + + m_client->sendRecordingStatus(true); + + checkTraceReceived(); + checkJsHeap(); + + QQmlProfilerData expected(0, QQmlProfilerDefinitions::RangeStart, + QQmlProfilerDefinitions::Binding); + VERIFY(MessageListQML, 8, expected, + CheckDetailType | CheckMessageType); + + expected.messageType = QQmlProfilerDefinitions::RangeEnd; + VERIFY(MessageListQML, 10, expected, + CheckDetailType | CheckMessageType); +} + void tst_QQmlProfilerService::memory() { connect(true, "memory.qml"); diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 441f8c113f..fd74135727 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -630,7 +630,7 @@ void tst_qv4debugger::readObject() QCOMPARE(b_tail_head.value("value").toString(), QStringLiteral("asdf")); QJsonObject b_tail_tail = b_tail_props.at(1).toObject(); QCOMPARE(b_tail_tail.value("name").toString(), QStringLiteral("tail")); - QCOMPARE(b_tail_tail.value("type").toString(), QStringLiteral("null")); + QCOMPARE(b_tail_tail.value("type").toString(), QStringLiteral("object")); QVERIFY(b_tail_tail.value("value").isNull()); } diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index d31efc84cf..40e51f3a05 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -305,3 +305,115 @@ void QQmlDebugProcess::processError(QProcess::ProcessError error) m_eventLoop.exit(); } + +template<typename F> +struct Finalizer { + F m_lambda; + Finalizer(F &&lambda) : m_lambda(std::forward<F>(lambda)) {} + ~Finalizer() { m_lambda(); } +}; + +template<typename F> +static Finalizer<F> defer(F &&lambda) +{ + return Finalizer<F>(std::forward<F>(lambda)); +} + +QQmlDebugTest::ConnectResult QQmlDebugTest::connect( + const QString &executable, const QString &services, const QString &extraArgs, + bool block) +{ + QStringList arguments; + arguments << QString::fromLatin1("-qmljsdebugger=port:13773,13783%3%4") + .arg(block ? QStringLiteral(",block") : QString()) + .arg(services.isEmpty() ? services : (QStringLiteral(",services:") + services)) + << extraArgs; + + m_process = createProcess(executable); + if (!m_process) + return ProcessFailed; + + m_process->start(QStringList() << arguments); + if (!m_process->waitForSessionStart()) + return SessionFailed; + + m_connection = createConnection(); + if (!m_connection) + return ConnectionFailed; + + m_clients = createClients(); + if (m_clients.contains(nullptr)) + return ClientsFailed; + + auto allEnabled = [this]() { + for (QQmlDebugClient *client : m_clients) { + if (client->state() != QQmlDebugClient::Enabled) + return false; + } + return true; + }; + + QList<QQmlDebugClient *> others = createOtherClients(m_connection); + auto deleter = defer([&others]() { qDeleteAll(others); }); + Q_UNUSED(deleter); + + const int port = m_process->debugPort(); + m_connection->connectToHost(QLatin1String("127.0.0.1"), port); + for (int tries = 0; tries < 100 && !allEnabled(); ++tries) + QTest::qWait(50); + if (!allEnabled()) + return EnableFailed; + + const QQmlDebugClient::State expectedState = services.isEmpty() ? QQmlDebugClient::Enabled + : QQmlDebugClient::Unavailable; + for (QQmlDebugClient *other : others) { + if (other->state() != expectedState) + return RestrictFailed; + } + + return ConnectSuccess; +} + +QList<QQmlDebugClient *> QQmlDebugTest::createClients() +{ + return QList<QQmlDebugClient *>(); +} + +QQmlDebugProcess *QQmlDebugTest::createProcess(const QString &executable) +{ + return new QQmlDebugProcess(executable, this); +} + +QQmlDebugConnection *QQmlDebugTest::createConnection() +{ + return new QQmlDebugConnection(this); +} + +void QQmlDebugTest::cleanup() +{ + if (QTest::currentTestFailed()) { + const QString null = QStringLiteral("null"); + + qDebug() << "Process State:" << (m_process ? m_process->state() : null); + qDebug() << "Application Output:" << (m_process ? m_process->output() : null); + qDebug() << "Connection State:" << QQmlDebugTest::connectionStateString(m_connection); + for (QQmlDebugClient *client : m_clients) { + if (client) + qDebug() << client->name() << "State:" << QQmlDebugTest::clientStateString(client); + else + qDebug() << "Failed Client:" << null; + } + } + + qDeleteAll(m_clients); + m_clients.clear(); + + delete m_connection; + m_connection = nullptr; + + if (m_process) { + m_process->stop(); + delete m_process; + m_process = nullptr; + } +} diff --git a/tests/auto/qml/debugger/shared/debugutil.pri b/tests/auto/qml/debugger/shared/debugutil.pri index 1983f3583e..44e8e0f999 100644 --- a/tests/auto/qml/debugger/shared/debugutil.pri +++ b/tests/auto/qml/debugger/shared/debugutil.pri @@ -1,4 +1,7 @@ QT += qmldebug-private +INCLUDEPATH += $$PWD +include($$PWD/../../../shared/util.pri) + HEADERS += $$PWD/debugutil_p.h SOURCES += $$PWD/debugutil.cpp diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h index 1ec0a6513d..f1b25d5f6d 100644 --- a/tests/auto/qml/debugger/shared/debugutil_p.h +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -41,6 +41,7 @@ // We mean it. // +#include <../../../shared/util.h> #include <private/qqmldebugclient_p.h> #include <QtCore/qeventloop.h> @@ -51,13 +52,40 @@ #include <QtTest/qtest.h> #include <QtQml/qqmlengine.h> -class QQmlDebugTest +class QQmlDebugProcess; +class QQmlDebugTest : public QQmlDataTest { + Q_OBJECT public: static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); static QList<QQmlDebugClient *> createOtherClients(QQmlDebugConnection *connection); static QString clientStateString(const QQmlDebugClient *client); static QString connectionStateString(const QQmlDebugConnection *connection); + +protected: + enum ConnectResult { + ConnectSuccess, + ProcessFailed, + SessionFailed, + ConnectionFailed, + ClientsFailed, + EnableFailed, + RestrictFailed + }; + + ConnectResult connect(const QString &executable, const QString &services, + const QString &extraArgs, bool block); + + virtual QQmlDebugProcess *createProcess(const QString &executable); + virtual QQmlDebugConnection *createConnection(); + virtual QList<QQmlDebugClient *> createClients(); + + QQmlDebugProcess *m_process = nullptr; + QQmlDebugConnection *m_connection = nullptr; + QList<QQmlDebugClient *> m_clients; + +protected slots: + virtual void cleanup(); }; class QQmlDebugTestClient : public QQmlDebugClient |