aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-09-19 12:29:10 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-20 08:47:27 +0200
commit940069e463b149cee85a88f33d26ace46d16ec59 (patch)
tree9b052b8aeb80a6d2f30825d61567f14f97b2b9b1 /tests
parent4bca5b2ff803f4d09350e2d251c90e3b9d60f350 (diff)
QDeclarativeDebug: Allow reconnects to QML debugger port
Allow a new client to attach once the old one was disconnected. Done by Aurindam Jana. Change-Id: Id85045204cc011ec6e02db2658173e652b75c07e Reviewed-on: http://codereview.qt-project.org/5132 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
index b53a92c6bb..220669ad8d 100644
--- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
@@ -50,6 +50,9 @@
#include "../../../shared/util.h"
#include "../shared/debugutil_p.h"
+#define PORT 13770
+#define STR_PORT "13770"
+
class tst_QDeclarativeDebugClient : public QObject
{
Q_OBJECT
@@ -63,11 +66,14 @@ private slots:
void name();
void status();
void sendMessage();
+ void parallelConnect();
+ void sequentialConnect();
};
void tst_QDeclarativeDebugClient::initTestCase()
{
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 13770...");
+ const QString waitingMsg = QString("QDeclarativeDebugServer: Waiting for connection on port %1...").arg(PORT);
+ QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
new QDeclarativeEngine(this);
m_conn = new QDeclarativeDebugConnection(this);
@@ -75,7 +81,7 @@ void tst_QDeclarativeDebugClient::initTestCase()
QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::handshake()", m_conn);
QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
- m_conn->connectToHost("127.0.0.1", 13770);
+ m_conn->connectToHost("127.0.0.1", PORT);
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
bool ok = m_conn->waitForConnected();
@@ -134,14 +140,46 @@ void tst_QDeclarativeDebugClient::sendMessage()
QCOMPARE(resp, msg);
}
+void tst_QDeclarativeDebugClient::parallelConnect()
+{
+ QDeclarativeDebugConnection connection2;
+
+ connection2.connectToHost("127.0.0.1", PORT);
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Another client is already connected");
+ // will connect & immediately disconnect
+ QVERIFY(connection2.waitForConnected());
+ QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState);
+ QVERIFY(m_conn->isConnected());
+}
+
+void tst_QDeclarativeDebugClient::sequentialConnect()
+{
+ QDeclarativeDebugConnection connection2;
+ QDeclarativeDebugTestClient client2("tst_QDeclarativeDebugClient::handshake()", &connection2);
+ QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
+
+ m_conn->close();
+ QVERIFY(!m_conn->isConnected());
+ QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState);
+
+ // Make sure that the disconnect is actually delivered to the server
+ QGuiApplication::processEvents();
+
+ connection2.connectToHost("127.0.0.1", PORT);
+ QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
+ QVERIFY(connection2.waitForConnected());
+ QVERIFY(connection2.isConnected());
+ QTRY_VERIFY(client2.status() == QDeclarativeDebugClient::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:13770";
- _argv[_argc - 1] = arg;
+
+ _argv[_argc - 1] = "-qmljsdebugger=port:" STR_PORT;
QGuiApplication app(_argc, _argv);
tst_QDeclarativeDebugClient tc;