QQmlDebugConnection *m_connection;
QV8ProfilerClient *m_client;
- void connect(bool block, const QString &testFile);
+ bool connect(bool block, const QString &testFile, QString *error);
private slots:
void cleanup();
QVERIFY(stream.atEnd());
}
-void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
+bool tst_QV8ProfilerService::connect(bool block, const QString &testFile,
+ QString *error)
{
const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
QStringList arguments;
arguments << QQmlDataTest::instance()->testFile(testFile);
+ m_connection = new QQmlDebugConnection();
+ m_client = new QV8ProfilerClient(m_connection);
+
m_process = new QQmlDebugProcess(executable);
m_process->start(QStringList() << arguments);
if (!m_process->waitForSessionStart()) {
- QString failMsg = QString("Could not launch app '%1'.").arg(executable);
- QFAIL(qPrintable(failMsg));
+ *error = QLatin1String("Could not launch app ") + executable;
+ return false;
}
- m_connection = new QQmlDebugConnection();
- m_client = new QV8ProfilerClient(m_connection);
-
m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
- if (!m_connection->waitForConnected())
- QFAIL("Could not connect to debugger port.");
+ if (!m_connection->waitForConnected()) {
+ *error = QLatin1String("Could not connect to debugger port.");
+ return false;
+ }
+ return true;
}
void tst_QV8ProfilerService::cleanup()
if (QTest::currentTestFailed())
qDebug() << "Application Output:" << m_process->output();
+ delete m_client;
delete m_process;
delete m_connection;
}
void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
{
- connect(true, "test.qml");
+ QString error;
+ if (!connect(true, "test.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
{
- connect(true, "test.qml");
+ QString error;
+ if (!connect(true, "test.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->stopProfiling("");
void tst_QV8ProfilerService::nonBlockingConnect()
{
- connect(false, "test.qml");
+ QString error;
+ if (!connect(false, "test.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
void tst_QV8ProfilerService::snapshot()
{
- connect(false, "test.qml");
+ QString error;
+ if (!connect(false, "test.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->takeSnapshot();
void tst_QV8ProfilerService::profileOnExit()
{
- connect(true, "exit.qml");
+ QString error;
+ if (!connect(true, "exit.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->startProfiling("");
void tst_QV8ProfilerService::console()
{
- connect(true, "console.qml");
+ QString error;
+ if (!connect(true, "console.qml", &error))
+ QFAIL(qPrintable(error));
+
QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
m_client->stopProfiling("");
lastMsg.clear();
QQmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
if (lastMsg.isEmpty()) {
- qWarning() << "tst_QQmlDebugTestClient: no response from server!";
+ qWarning() << "no response from server!";
return QByteArray();
}
return lastMsg;
m_timer.setSingleShot(true);
m_timer.setInterval(5000);
connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
- connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
+ connect(&m_timer, SIGNAL(timeout()), SLOT(timeout()));
}
QQmlDebugProcess::~QQmlDebugProcess()
}
}
+void QQmlDebugProcess::timeout()
+{
+ qWarning() << "Timeout while waiting for QML debugging messages "
+ "in application output";
+ m_eventLoop.quit();
+}
+
bool QQmlDebugProcess::waitForSessionStart()
{
if (m_process.state() != QProcess::Running) {
const QString line = m_outputBuffer.left(nlIndex);
m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1);
- if (line.startsWith("QML debugging is enabled")) // ignore
- continue;
if (line.startsWith("QML Debugger:")) {
if (line.contains("Waiting for connection ")) {
m_started = true;
m_eventLoop.quit();
continue;
}
+ if (line.contains("Unable to listen")) {
+ qWarning() << "App was unable to bind to port!";
+ m_eventLoop.quit();
+ continue;
+ }
}
}
m_mutex.unlock();