summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/shared
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/shared')
-rw-r--r--tests/auto/declarative/shared/debugutil.cpp21
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h25
2 files changed, 27 insertions, 19 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;
}
-
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index 313d16c..6f23899 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -51,6 +51,15 @@
#include <private/qmldebugservice_p.h>
#include <private/qmlgraphicsitem_p.h>
+class QmlTestFactory;
+
+class QmlDebugTest
+{
+public:
+ static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+
+ static int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
+};
class QmlDebugTestData : public QObject
{
@@ -68,8 +77,14 @@ public:
QList<QmlGraphicsItem *> items;
+signals:
+ void engineCreated();
+
public slots:
void testsFinished(int code);
+
+private:
+ friend class QmlDebugTest;
};
@@ -82,14 +97,6 @@ public:
virtual QObject *createTest(QmlDebugTestData *data) = 0;
};
-
-namespace QmlDebugTest {
-
- bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-
- int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
-}
-
class QmlDebugTestService : public QmlDebugService
{
Q_OBJECT
@@ -132,8 +139,6 @@ public:
void run();
- bool m_ready;
-
signals:
void testsFinished(int);