aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp39
-rw-r--r--tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp40
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp76
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp1
4 files changed, 59 insertions, 97 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
index 7a8411c49f..6fc6c6a914 100644
--- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -42,6 +42,8 @@
#include "debugutil_p.h"
#include "qqmldebugtestservice.h"
+#include <private/qqmldebugconnector_p.h>
+
#define PORT 13770
#define STR_PORT "13770"
@@ -51,6 +53,7 @@ class tst_QQmlDebugClient : public QObject
private:
QQmlDebugConnection *m_conn;
+ QQmlDebugTestService *m_service;
private slots:
void initTestCase();
@@ -64,14 +67,21 @@ private slots:
void tst_QQmlDebugClient::initTestCase()
{
+ QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
+ QTest::ignoreMessage(QtWarningMsg,
+ "QML debugger: Cannot set plugin key after loading the plugin.");
+
+ m_service = new QQmlDebugTestService("tst_QQmlDebugClient::handshake()");
const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
+ QQmlDebuggingEnabler::startTcpDebugServer(PORT);
+
new QQmlEngine(this);
m_conn = new QQmlDebugConnection(this);
QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
- QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
for (int i = 0; i < 50; ++i) {
// try for 5 seconds ...
@@ -105,14 +115,6 @@ void tst_QQmlDebugClient::state()
QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn);
QCOMPARE(client.state(), QQmlDebugClient::Unavailable);
- {
- QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2);
- QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QCOMPARE(client.serviceVersion(), 2.0f);
- }
-
- QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable);
-
// duplicate plugin name
QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\"");
QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn);
@@ -124,8 +126,7 @@ void tst_QQmlDebugClient::state()
void tst_QQmlDebugClient::sendMessage()
{
- QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()");
- QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
QByteArray msg = "hello!";
@@ -151,7 +152,6 @@ void tst_QQmlDebugClient::sequentialConnect()
{
QQmlDebugConnection connection2;
QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2);
- QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
m_conn->close();
QVERIFY(!m_conn->isConnected());
@@ -166,20 +166,7 @@ void tst_QQmlDebugClient::sequentialConnect()
QTRY_COMPARE(client2.state(), QQmlDebugClient::Enabled);
}
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QQmlDebugClient tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
+QTEST_MAIN(tst_QQmlDebugClient)
#include "tst_qqmldebugclient.moc"
diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
index 748c153822..0343ea77ee 100644
--- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
+++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp
@@ -42,6 +42,8 @@
#include "debugutil_p.h"
#include "qqmldebugtestservice.h"
+#include <private/qqmldebugconnector_p.h>
+
QString fileName;
class tst_QQmlDebugLocal : public QObject
@@ -50,6 +52,7 @@ class tst_QQmlDebugLocal : public QObject
private:
QQmlDebugConnection *m_conn;
+ QQmlDebugTestService *m_service;
bool connect();
@@ -67,16 +70,23 @@ private slots:
void tst_QQmlDebugLocal::initTestCase()
{
+ fileName = QString::fromLatin1("tst_QQmlDebugLocal%1").arg(std::time(0));
+ QQmlDebugConnector::setPluginKey("QQmlDebugServer");
+ QTest::ignoreMessage(QtWarningMsg,
+ "QML debugger: Cannot set plugin key after loading the plugin.");
+ m_service = new QQmlDebugTestService("tst_QQmlDebugLocal::handshake()");
+
const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
m_conn = new QQmlDebugConnection(this);
m_conn->startLocalServer(fileName);
+ QQmlDebuggingEnabler::connectToLocalDebugger(fileName);
+
new QQmlEngine(this);
QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn);
- QQmlDebugTestService service("tst_QQmlDebugLocal::handshake()");
for (int i = 0; i < 50; ++i) {
// try for 5 seconds ...
@@ -109,14 +119,6 @@ void tst_QQmlDebugLocal::state()
QQmlDebugTestClient client("tst_QQmlDebugLocal::state()", m_conn);
QCOMPARE(client.state(), QQmlDebugClient::Unavailable);
- {
- QQmlDebugTestService service("tst_QQmlDebugLocal::state()", 2);
- QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QCOMPARE(client.serviceVersion(), 2.0f);
- }
-
- QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable);
-
// duplicate plugin name
QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugLocal::state()\"");
QQmlDebugClient client2("tst_QQmlDebugLocal::state()", m_conn);
@@ -128,8 +130,7 @@ void tst_QQmlDebugLocal::state()
void tst_QQmlDebugLocal::sendMessage()
{
- QQmlDebugTestService service("tst_QQmlDebugLocal::sendMessage()");
- QQmlDebugTestClient client("tst_QQmlDebugLocal::sendMessage()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn);
QByteArray msg = "hello!";
@@ -140,21 +141,6 @@ void tst_QQmlDebugLocal::sendMessage()
QCOMPARE(resp, msg);
}
-int main(int argc, char *argv[])
-{
- fileName = QString::fromLatin1("tst_QQmlDebugLocal%1").arg(std::time(0));
-
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char *arg = strdup((QString::fromLatin1("-qmljsdebugger=file:") + fileName).toLatin1().data());
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QQmlDebugLocal tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
+QTEST_MAIN(tst_QQmlDebugLocal)
#include "tst_qqmldebuglocal.moc"
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
index 15d8ffff15..6ae59078f6 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -44,6 +44,7 @@
#include "debugutil_p.h"
#include "qqmldebugclient.h"
#include "qqmldebugtestservice.h"
+#include <private/qqmldebugconnector_p.h>
#define PORT 3769
#define STR_PORT "3769"
@@ -53,7 +54,7 @@ class tst_QQmlDebugService : public QQmlDataTest
Q_OBJECT
private:
QQmlDebugConnection *m_conn;
-
+ QQmlDebugTestService *m_service;
private slots:
@@ -72,8 +73,15 @@ private slots:
void tst_QQmlDebugService::initTestCase()
{
QQmlDataTest::initTestCase();
+ QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
+ QTest::ignoreMessage(QtWarningMsg,
+ "QML debugger: Cannot set plugin key after loading the plugin.");
+ m_service = new QQmlDebugTestService("tst_QQmlDebugService", 2);
+
const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT);
QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData());
+ QQmlDebuggingEnabler::startTcpDebugServer(PORT);
+
new QQmlEngine(this);
m_conn = new QQmlDebugConnection(this);
@@ -125,67 +133,64 @@ void tst_QQmlDebugService::checkPortRange()
void tst_QQmlDebugService::name()
{
- QString name = "tst_QQmlDebugService::name()";
-
- QQmlDebugTestService service(name, 1);
- QCOMPARE(service.name(), name);
+ QCOMPARE(m_service->name(), QLatin1String("tst_QQmlDebugService"));
}
void tst_QQmlDebugService::version()
{
- QString name = "tst_QQmlDebugService::name()";
-
- QQmlDebugTestService service(name, 2);
- QCOMPARE(service.version(), 2.0f);
+ QCOMPARE(m_service->version(), 2.0f);
}
void tst_QQmlDebugService::state()
{
- QQmlDebugTestService service("tst_QQmlDebugService::state()");
- QCOMPARE(service.state(), QQmlDebugService::Unavailable);
+ QCOMPARE(m_service->state(), QQmlDebugService::Unavailable);
{
- QQmlDebugTestClient client("tst_QQmlDebugService::state()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugService", m_conn);
QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled);
}
+ QTRY_COMPARE(m_service->state(), QQmlDebugService::Unavailable);
- QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable);
-
- QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\"");
- QQmlDebugTestService duplicate("tst_QQmlDebugService::state()");
+ // We can do this because it will never addService()
+ QTest::ignoreMessage(QtWarningMsg,
+ "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\"");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService");
QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected);
+ QTest::ignoreMessage(QtWarningMsg,
+ "QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered.");
}
void tst_QQmlDebugService::sendMessage()
{
- QQmlDebugTestService service("tst_QQmlDebugService::sendMessage()");
- QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugService", m_conn);
QByteArray msg = "hello!";
QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled);
client.sendMessage(msg);
QByteArray resp = client.waitForResponse();
QCOMPARE(resp, msg);
- QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\"");
- QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()");
+ QTest::ignoreMessage(QtWarningMsg,
+ "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\"");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService");
duplicate.sendMessage("msg");
+ QTest::ignoreMessage(QtWarningMsg,
+ "QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered.");
}
void tst_QQmlDebugService::checkSupportForDataStreamVersion()
{
- QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()");
- QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugService", m_conn);
QByteArray msg = "hello!";
QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled);
client.sendMessage(msg);
QByteArray resp = client.waitForResponse();
@@ -243,13 +248,12 @@ void tst_QQmlDebugService::checkSupportForOldDataStreamVersion()
}
QVERIFY(m_conn->isConnected());
- QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()");
- QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn);
+ QQmlDebugTestClient client("tst_QQmlDebugService", m_conn);
QByteArray msg = "hello!";
QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled);
client.sendMessage(msg);
QByteArray resp = client.waitForResponse();
@@ -257,20 +261,6 @@ void tst_QQmlDebugService::checkSupportForOldDataStreamVersion()
QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_4_7));
}
-
-int main(int argc, char *argv[])
-{
- int _argc = argc + 1;
- char **_argv = new char*[_argc];
- for (int i = 0; i < argc; ++i)
- _argv[i] = argv[i];
- char arg[] = "-qmljsdebugger=port:" STR_PORT ",host:127.0.0.1";
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QQmlDebugService tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
+QTEST_MAIN(tst_QQmlDebugService)
#include "tst_qqmldebugservice.moc"
diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
index 990cb1caa1..94eaa2c083 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp
@@ -37,7 +37,6 @@
QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent)
: QQmlDebugService(s, version, parent)
{
- registerService();
}
void QQmlDebugTestService::messageReceived(const QByteArray &ba)