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.cpp81
-rw-r--r--tests/auto/declarative/shared/debugutil_p.h56
2 files changed, 1 insertions, 136 deletions
diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp
index 66f04e5..c0c3eca 100644
--- a/tests/auto/declarative/shared/debugutil.cpp
+++ b/tests/auto/declarative/shared/debugutil.cpp
@@ -47,11 +47,11 @@
#include "debugutil_p.h"
-#include <iostream>
bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
QEventLoop loop;
QTimer timer;
+ timer.setSingleShot(true);
QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
QObject::connect(receiver, member, &loop, SLOT(quit()));
timer.start(timeout);
@@ -59,25 +59,6 @@ bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member,
return timer.isActive();
}
-
-QDeclarativeDebugTestData::QDeclarativeDebugTestData(QEventLoop *el)
- : exitCode(-1), loop(el)
-{
-}
-
-QDeclarativeDebugTestData::~QDeclarativeDebugTestData()
-{
- qDeleteAll(items);
-}
-
-void QDeclarativeDebugTestData::testsFinished(int code)
-{
- exitCode = code;
- loop->quit();
-}
-
-
-
QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, QObject *parent)
: QDeclarativeDebugService(s, parent), enabled(false)
{
@@ -117,63 +98,3 @@ void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba)
emit serverMessage(ba);
}
-
-tst_QDeclarativeDebug_Thread::tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory)
- : m_data(data), m_factory(factory)
-{
-}
-
-void tst_QDeclarativeDebug_Thread::run()
-{
- bool ok = false;
-
- QDeclarativeDebugConnection conn;
- conn.connectToHost("127.0.0.1", 3768);
- ok = conn.waitForConnected();
- Q_ASSERT(ok);
-
- QEventLoop loop;
- connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit()));
- loop.exec();
-
- m_data->conn = &conn;
-
- Q_ASSERT(m_factory);
- QObject *test = m_factory->createTest(m_data);
- Q_ASSERT(test);
- int code = QTest::qExec(test, QCoreApplication::arguments());
- delete test;
- emit testsFinished(code);
-}
-
-int QDeclarativeDebugTest::runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml)
-{
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
-
- QEventLoop loop;
- QDeclarativeDebugTestData data(&loop);
-
- tst_QDeclarativeDebug_Thread thread(&data, factory);
- QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
-
- QDeclarativeDebugService::notifyOnServerStart(&thread, "start");
-
- QDeclarativeEngine engine; // blocks until client connects
-
- foreach (const QByteArray &code, qml) {
- QDeclarativeComponent c(&engine);
- c.setData(code, QUrl::fromLocalFile(""));
- Q_ASSERT(c.isReady()); // fails if bad syntax
- data.items << qobject_cast<QDeclarativeItem*>(c.create());
- }
-
- // start the test
- data.engine = &engine;
- emit data.engineCreated();
-
- loop.exec();
- thread.wait();
-
- return data.exitCode;
-}
-
diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h
index c152b5a..e6bb7ad 100644
--- a/tests/auto/declarative/shared/debugutil_p.h
+++ b/tests/auto/declarative/shared/debugutil_p.h
@@ -51,50 +51,10 @@
#include <private/qdeclarativedebugservice_p.h>
#include <private/qdeclarativeitem_p.h>
-class QDeclarativeTestFactory;
-
class QDeclarativeDebugTest
{
public:
static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-
- static int runTests(QDeclarativeTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
-};
-
-class QDeclarativeDebugTestData : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeDebugTestData(QEventLoop *el);
-
- ~QDeclarativeDebugTestData();
-
- QDeclarativeDebugConnection *conn;
- QDeclarativeEngine *engine;
-
- int exitCode;
- QEventLoop *loop;
-
- QList<QDeclarativeItem *> items;
-
-signals:
- void engineCreated();
-
-public slots:
- void testsFinished(int code);
-
-private:
- friend class QDeclarativeDebugTest;
-};
-
-
-class QDeclarativeTestFactory
-{
-public:
- QDeclarativeTestFactory() {}
- virtual ~QDeclarativeTestFactory() {}
-
- virtual QObject *createTest(QDeclarativeDebugTestData *data) = 0;
};
class QDeclarativeDebugTestService : public QDeclarativeDebugService
@@ -131,20 +91,4 @@ private:
QByteArray lastMsg;
};
-class tst_QDeclarativeDebug_Thread : public QThread
-{
- Q_OBJECT
-public:
- tst_QDeclarativeDebug_Thread(QDeclarativeDebugTestData *data, QDeclarativeTestFactory *factory);
-
- void run();
-
-signals:
- void testsFinished(int);
-
-private:
- QDeclarativeDebugTestData *m_data;
- QDeclarativeTestFactory *m_factory;
-};
-