aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/shared
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2012-03-16 16:44:24 +0100
committerQt by Nokia <qt-info@nokia.com>2012-04-25 11:46:16 +0200
commitb70c84564a135090740d2db98c04bf9ee8a6a4aa (patch)
treef4c13700e953f92564edd827357b997314931485 /tests/auto/qml/debugger/shared
parenta5d4efbc0035a0a3356e6d69a7b7b1c2d17ff253 (diff)
Debugger: Improve output of autotests
Change-Id: Ib938d2f39d8a0928c257ef923df5d5fcfa85c4cf Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Diffstat (limited to 'tests/auto/qml/debugger/shared')
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp31
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h2
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.cpp31
3 files changed, 58 insertions, 6 deletions
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
index eea777f09d..a6b24ae2b0 100644
--- a/tests/auto/qml/debugger/shared/debugutil.cpp
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -99,13 +99,36 @@ QQmlDebugProcess::~QQmlDebugProcess()
stop();
}
+QString QQmlDebugProcess::state()
+{
+ QString stateStr;
+ switch (m_process.state()) {
+ case QProcess::NotRunning: {
+ stateStr = "not running";
+ if (m_process.exitStatus() == QProcess::CrashExit)
+ stateStr += " (crashed!)";
+ else
+ stateStr += ", return value" + m_process.exitCode();
+ break;
+ }
+ case QProcess::Starting: stateStr = "starting"; break;
+ case QProcess::Running: stateStr = "running"; break;
+ }
+ return stateStr;
+}
+
void QQmlDebugProcess::start(const QStringList &arguments)
{
m_mutex.lock();
m_process.setEnvironment(m_environment);
m_process.start(m_executable, arguments);
- m_process.waitForStarted();
- m_timer.start();
+ if (!m_process.waitForStarted()) {
+ qWarning() << "QML Debug Client: Could not launch app " << m_executable
+ << ": " << m_process.errorString();
+ m_eventLoop.quit();
+ } else {
+ m_timer.start();
+ }
m_mutex.unlock();
}
@@ -120,7 +143,7 @@ void QQmlDebugProcess::stop()
void QQmlDebugProcess::timeout()
{
qWarning() << "Timeout while waiting for QML debugging messages "
- "in application output";
+ "in application output. Process is in state" << m_process.state() << ".";
m_eventLoop.quit();
}
@@ -162,12 +185,14 @@ void QQmlDebugProcess::processAppOutput()
if (line.startsWith("QML Debugger:")) {
if (line.contains("Waiting for connection ")) {
+ m_timer.stop();
m_started = true;
m_eventLoop.quit();
continue;
}
if (line.contains("Unable to listen")) {
qWarning() << "App was unable to bind to port!";
+ m_timer.stop();
m_eventLoop.quit();
continue;
}
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
index 0b3b8ec2a6..fa65230542 100644
--- a/tests/auto/qml/debugger/shared/debugutil_p.h
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -87,6 +87,8 @@ public:
QQmlDebugProcess(const QString &executable);
~QQmlDebugProcess();
+ QString state();
+
void setEnvironment(const QStringList &environment);
void start(const QStringList &arguments);
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
index 50feb950fb..f0fa499b9f 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
@@ -43,7 +43,9 @@
#include "../../../../../src/plugins/qmltooling/shared/qpacketprotocol.h"
#include <QtCore/qdebug.h>
+#include <QtCore/qeventloop.h>
#include <QtCore/qstringlist.h>
+#include <QtCore/qtimer.h>
#include <QtNetwork/qnetworkproxy.h>
const int protocolVersion = 1;
@@ -67,6 +69,8 @@ public:
QQmlDebugConnection *q;
QPacketProtocol *protocol;
QIODevice *device;
+ QEventLoop handshakeEventLoop;
+ QTimer handshakeTimer;
bool gotHello;
QHash <QString, float> serverPlugins;
@@ -79,6 +83,7 @@ public Q_SLOTS:
void connected();
void readyRead();
void deviceAboutToClose();
+ void handshakeTimeout();
};
QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate(QQmlDebugConnection *c)
@@ -87,6 +92,10 @@ QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate(QQmlDebugConnection *c)
protocol = new QPacketProtocol(q, this);
QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
+
+ handshakeTimer.setSingleShot(true);
+ handshakeTimer.setInterval(3000);
+ connect(&handshakeTimer, SIGNAL(timeout()), SLOT(handshakeTimeout()));
}
void QQmlDebugConnectionPrivate::advertisePlugins()
@@ -158,6 +167,9 @@ void QQmlDebugConnectionPrivate::readyRead()
newState = QQmlDebugClient::Enabled;
iter.value()->stateChanged(newState);
}
+
+ handshakeTimer.stop();
+ handshakeEventLoop.quit();
}
while (protocol->packetsAvailable()) {
@@ -226,6 +238,14 @@ void QQmlDebugConnectionPrivate::deviceAboutToClose()
q->QIODevice::close();
}
+void QQmlDebugConnectionPrivate::handshakeTimeout()
+{
+ if (!gotHello) {
+ qWarning() << "Qml Debug Client: Did not get handshake answer in time";
+ handshakeEventLoop.quit();
+ }
+}
+
QQmlDebugConnection::QQmlDebugConnection(QObject *parent)
: QIODevice(parent), d(new QQmlDebugConnectionPrivate(this))
{
@@ -282,9 +302,14 @@ void QQmlDebugConnection::close()
bool QQmlDebugConnection::waitForConnected(int msecs)
{
QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
- if (socket)
- return socket->waitForConnected(msecs);
- return false;
+ if (!socket)
+ return false;
+ if (!socket->waitForConnected(msecs))
+ return false;
+ // wait for handshake
+ d->handshakeTimer.start();
+ d->handshakeEventLoop.exec();
+ return d->gotHello;
}
QAbstractSocket::SocketState QQmlDebugConnection::state() const