summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/shared/debugutil.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-15 07:22:29 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-15 07:22:29 (GMT)
commitaf36be2c7257870e1ad094ec7b2cc37ae4ca2176 (patch)
tree5e69a670cad06f62f8a5b539105995cea00ae0aa /tests/auto/declarative/shared/debugutil.cpp
parentb258be1d39889e65411324fe5cda47a34f814033 (diff)
downloadQt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.zip
Qt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.tar.gz
Qt-af36be2c7257870e1ad094ec7b2cc37ae4ca2176.tar.bz2
For qmldebug* tests, make sure engine is running before the test thread
is started. Also fix some memory leaks.
Diffstat (limited to 'tests/auto/declarative/shared/debugutil.cpp')
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index aa0cd31..0010508 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -47,6 +47,8 @@
#include "debugutil_p.h"
+#include <iostream>
+
bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
@@ -117,21 +119,22 @@ void QmlDebugTestClient::messageReceived(const QByteArray &ba)
tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
- : m_ready(false), m_data(data), m_factory(factory)
+ : m_data(data), m_factory(factory)
{
}
void tst_QmlDebug_Thread::run()
{
- QTest::qWait(1000);
+ bool ok = false;
QmlDebugConnection conn;
conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
+ ok = conn.waitForConnected();
Q_ASSERT(ok);
- while (!m_ready)
- QTest::qWait(100);
+ QEventLoop loop;
+ connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit()));
+ loop.exec();
m_data->conn = &conn;
@@ -139,10 +142,10 @@ void tst_QmlDebug_Thread::run()
QObject *test = m_factory->createTest(m_data);
Q_ASSERT(test);
int code = QTest::qExec(test, QCoreApplication::arguments());
+ delete test;
emit testsFinished(code);
}
-
int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
{
qputenv("QML_DEBUG_SERVER_PORT", "3768");
@@ -152,7 +155,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
tst_QmlDebug_Thread thread(&data, factory);
QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
- thread.start();
+
+ QmlDebugService::notifyOnServerStart(&thread, "start");
QmlEngine engine; // blocks until client connects
@@ -165,7 +169,7 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
// start the test
data.engine = &engine;
- thread.m_ready = true;
+ emit data.engineCreated();
loop.exec();
thread.wait();
@@ -173,4 +177,3 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml
return data.exitCode;
}
-