From 784d867d2b79fcfdbf039456fcfe0692652fec52 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 17 Feb 2012 15:56:14 +0100 Subject: [PATCH] v8profiler: Actually submit data Fix regression introduced in 82dfecab3. Change-Id: Icd90c483b9b2fde8d4cf522f3a35368cd395b120 Reviewed-by: Christiaan Janssen --- src/declarative/debugger/qv8profilerservice.cpp | 2 + .../debugger/qv8profilerservice/data/console.qml | 14 ++++++ .../qv8profilerservice/tst_qv8profilerservice.cpp | 52 +++++++++++----------- 3 files changed, 43 insertions(+), 25 deletions(-) create mode 100644 tests/auto/declarative/debugger/qv8profilerservice/data/console.qml diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp index 4519fd6..5ae2d01 100644 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ b/src/declarative/debugger/qv8profilerservice.cpp @@ -185,6 +185,8 @@ void QV8ProfilerService::startProfiling(const QString &title) v8::HandleScope handle_scope; v8::Handle v8title = v8::String::New(reinterpret_cast(title.data()), title.size()); v8::CpuProfiler::StartProfiling(v8title); + + d->m_ongoing.append(title); } void QV8ProfilerService::stopProfiling(const QString &title) diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml b/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml new file mode 100644 index 0000000..c23c820 --- /dev/null +++ b/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + + +Item { + function f() + { + } + + Component.onCompleted: { + console.profile(); + f(); + console.profileEnd(); + } +} diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index 3ec92f9..92b893a 100644 --- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -125,6 +125,7 @@ private slots: void nonBlockingConnect(); void snapshot(); void profileOnExit(); + void console(); }; void QV8ProfilerClient::messageReceived(const QByteArray &message) @@ -193,6 +194,9 @@ void tst_QV8ProfilerService::connect(bool block, const QString &testFile) void tst_QV8ProfilerService::cleanup() { + if (QTest::currentTestFailed()) + qDebug() << "Application Output:" << m_process->output(); + delete m_process; delete m_connection; delete m_client; @@ -205,11 +209,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() m_client->startProfiling(""); m_client->stopProfiling(""); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: %1\n\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); } void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() @@ -225,11 +226,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() } m_client->startProfiling(""); m_client->stopProfiling(""); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: %1\n\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); } void tst_QV8ProfilerService::nonBlockingConnect() @@ -239,11 +237,8 @@ void tst_QV8ProfilerService::nonBlockingConnect() m_client->startProfiling(""); m_client->stopProfiling(""); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { - QString failMsg - = QString("No trace received in time. App output: %1\n\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); } void tst_QV8ProfilerService::snapshot() @@ -252,11 +247,8 @@ void tst_QV8ProfilerService::snapshot() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->takeSnapshot(); - if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(snapshot()))) { - QString failMsg - = QString("No snapshot received in time. App output: %1\n\n").arg(m_process->output()); - QFAIL(qPrintable(failMsg)); - } + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(snapshot())), + "No trace received in time."); } void tst_QV8ProfilerService::profileOnExit() @@ -266,11 +258,21 @@ void tst_QV8ProfilerService::profileOnExit() m_client->startProfiling(""); - 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)); - } + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); + //QVERIFY(!m_client->traceMessages.isEmpty()); +} + +void tst_QV8ProfilerService::console() +{ + connect(true, "console.qml"); + QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); + + m_client->stopProfiling(""); + + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); + QVERIFY(!m_client->traceMessages.isEmpty()); } QTEST_MAIN(tst_QV8ProfilerService) -- 2.7.4