summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-12 06:41:22 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-12 06:41:22 (GMT)
commit073963d9e45d9923cfafd5a3b43ef0dda8fe6d6f (patch)
treed39dc1f39d15494bad64164ab718901e27d90a47
parent22fe9474b01c577337e43416666a8f90d0ad6064 (diff)
downloadQt-073963d9e45d9923cfafd5a3b43ef0dda8fe6d6f.zip
Qt-073963d9e45d9923cfafd5a3b43ef0dda8fe6d6f.tar.gz
Qt-073963d9e45d9923cfafd5a3b43ef0dda8fe6d6f.tar.bz2
Move engine/test set up code to debugutil.cpp
-rw-r--r--tests/auto/declarative/debugger/debuggerutil.cpp103
-rw-r--r--tests/auto/declarative/debugger/debugutil.cpp170
-rw-r--r--tests/auto/declarative/debugger/debugutil_p.h (renamed from tests/auto/declarative/debugger/debuggerutil_p.h)68
-rw-r--r--tests/auto/declarative/debugger/qmldebug/qmldebug.pro4
-rw-r--r--tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp96
-rw-r--r--tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro4
-rw-r--r--tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp66
-rw-r--r--tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro4
-rw-r--r--tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp69
9 files changed, 303 insertions, 281 deletions
diff --git a/tests/auto/declarative/debugger/debuggerutil.cpp b/tests/auto/declarative/debugger/debuggerutil.cpp
deleted file mode 100644
index 761105e..0000000
--- a/tests/auto/declarative/debugger/debuggerutil.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QSignalSpy>
-#include <QEventLoop>
-#include <QTimer>
-
-#include <private/qmldebugclient_p.h>
-#include <private/qmldebugservice_p.h>
-
-#include "debuggerutil_p.h"
-
-namespace QmlDebuggerTest {
-
- bool waitForSignal(QObject *receiver, const char *member, int timeout) {
- QEventLoop loop;
- QTimer timer;
- QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- QObject::connect(receiver, member, &loop, SLOT(quit()));
- timer.start(timeout);
- loop.exec();
- return timer.isActive();
- }
-
-}
-
-
-QmlDebuggerTestService::QmlDebuggerTestService(const QString &s, QObject *parent)
- : QmlDebugService(s, parent), enabled(false)
-{
-}
-
-void QmlDebuggerTestService::messageReceived(const QByteArray &ba)
-{
- sendMessage(ba);
-}
-
-void QmlDebuggerTestService::enabledChanged(bool e)
-{
- emit enabledStateChanged();
- enabled = e;
-}
-
-
-QmlDebuggerTestClient::QmlDebuggerTestClient(const QString &s, QmlDebugConnection *c)
- : QmlDebugClient(s, c)
-{
-}
-
-QByteArray QmlDebuggerTestClient::waitForResponse()
-{
- QSignalSpy spy(this, SIGNAL(serverMessage(QByteArray)));
- QmlDebuggerTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
- if (spy.count() == 0) {
- qWarning() << "tst_QmlDebugClient: no response from server!";
- return QByteArray();
- }
- return spy.at(0).at(0).value<QByteArray>();
-}
-
-void QmlDebuggerTestClient::messageReceived(const QByteArray &ba)
-{
- emit serverMessage(ba);
-}
-
-
diff --git a/tests/auto/declarative/debugger/debugutil.cpp b/tests/auto/declarative/debugger/debugutil.cpp
new file mode 100644
index 0000000..cc58fe9
--- /dev/null
+++ b/tests/auto/declarative/debugger/debugutil.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QSignalSpy>
+#include <QEventLoop>
+#include <QTimer>
+
+#include <private/qmldebugclient_p.h>
+#include <private/qmldebugservice_p.h>
+
+#include "debugutil_p.h"
+
+bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
+ QEventLoop loop;
+ QTimer timer;
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ QObject::connect(receiver, member, &loop, SLOT(quit()));
+ timer.start(timeout);
+ loop.exec();
+ return timer.isActive();
+}
+
+
+QmlDebugTestData::QmlDebugTestData(QEventLoop *el)
+ : exitCode(-1), loop(el)
+{
+}
+
+QmlDebugTestData::~QmlDebugTestData()
+{
+ qDeleteAll(items);
+}
+
+void QmlDebugTestData::testsFinished(int code)
+{
+ exitCode = code;
+ loop->quit();
+}
+
+
+
+QmlDebugTestService::QmlDebugTestService(const QString &s, QObject *parent)
+ : QmlDebugService(s, parent), enabled(false)
+{
+}
+
+void QmlDebugTestService::messageReceived(const QByteArray &ba)
+{
+ sendMessage(ba);
+}
+
+void QmlDebugTestService::enabledChanged(bool e)
+{
+ emit enabledStateChanged();
+ enabled = e;
+}
+
+
+QmlDebugTestClient::QmlDebugTestClient(const QString &s, QmlDebugConnection *c)
+ : QmlDebugClient(s, c)
+{
+}
+
+QByteArray QmlDebugTestClient::waitForResponse()
+{
+ QSignalSpy spy(this, SIGNAL(serverMessage(QByteArray)));
+ QmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
+ if (spy.count() == 0) {
+ qWarning() << "tst_QmlDebugClient: no response from server!";
+ return QByteArray();
+ }
+ return spy.at(0).at(0).value<QByteArray>();
+}
+
+void QmlDebugTestClient::messageReceived(const QByteArray &ba)
+{
+ emit serverMessage(ba);
+}
+
+
+tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory)
+ : m_ready(false), m_data(data), m_factory(factory)
+{
+}
+
+void tst_QmlDebug_Thread::run()
+{
+ QTest::qWait(1000);
+
+ QmlDebugConnection conn;
+ conn.connectToHost("127.0.0.1", 3768);
+ bool ok = conn.waitForConnected(5000);
+ Q_ASSERT(ok);
+
+ while (!m_ready)
+ QTest::qWait(100);
+
+ m_data->conn = &conn;
+ QObject *test = m_factory->createTest(m_data);
+ int code = QTest::qExec(test);
+ emit testsFinished(code);
+}
+
+
+int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml)
+{
+ qputenv("QML_DEBUG_SERVER_PORT", "3768");
+
+ QEventLoop loop;
+ QmlDebugTestData data(&loop);
+
+ tst_QmlDebug_Thread thread(&data, factory);
+ QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int)));
+ thread.start();
+
+ QmlEngine engine; // blocks until client connects
+
+ foreach (const QByteArray &code, qml) {
+ QmlComponent c(&engine, code, QUrl("file://"));
+ Q_ASSERT(c.isReady()); // fails if bad syntax
+ data.items << qobject_cast<QmlGraphicsItem*>(c.create());
+ }
+
+ // start the test
+ data.engine = &engine;
+ thread.m_ready = true;
+
+ loop.exec();
+
+ return data.exitCode;
+}
+
+
diff --git a/tests/auto/declarative/debugger/debuggerutil_p.h b/tests/auto/declarative/debugger/debugutil_p.h
index 5e27a7a..665aeda 100644
--- a/tests/auto/declarative/debugger/debuggerutil_p.h
+++ b/tests/auto/declarative/debugger/debugutil_p.h
@@ -40,21 +40,61 @@
****************************************************************************/
#include <QSignalSpy>
#include <QEventLoop>
+#include <QPointer>
#include <QTimer>
+#include <QThread>
+#include <QTest>
+
+#include <QtDeclarative/qmlengine.h>
#include <private/qmldebugclient_p.h>
#include <private/qmldebugservice_p.h>
+#include <private/qmlgraphicsitem_p.h>
+
+
+class QmlDebugTestData : public QObject
+{
+ Q_OBJECT
+public:
+ QmlDebugTestData(QEventLoop *el);
+
+ ~QmlDebugTestData();
+
+ QmlEngine *engine;
+ QmlDebugConnection *conn;
+
+ int exitCode;
+ QEventLoop *loop;
+
+ QList<QmlGraphicsItem *> items;
+
+public slots:
+ void testsFinished(int code);
+};
+
+
+class QmlTestFactory
+{
+public:
+ QmlTestFactory() {}
+ virtual ~QmlTestFactory() {}
+
+ virtual QObject *createTest(QmlDebugTestData *data) = 0;
+};
+
-namespace QmlDebuggerTest {
+namespace QmlDebugTest {
bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+
+ int runTests(QmlTestFactory *factory, const QList<QByteArray> &qml = QList<QByteArray>());
}
-class QmlDebuggerTestService : public QmlDebugService
+class QmlDebugTestService : public QmlDebugService
{
Q_OBJECT
public:
- QmlDebuggerTestService(const QString &s, QObject *parent = 0);
+ QmlDebugTestService(const QString &s, QObject *parent = 0);
bool enabled;
signals:
@@ -66,11 +106,11 @@ protected:
virtual void enabledChanged(bool e);
};
-class QmlDebuggerTestClient : public QmlDebugClient
+class QmlDebugTestClient : public QmlDebugClient
{
Q_OBJECT
public:
- QmlDebuggerTestClient(const QString &s, QmlDebugConnection *c);
+ QmlDebugTestClient(const QString &s, QmlDebugConnection *c);
QByteArray waitForResponse();
@@ -81,4 +121,22 @@ protected:
virtual void messageReceived(const QByteArray &ba);
};
+class tst_QmlDebug_Thread : public QThread
+{
+ Q_OBJECT
+public:
+ tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory);
+
+ void run();
+
+ bool m_ready;
+
+signals:
+ void testsFinished(int);
+
+private:
+ QmlDebugTestData *m_data;
+ QmlTestFactory *m_factory;
+};
+
diff --git a/tests/auto/declarative/debugger/qmldebug/qmldebug.pro b/tests/auto/declarative/debugger/qmldebug/qmldebug.pro
index c1ac125..0af30e1 100644
--- a/tests/auto/declarative/debugger/qmldebug/qmldebug.pro
+++ b/tests/auto/declarative/debugger/qmldebug/qmldebug.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debuggerutil_p.h
+HEADERS += ../debugutil_p.h
SOURCES += tst_qmldebug.cpp \
- ../debuggerutil.cpp
+ ../debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp
index bfb8aee..21e7962 100644
--- a/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp
+++ b/tests/auto/declarative/debugger/qmldebug/tst_qmldebug.cpp
@@ -59,7 +59,7 @@
#include <private/qmldebugservice_p.h>
#include <private/qmlgraphicsrectangle_p.h>
-#include "../debuggerutil_p.h"
+#include "../debugutil_p.h"
Q_DECLARE_METATYPE(QmlDebugWatch::State)
@@ -69,8 +69,12 @@ class tst_QmlDebug : public QObject
Q_OBJECT
public:
- tst_QmlDebug(QmlDebugConnection *conn, QmlEngine *engine, QmlGraphicsItem *rootItem)
- : m_conn(conn), m_dbg(0), m_engine(engine), m_rootItem(rootItem) {}
+ tst_QmlDebug(QmlDebugTestData *data)
+ {
+ m_conn = data->conn;
+ m_engine = data->engine;
+ m_rootItem = data->items[0];
+ }
private:
QmlDebugObjectReference findRootObject();
@@ -160,7 +164,7 @@ void tst_QmlDebug::waitForQuery(QmlDebugQuery *query)
QVERIFY(query);
QCOMPARE(query->parent(), this);
QVERIFY(query->state() == QmlDebugQuery::Waiting);
- if (!QmlDebuggerTest::waitForSignal(query, SIGNAL(stateChanged(QmlDebugQuery::State))))
+ if (!QmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QmlDebugQuery::State))))
QFAIL("query timed out");
}
@@ -289,7 +293,7 @@ void tst_QmlDebug::watch_property()
m_rootItem->setProperty("width", origWidth*2);
// stateChanged() is received before valueChanged()
- QVERIFY(QmlDebuggerTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
+ QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
QCOMPARE(spy.count(), 1);
m_dbg->removeWatch(watch);
@@ -340,7 +344,7 @@ void tst_QmlDebug::watch_object()
m_rootItem->setProperty("height", origHeight*2);
// stateChanged() is received before any valueChanged() signals
- QVERIFY(QmlDebuggerTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
+ QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
QVERIFY(spy.count() > 0);
int newWidth = -1;
@@ -401,12 +405,12 @@ void tst_QmlDebug::watch_expression()
width += increment;
m_rootItem->setProperty("width", width);
}
- if (!QmlDebuggerTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
+ if (!QmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
QFAIL("Did not receive valueChanged() for expression");
}
if (spyState.count() == 0)
- QVERIFY(QmlDebuggerTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
+ QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State))));
QCOMPARE(spyState.count(), 1);
m_dbg->removeWatch(watch);
@@ -759,72 +763,32 @@ void tst_QmlDebug::tst_QmlDebugPropertyReference()
compareProperties(r, ref);
}
-class TestRunnerThread : public QThread
+
+class tst_QmlDebug_Factory : public QmlTestFactory
{
- Q_OBJECT
public:
- void run() {
- QTest::qWait(1000);
- connectToEngine();
- }
-
- QPointer<QmlEngine> m_engine;
- QPointer<QmlGraphicsItem> m_item;
-
-signals:
- void testsFinished();
-
-public slots:
-
- void connectToEngine()
- {
- QmlDebugConnection conn;
- conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
- Q_ASSERT(ok);
- while (!m_engine && !m_item)
- QTest::qWait(50);
-
- tst_QmlDebug test(&conn, m_engine, m_item);
- QTest::qExec(&test);
- emit testsFinished();
- }
+ QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebug(data); }
};
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
-
- TestRunnerThread thread;
- QObject::connect(&thread, SIGNAL(testsFinished()), qApp, SLOT(quit()));
- thread.start();
-
- QmlEngine engine; // blocks until client connects
-
- QmlComponent component(&engine,
- "import Qt 4.6\n"
- "Item {\n"
- "width: 10; height: 20; scale: blueRect.scale;\n"
- "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
- "Text { color: blueRect.color; }"
- "}\n",
- QUrl("file://"));
- Q_ASSERT(component.isReady());
- QObject *o = component.create();
- QObject::connect(&thread, SIGNAL(testsFinished()), o, SLOT(deleteLater()));
-
- // allows us to test that multiple contexts can be detected
- QObject *o2 = component.create();
- QObject::connect(&thread, SIGNAL(testsFinished()), o2, SLOT(deleteLater()));
-
- // start the test
- thread.m_engine = &engine;
- thread.m_item = qobject_cast<QmlGraphicsItem*>(o);
-
- return app.exec();
+ QList<QByteArray> qml;
+ qml << "import Qt 4.6\n"
+ "Item {"
+ "width: 10; height: 20; scale: blueRect.scale;"
+ "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
+ "Text { color: blueRect.color; }"
+ "}"
+ << "import Qt 4.6\n"
+ "Item {"
+ "MouseRegion {"
+ "onEntered: { print('hello') }"
+ "}"
+ "}";
+ tst_QmlDebug_Factory factory;
+ return QmlDebugTest::runTests(&factory, qml);
}
//QTEST_MAIN(tst_QmlDebug)
diff --git a/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro b/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro
index 6e68cd5..c0aa7b2 100644
--- a/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro
+++ b/tests/auto/declarative/debugger/qmldebugclient/qmldebugclient.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debuggerutil_p.h
+HEADERS += ../debugutil_p.h
SOURCES += tst_qmldebugclient.cpp \
- ../debuggerutil.cpp
+ ../debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp b/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp
index 0a768a5..6c4a1a3 100644
--- a/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp
+++ b/tests/auto/declarative/debugger/qmldebugclient/tst_qmldebugclient.cpp
@@ -52,15 +52,18 @@
#include <private/qmldebugclient_p.h>
#include <private/qmldebugservice_p.h>
-#include "../debuggerutil_p.h"
+#include "../debugutil_p.h"
class tst_QmlDebugClient : public QObject
{
Q_OBJECT
public:
- tst_QmlDebugClient(QmlDebugConnection *conn, QmlEngine *engine)
- : m_conn(conn), m_engine(engine) {}
+ tst_QmlDebugClient(QmlDebugTestData *data)
+ {
+ m_conn = data->conn;
+ m_engine = data->engine;
+ }
QmlDebugConnection *m_conn;
QmlEngine *m_engine;
@@ -89,19 +92,19 @@ void tst_QmlDebugClient::isEnabled()
void tst_QmlDebugClient::setEnabled()
{
- QmlDebuggerTestService service("tst_QmlDebugClient::setEnabled()");
- QmlDebuggerTestClient client("tst_QmlDebugClient::setEnabled()", m_conn);
+ QmlDebugTestService service("tst_QmlDebugClient::setEnabled()");
+ QmlDebugTestClient client("tst_QmlDebugClient::setEnabled()", m_conn);
QCOMPARE(service.isEnabled(), false);
client.setEnabled(true);
QCOMPARE(client.isEnabled(), true);
- QmlDebuggerTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
QCOMPARE(service.isEnabled(), true);
client.setEnabled(false);
QCOMPARE(client.isEnabled(), false);
- QmlDebuggerTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
QCOMPARE(service.isEnabled(), false);
}
@@ -125,8 +128,8 @@ void tst_QmlDebugClient::isConnected()
void tst_QmlDebugClient::sendMessage()
{
- QmlDebuggerTestService service("tst_QmlDebugClient::sendMessage()");
- QmlDebuggerTestClient client("tst_QmlDebugClient::sendMessage()", m_conn);
+ QmlDebugTestService service("tst_QmlDebugClient::sendMessage()");
+ QmlDebugTestClient client("tst_QmlDebugClient::sendMessage()", m_conn);
QByteArray msg = "hello!";
@@ -136,55 +139,18 @@ void tst_QmlDebugClient::sendMessage()
}
-
-class tst_QmlDebugClient_Thread : public QThread
+class tst_QmlDebugClient_Factory : public QmlTestFactory
{
- Q_OBJECT
public:
- void run() {
- QTest::qWait(1000);
- connectToEngine();
- }
-
- QPointer<QmlEngine> m_engine;
-
-signals:
- void testsFinished();
-
-public slots:
-
- void connectToEngine()
- {
- QmlDebugConnection conn;
- conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
- Q_ASSERT(ok);
- while (!m_engine)
- QTest::qWait(50);
-
- tst_QmlDebugClient test(&conn, m_engine);
- QTest::qExec(&test);
- emit testsFinished();
- }
+ QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugClient(data); }
};
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
-
- tst_QmlDebugClient_Thread thread;
- QObject::connect(&thread, SIGNAL(testsFinished()), qApp, SLOT(quit()));
- thread.start();
-
- QmlEngine engine; // blocks until client connects
-
- // start the test
- thread.m_engine = &engine;
-
- return app.exec();
+ tst_QmlDebugClient_Factory factory;
+ return QmlDebugTest::runTests(&factory);
}
#include "tst_qmldebugclient.moc"
diff --git a/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro b/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro
index 1b6762c..cce277a 100644
--- a/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro
+++ b/tests/auto/declarative/debugger/qmldebugservice/qmldebugservice.pro
@@ -2,6 +2,6 @@ load(qttest_p4)
contains(QT_CONFIG,declarative): QT += network declarative
macx:CONFIG -= app_bundle
-HEADERS += ../debuggerutil_p.h
+HEADERS += ../debugutil_p.h
SOURCES += tst_qmldebugservice.cpp \
- ../debuggerutil.cpp
+ ../debugutil.cpp
diff --git a/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp
index 2cd8607..0c02929 100644
--- a/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp
+++ b/tests/auto/declarative/debugger/qmldebugservice/tst_qmldebugservice.cpp
@@ -52,15 +52,18 @@
#include <private/qmldebugclient_p.h>
#include <private/qmldebugservice_p.h>
-#include "../debuggerutil_p.h"
+#include "../debugutil_p.h"
class tst_QmlDebugService : public QObject
{
Q_OBJECT
public:
- tst_QmlDebugService(QmlDebugConnection *conn, QmlEngine *engine)
- : m_conn(conn), m_engine(engine) {}
+ tst_QmlDebugService(QmlDebugTestData *data)
+ {
+ m_conn = data->conn;
+ m_engine = data->engine;
+ }
QmlDebugConnection *m_conn;
QmlEngine *m_engine;
@@ -85,12 +88,12 @@ void tst_QmlDebugService::name()
void tst_QmlDebugService::isEnabled()
{
- QmlDebuggerTestService service("tst_QmlDebugService::isEnabled()", m_conn);
+ QmlDebugTestService service("tst_QmlDebugService::isEnabled()", m_conn);
QCOMPARE(service.isEnabled(), false);
- QmlDebuggerTestClient client("tst_QmlDebugService::isEnabled()", m_conn);
+ QmlDebugTestClient client("tst_QmlDebugService::isEnabled()", m_conn);
client.setEnabled(true);
- QmlDebuggerTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
QCOMPARE(service.isEnabled(), true);
QTest::ignoreMessage(QtWarningMsg, "QmlDebugService: Conflicting plugin name \"tst_QmlDebugService::isEnabled()\" ");
@@ -100,20 +103,20 @@ void tst_QmlDebugService::isEnabled()
void tst_QmlDebugService::enabledChanged()
{
- QmlDebuggerTestService service("tst_QmlDebugService::enabledChanged()");
- QmlDebuggerTestClient client("tst_QmlDebugService::enabledChanged()", m_conn);
+ QmlDebugTestService service("tst_QmlDebugService::enabledChanged()");
+ QmlDebugTestClient client("tst_QmlDebugService::enabledChanged()", m_conn);
QCOMPARE(service.enabled, false);
client.setEnabled(true);
- QmlDebuggerTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
+ QmlDebugTest::waitForSignal(&service, SIGNAL(enabledStateChanged()));
QCOMPARE(service.enabled, true);
}
void tst_QmlDebugService::sendMessage()
{
- QmlDebuggerTestService service("tst_QmlDebugService::sendMessage()");
- QmlDebuggerTestClient client("tst_QmlDebugService::sendMessage()", m_conn);
+ QmlDebugTestService service("tst_QmlDebugService::sendMessage()");
+ QmlDebugTestClient client("tst_QmlDebugService::sendMessage()", m_conn);
QByteArray msg = "hello!";
@@ -169,54 +172,18 @@ void tst_QmlDebugService::objectToString()
}
-class tst_QmlDebugService_Thread : public QThread
+class tst_QmlDebugService_Factory : public QmlTestFactory
{
- Q_OBJECT
public:
- void run() {
- QTest::qWait(1000);
- connectToEngine();
- }
-
- QPointer<QmlEngine> m_engine;
-
-signals:
- void testsFinished();
-
-public slots:
-
- void connectToEngine()
- {
- QmlDebugConnection conn;
- conn.connectToHost("127.0.0.1", 3768);
- bool ok = conn.waitForConnected(5000);
- Q_ASSERT(ok);
- while (!m_engine)
- QTest::qWait(50);
-
- tst_QmlDebugService test(&conn, m_engine);
- QTest::qExec(&test);
- emit testsFinished();
- }
+ QObject *createTest(QmlDebugTestData *data) { return new tst_QmlDebugService(data); }
};
-
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qputenv("QML_DEBUG_SERVER_PORT", "3768");
-
- tst_QmlDebugService_Thread thread;
- QObject::connect(&thread, SIGNAL(testsFinished()), qApp, SLOT(quit()));
- thread.start();
-
- QmlEngine engine; // blocks until client connects
-
- // start the test
- thread.m_engine = &engine;
-
- return app.exec();
+ tst_QmlDebugService_Factory factory;
+ return QmlDebugTest::runTests(&factory);
}
#include "tst_qmldebugservice.moc"