aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-04-23 09:23:23 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-26 11:46:06 +0200
commit7f7cd79e29e634ddff55fe18b122ac85c5cfe4a0 (patch)
treec6914c9a28eaec0e07309cfdfd60b9da0388912b /tests/auto/qml/debugger
parentc0f07d5707180856bb2705359d780a836653188c (diff)
QmlDebugging: Exchange supported QDataStream versions
Since the client and service needs to pack/unpack datastreams, they need to encode/decode using the lowest common QDataStream version. Change-Id: I3b4886fece59b24950ba618da07a0fefd41a5637 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/qml/debugger')
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp55
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.cpp17
-rw-r--r--tests/auto/qml/debugger/shared/qqmldebugclient.h5
3 files changed, 72 insertions, 5 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
index 12acb9feae..2a561b1859 100644
--- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -52,8 +52,8 @@
#include "qqmldebugclient.h"
#include "qqmldebugtestservice.h"
-#define PORT 13769
-#define STR_PORT "13769"
+#define PORT 3769
+#define STR_PORT "3769"
class tst_QQmlDebugService : public QObject
{
@@ -61,9 +61,10 @@ class tst_QQmlDebugService : public QObject
private:
QQmlDebugConnection *m_conn;
+
private slots:
- void initTestCase();
+ void initTestCase();
void name();
void version();
void state();
@@ -71,6 +72,8 @@ private slots:
void idForObject();
void objectForId();
void objectToString();
+ void checkSupportForDataStreamVersion();
+ void checkSupportForOldDataStreamVersion();
};
void tst_QQmlDebugService::initTestCase()
@@ -147,6 +150,22 @@ void tst_QQmlDebugService::sendMessage()
duplicate.sendMessage("msg");
}
+void tst_QQmlDebugService::checkSupportForDataStreamVersion()
+{
+ QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()");
+ QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+ QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_5_0));
+}
+
void tst_QQmlDebugService::idForObject()
{
QCOMPARE(QQmlDebugService::idForObject(0), -1);
@@ -194,6 +213,36 @@ void tst_QQmlDebugService::objectToString()
delete obj;
}
+void tst_QQmlDebugService::checkSupportForOldDataStreamVersion()
+{
+ //create a new connection;
+ delete m_conn;
+ m_conn = new QQmlDebugConnection(this);
+ m_conn->setDataStreamVersion(QDataStream::Qt_4_7);
+ for (int i = 0; i < 50; ++i) {
+ // try for 5 seconds ...
+ m_conn->connectToHost("127.0.0.1", PORT);
+ if (m_conn->waitForConnected())
+ break;
+ QTest::qSleep(100);
+ }
+ QVERIFY(m_conn->isConnected());
+
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+ QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()");
+ QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+ QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_4_7));
+}
+
int main(int argc, char *argv[])
{
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
index f0fa499b9f..e36d596a49 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp
@@ -112,7 +112,8 @@ void QQmlDebugConnectionPrivate::advertisePlugins()
void QQmlDebugConnectionPrivate::connected()
{
QPacket pack;
- pack << serverId << 0 << protocolVersion << plugins.keys();
+ pack << serverId << 0 << protocolVersion << plugins.keys()
+ << q->m_dataStreamVersion;
protocol->send(pack);
q->flush();
}
@@ -148,6 +149,7 @@ void QQmlDebugConnectionPrivate::readyRead()
serverPlugins.insert(pluginNames.at(i), pluginVersion);
}
+ pack >> q->m_dataStreamVersion;
validHello = true;
}
}
@@ -247,7 +249,8 @@ void QQmlDebugConnectionPrivate::handshakeTimeout()
}
QQmlDebugConnection::QQmlDebugConnection(QObject *parent)
- : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this))
+ : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this)),
+ m_dataStreamVersion(QDataStream::Qt_5_0)
{
}
@@ -260,6 +263,16 @@ QQmlDebugConnection::~QQmlDebugConnection()
}
}
+void QQmlDebugConnection::setDataStreamVersion(int dataStreamVersion)
+{
+ m_dataStreamVersion = dataStreamVersion;
+}
+
+int QQmlDebugConnection::dataStreamVersion()
+{
+ return m_dataStreamVersion;
+}
+
bool QQmlDebugConnection::isConnected() const
{
return state() == QAbstractSocket::ConnectedState;
diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h
index 0f140a1db1..5275d41431 100644
--- a/tests/auto/qml/debugger/shared/qqmldebugclient.h
+++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h
@@ -55,6 +55,9 @@ public:
void connectToHost(const QString &hostName, quint16 port);
+ void setDataStreamVersion(int dataStreamVersion);
+ int dataStreamVersion();
+
qint64 bytesAvailable() const;
bool isConnected() const;
QAbstractSocket::SocketState state() const;
@@ -74,8 +77,10 @@ protected:
private:
QQmlDebugConnectionPrivate *d;
+ int m_dataStreamVersion;
friend class QQmlDebugClient;
friend class QQmlDebugClientPrivate;
+ friend class QQmlDebugConnectionPrivate;
};
class QQmlDebugClientPrivate;