From ebb65bc084d44cfc96efb29abf0607616095f757 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 2 Feb 2012 12:06:06 +0100 Subject: Debugger: Rename QDeclarativeDebugTrace to QDeclarativeProfilerService This avoids naming confusion with QDeclarativeTrace + makes it in line with QV8ProfilerService. Change-Id: Ifd801655044cff3ffdb2a9695ffc9868eeb51663 Reviewed-by: Christiaan Janssen --- tests/auto/declarative/debugger/debugger.pro | 2 +- .../debugger/qdeclarativedebugtrace/data/exit.qml | 9 - .../debugger/qdeclarativedebugtrace/data/test.qml | 5 - .../qdeclarativedebugtrace.pro | 15 - .../tst_qdeclarativedebugtrace.cpp | 310 --------------------- .../qdeclarativeprofilerservice/data/exit.qml | 9 + .../qdeclarativeprofilerservice/data/test.qml | 5 + .../qdeclarativeprofilerservice.pro | 15 + .../tst_qdeclarativeprofilerservice.cpp | 310 +++++++++++++++++++++ 9 files changed, 340 insertions(+), 340 deletions(-) delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugtrace/data/test.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugtrace/qdeclarativedebugtrace.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp create mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml create mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml create mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro create mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp (limited to 'tests/auto') diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro index 6d7548cec8..314f0d1b78 100644 --- a/tests/auto/declarative/debugger/debugger.pro +++ b/tests/auto/declarative/debugger/debugger.pro @@ -6,7 +6,7 @@ PRIVATETESTS += \ qdeclarativedebugservice \ qdeclarativedebugjs \ qdeclarativeinspector \ - qdeclarativedebugtrace \ + qdeclarativeprofilerservice \ qpacketprotocol \ qv8profilerservice \ qdebugmessageservice diff --git a/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml b/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml deleted file mode 100644 index b250524caa..0000000000 --- a/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Item { - Timer { - running: true - interval: 1 - onTriggered: Qt.quit(); - } -} diff --git a/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/test.qml b/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/test.qml deleted file mode 100644 index 9c36e13c5b..0000000000 --- a/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/test.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - -} diff --git a/tests/auto/declarative/debugger/qdeclarativedebugtrace/qdeclarativedebugtrace.pro b/tests/auto/declarative/debugger/qdeclarativedebugtrace/qdeclarativedebugtrace.pro deleted file mode 100644 index 487c63aaca..0000000000 --- a/tests/auto/declarative/debugger/qdeclarativedebugtrace/qdeclarativedebugtrace.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativedebugtrace -macx:CONFIG -= app_bundle - -HEADERS += ../shared/debugutil_p.h - -SOURCES += tst_qdeclarativedebugtrace.cpp \ - ../shared/debugutil.cpp -OTHER_FILES += data/test.qml - -include (../../../shared/util.pri) - -CONFIG += parallel_test declarative_debug - -QT += declarative-private testlib diff --git a/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp b/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp deleted file mode 100644 index f0a660c146..0000000000 --- a/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "QtDeclarative/private/qdeclarativedebugtrace_p.h" -#include "../shared/debugutil_p.h" -#include "../../../shared/util.h" - -#define PORT 13773 -#define STR_PORT "13773" - -class QDeclarativeDebugTraceClient : public QDeclarativeDebugClient -{ - Q_OBJECT - -public: - QDeclarativeDebugTraceClient(QDeclarativeDebugConnection *connection) - : QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), connection) - { - } - - QList traceMessages; - - void setTraceState(bool enabled) { - QByteArray message; - QDataStream stream(&message, QIODevice::WriteOnly); - stream << enabled; - sendMessage(message); - } - -signals: - void complete(); - -protected: - void messageReceived(const QByteArray &message); -}; - -class tst_QDeclarativeDebugTrace : public QDeclarativeDataTest -{ - Q_OBJECT - -public: - tst_QDeclarativeDebugTrace() - : m_process(0) - , m_connection(0) - , m_client(0) - { - } - -private: - QDeclarativeDebugProcess *m_process; - QDeclarativeDebugConnection *m_connection; - QDeclarativeDebugTraceClient *m_client; - - void connect(bool block, const QString &testFile); - -private slots: - void cleanup(); - - void blockingConnectWithTraceEnabled(); - void blockingConnectWithTraceDisabled(); - void nonBlockingConnect(); - void profileOnExit(); -}; - -void QDeclarativeDebugTraceClient::messageReceived(const QByteArray &message) -{ - QByteArray msg = message; - QDataStream stream(&msg, QIODevice::ReadOnly); - - - QDeclarativeDebugData data; - data.time = -2; - data.messageType = -1; - data.detailType = -1; - data.line = -1; - data.framerate = -1; - data.animationcount = -1; - - stream >> data.time >> data.messageType; - - QVERIFY(data.time >= -1); - - switch (data.messageType) { - case (QDeclarativeDebugTrace::Event): { - stream >> data.detailType; - - switch (data.detailType) { - case QDeclarativeDebugTrace::AnimationFrame: { - stream >> data.framerate >> data.animationcount; - QVERIFY(data.framerate != -1); - QVERIFY(data.animationcount != -1); - break; - } - case QDeclarativeDebugTrace::FramePaint: - case QDeclarativeDebugTrace::Mouse: - case QDeclarativeDebugTrace::Key: - case QDeclarativeDebugTrace::StartTrace: - case QDeclarativeDebugTrace::EndTrace: - break; - default: { - QString failMsg = QString("Unknown event type:") + data.detailType; - QFAIL(qPrintable(failMsg)); - break; - } - } - break; - } - case QDeclarativeDebugTrace::Complete: { - emit complete(); - return; - } - case QDeclarativeDebugTrace::RangeStart: { - stream >> data.detailType; - QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeDebugTrace::MaximumRangeType); - break; - } - case QDeclarativeDebugTrace::RangeEnd: { - stream >> data.detailType; - QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeDebugTrace::MaximumRangeType); - break; - } - case QDeclarativeDebugTrace::RangeData: { - stream >> data.detailType >> data.detailData; - QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeDebugTrace::MaximumRangeType); - break; - } - case QDeclarativeDebugTrace::RangeLocation: { - stream >> data.detailType >> data.detailData >> data.line >> data.column; - QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeDebugTrace::MaximumRangeType); - QVERIFY(data.line >= -2); - break; - } - default: - QString failMsg = QString("Unknown message type:") + data.messageType; - QFAIL(qPrintable(failMsg)); - break; - } - QVERIFY(stream.atEnd()); - traceMessages.append(data); -} - -void tst_QDeclarativeDebugTrace::connect(bool block, const QString &testFile) -{ - const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; - QStringList arguments; - - if (block) - arguments << QString("-qmljsdebugger=port:"STR_PORT",block"); - else - arguments << QString("-qmljsdebugger=port:"STR_PORT); - - arguments << QDeclarativeDataTest::instance()->testFile(testFile); - - m_process = new QDeclarativeDebugProcess(executable); - m_process->start(QStringList() << arguments); - if (!m_process->waitForSessionStart()) { - QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg( - executable, m_process->output()); - QFAIL(qPrintable(failMsg)); - } - - QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection(); - m_client = new QDeclarativeDebugTraceClient(m_connection); - - m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); -} - -void tst_QDeclarativeDebugTrace::cleanup() -{ - delete m_process; - delete m_connection; - delete m_client; -} - -void tst_QDeclarativeDebugTrace::blockingConnectWithTraceEnabled() -{ - connect(true, "test.qml"); - QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); - - m_client->setTraceState(true); - m_client->setTraceState(false); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } - - QVERIFY(m_client->traceMessages.count()); - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeDebugTrace::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeDebugTrace::EndTrace); -} - -void tst_QDeclarativeDebugTrace::blockingConnectWithTraceDisabled() -{ - connect(true, "test.qml"); - QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); - - m_client->setTraceState(false); - m_client->setTraceState(true); - m_client->setTraceState(false); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } - - QVERIFY(m_client->traceMessages.count()); - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeDebugTrace::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeDebugTrace::EndTrace); -} - -void tst_QDeclarativeDebugTrace::nonBlockingConnect() -{ - connect(false, "test.qml"); - QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); - - m_client->setTraceState(true); - m_client->setTraceState(false); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeDebugTrace::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeDebugTrace::EndTrace); -} - -void tst_QDeclarativeDebugTrace::profileOnExit() -{ - connect(true, "exit.qml"); - QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); - - m_client->setTraceState(true); - - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } - - // must start with "StartTrace" - QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeDebugTrace::StartTrace); - - // must end with "EndTrace" - QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeDebugTrace::Event); - QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeDebugTrace::EndTrace); -} - -QTEST_MAIN(tst_QDeclarativeDebugTrace) - -#include "tst_qdeclarativedebugtrace.moc" diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml new file mode 100644 index 0000000000..b250524caa --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Timer { + running: true + interval: 1 + onTriggered: Qt.quit(); + } +} diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml new file mode 100644 index 0000000000..9c36e13c5b --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro new file mode 100644 index 0000000000..564945faf7 --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qdeclarativeprofilerservice +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h + +SOURCES += tst_qdeclarativeprofilerservice.cpp \ + ../shared/debugutil.cpp +OTHER_FILES += data/test.qml + +include (../../../shared/util.pri) + +CONFIG += parallel_test declarative_debug + +QT += declarative-private testlib diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp new file mode 100644 index 0000000000..5de7b8621d --- /dev/null +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "QtDeclarative/private/qdeclarativeprofilerservice_p.h" +#include "../shared/debugutil_p.h" +#include "../../../shared/util.h" + +#define PORT 13773 +#define STR_PORT "13773" + +class QDeclarativeProfilerClient : public QDeclarativeDebugClient +{ + Q_OBJECT + +public: + QDeclarativeProfilerClient(QDeclarativeDebugConnection *connection) + : QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), connection) + { + } + + QList traceMessages; + + void setTraceState(bool enabled) { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << enabled; + sendMessage(message); + } + +signals: + void complete(); + +protected: + void messageReceived(const QByteArray &message); +}; + +class tst_QDeclarativeProfilerService : public QDeclarativeDataTest +{ + Q_OBJECT + +public: + tst_QDeclarativeProfilerService() + : m_process(0) + , m_connection(0) + , m_client(0) + { + } + +private: + QDeclarativeDebugProcess *m_process; + QDeclarativeDebugConnection *m_connection; + QDeclarativeProfilerClient *m_client; + + void connect(bool block, const QString &testFile); + +private slots: + void cleanup(); + + void blockingConnectWithTraceEnabled(); + void blockingConnectWithTraceDisabled(); + void nonBlockingConnect(); + void profileOnExit(); +}; + +void QDeclarativeProfilerClient::messageReceived(const QByteArray &message) +{ + QByteArray msg = message; + QDataStream stream(&msg, QIODevice::ReadOnly); + + + QDeclarativeProfilerData data; + data.time = -2; + data.messageType = -1; + data.detailType = -1; + data.line = -1; + data.framerate = -1; + data.animationcount = -1; + + stream >> data.time >> data.messageType; + + QVERIFY(data.time >= -1); + + switch (data.messageType) { + case (QDeclarativeProfilerService::Event): { + stream >> data.detailType; + + switch (data.detailType) { + case QDeclarativeProfilerService::AnimationFrame: { + stream >> data.framerate >> data.animationcount; + QVERIFY(data.framerate != -1); + QVERIFY(data.animationcount != -1); + break; + } + case QDeclarativeProfilerService::FramePaint: + case QDeclarativeProfilerService::Mouse: + case QDeclarativeProfilerService::Key: + case QDeclarativeProfilerService::StartTrace: + case QDeclarativeProfilerService::EndTrace: + break; + default: { + QString failMsg = QString("Unknown event type:") + data.detailType; + QFAIL(qPrintable(failMsg)); + break; + } + } + break; + } + case QDeclarativeProfilerService::Complete: { + emit complete(); + return; + } + case QDeclarativeProfilerService::RangeStart: { + stream >> data.detailType; + QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType); + break; + } + case QDeclarativeProfilerService::RangeEnd: { + stream >> data.detailType; + QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType); + break; + } + case QDeclarativeProfilerService::RangeData: { + stream >> data.detailType >> data.detailData; + QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType); + break; + } + case QDeclarativeProfilerService::RangeLocation: { + stream >> data.detailType >> data.detailData >> data.line >> data.column; + QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType); + QVERIFY(data.line >= -2); + break; + } + default: + QString failMsg = QString("Unknown message type:") + data.messageType; + QFAIL(qPrintable(failMsg)); + break; + } + QVERIFY(stream.atEnd()); + traceMessages.append(data); +} + +void tst_QDeclarativeProfilerService::connect(bool block, const QString &testFile) +{ + const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; + QStringList arguments; + + if (block) + arguments << QString("-qmljsdebugger=port:"STR_PORT",block"); + else + arguments << QString("-qmljsdebugger=port:"STR_PORT); + + arguments << QDeclarativeDataTest::instance()->testFile(testFile); + + m_process = new QDeclarativeDebugProcess(executable); + m_process->start(QStringList() << arguments); + if (!m_process->waitForSessionStart()) { + QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg( + executable, m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection(); + m_client = new QDeclarativeProfilerClient(m_connection); + + m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); +} + +void tst_QDeclarativeProfilerService::cleanup() +{ + delete m_process; + delete m_connection; + delete m_client; +} + +void tst_QDeclarativeProfilerService::blockingConnectWithTraceEnabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); + + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QVERIFY(m_client->traceMessages.count()); + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace); +} + +void tst_QDeclarativeProfilerService::blockingConnectWithTraceDisabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); + + m_client->setTraceState(false); + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QVERIFY(m_client->traceMessages.count()); + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace); +} + +void tst_QDeclarativeProfilerService::nonBlockingConnect() +{ + connect(false, "test.qml"); + QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); + + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace); +} + +void tst_QDeclarativeProfilerService::profileOnExit() +{ + connect(true, "exit.qml"); + QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); + + m_client->setTraceState(true); + + if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace); +} + +QTEST_MAIN(tst_QDeclarativeProfilerService) + +#include "tst_qdeclarativeprofilerservice.moc" -- cgit v1.2.3