aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-12-20 14:26:39 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-09 16:53:14 +0100
commit82dfecab38031f8009ea64ef93063c02b79eaf94 (patch)
tree2fb8e982b517d5b76bb228be477b92c0aa31788c /tests/auto
parent4a224c4bd36e859c7b36867d4322321c0852c05a (diff)
Debugger: Allow trace service to send data on exit
Add a statusAboutToBeChanged virtual that allows services to send data e.g. on application exit. Change-Id: I28fa513ab2a12d6973c444aac3062d64a0957207 Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml9
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp38
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml11
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp29
4 files changed, 72 insertions, 15 deletions
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml b/tests/auto/declarative/debugger/qdeclarativedebugtrace/data/exit.qml
new file mode 100644
index 0000000000..b250524caa
--- /dev/null
+++ b/tests/auto/declarative/debugger/qdeclarativedebugtrace/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/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp b/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp
index fb24c54a25..e0c8af7181 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp
+++ b/tests/auto/declarative/debugger/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp
@@ -92,7 +92,7 @@ private:
QDeclarativeDebugConnection *m_connection;
QDeclarativeDebugTraceClient *m_client;
- void connect(bool block);
+ void connect(bool block, const QString &testFile);
private slots:
void cleanup();
@@ -100,6 +100,7 @@ private slots:
void blockingConnectWithTraceEnabled();
void blockingConnectWithTraceDisabled();
void nonBlockingConnect();
+ void profileOnExit();
};
void QDeclarativeDebugTraceClient::messageReceived(const QByteArray &message)
@@ -147,7 +148,6 @@ void QDeclarativeDebugTraceClient::messageReceived(const QByteArray &message)
}
case QDeclarativeDebugTrace::Complete: {
emit complete();
- QVERIFY(stream.atEnd());
return;
}
case QDeclarativeDebugTrace::RangeStart: {
@@ -166,7 +166,7 @@ void QDeclarativeDebugTraceClient::messageReceived(const QByteArray &message)
break;
}
case QDeclarativeDebugTrace::RangeLocation: {
- stream >> data.detailType >> data.detailData >> data.line;
+ stream >> data.detailType >> data.detailData >> data.line >> data.column;
QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeDebugTrace::MaximumRangeType);
QVERIFY(data.line >= -2);
break;
@@ -180,7 +180,7 @@ void QDeclarativeDebugTraceClient::messageReceived(const QByteArray &message)
traceMessages.append(data);
}
-void tst_QDeclarativeDebugTrace::connect(bool block)
+void tst_QDeclarativeDebugTrace::connect(bool block, const QString &testFile)
{
const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
QStringList arguments;
@@ -190,7 +190,7 @@ void tst_QDeclarativeDebugTrace::connect(bool block)
else
arguments << QString("-qmljsdebugger=port:"STR_PORT);
- arguments << testFile("test.qml");
+ arguments << QDeclarativeDataTest::instance()->testFile(testFile);
m_process = new QDeclarativeDebugProcess(executable);
m_process->start(QStringList() << arguments);
@@ -215,7 +215,7 @@ void tst_QDeclarativeDebugTrace::cleanup()
void tst_QDeclarativeDebugTrace::blockingConnectWithTraceEnabled()
{
- connect(true);
+ connect(true, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->setTraceStatus(true);
@@ -238,7 +238,7 @@ void tst_QDeclarativeDebugTrace::blockingConnectWithTraceEnabled()
void tst_QDeclarativeDebugTrace::blockingConnectWithTraceDisabled()
{
- connect(true);
+ connect(true, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->setTraceStatus(false);
@@ -263,7 +263,7 @@ void tst_QDeclarativeDebugTrace::blockingConnectWithTraceDisabled()
void tst_QDeclarativeDebugTrace::nonBlockingConnect()
{
- connect(false);
+ connect(false, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->setTraceStatus(true);
@@ -283,6 +283,28 @@ void tst_QDeclarativeDebugTrace::nonBlockingConnect()
QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeDebugTrace::EndTrace);
}
+void tst_QDeclarativeDebugTrace::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
+
+ m_client->setTraceStatus(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/qv8profilerservice/data/exit.qml b/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml
new file mode 100644
index 0000000000..604265354c
--- /dev/null
+++ b/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+Item {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ Qt.quit();
+ }
+ }
+}
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
index c70d726fca..2556e41e4f 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
+++ b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
@@ -115,7 +115,7 @@ private:
QDeclarativeDebugConnection *m_connection;
QV8ProfilerClient *m_client;
- void connect(bool block);
+ void connect(bool block, const QString &testFile);
private slots:
void cleanup();
@@ -124,6 +124,7 @@ private slots:
void blockingConnectWithTraceDisabled();
void nonBlockingConnect();
void snapshot();
+ void profileOnExit();
};
void QV8ProfilerClient::messageReceived(const QByteArray &message)
@@ -164,7 +165,7 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message)
QVERIFY(stream.atEnd());
}
-void tst_QV8ProfilerService::connect(bool block)
+void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
{
const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
QStringList arguments;
@@ -174,7 +175,7 @@ void tst_QV8ProfilerService::connect(bool block)
else
arguments << QString("-qmljsdebugger=port:"STR_PORT);
- arguments << QDeclarativeDataTest::instance()->testFile("test.qml");
+ arguments << QDeclarativeDataTest::instance()->testFile(testFile);
m_process = new QDeclarativeDebugProcess(executable);
m_process->start(QStringList() << arguments);
@@ -199,7 +200,7 @@ void tst_QV8ProfilerService::cleanup()
void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
{
- connect(true);
+ connect(true, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->startProfiling("");
@@ -213,7 +214,7 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
{
- connect(true);
+ connect(true, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->stopProfiling("");
@@ -233,7 +234,7 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
void tst_QV8ProfilerService::nonBlockingConnect()
{
- connect(false);
+ connect(false, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->startProfiling("");
@@ -247,7 +248,7 @@ void tst_QV8ProfilerService::nonBlockingConnect()
void tst_QV8ProfilerService::snapshot()
{
- connect(false);
+ connect(false, "test.qml");
QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
m_client->takeSnapshot();
@@ -258,6 +259,20 @@ void tst_QV8ProfilerService::snapshot()
}
}
+void tst_QV8ProfilerService::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->status(), QDeclarativeDebugClient::Enabled);
+
+ 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));
+ }
+}
+
QTEST_MAIN(tst_QV8ProfilerService)
#include "tst_qv8profilerservice.moc"