diff options
author | Chris Craig <ext-chris.craig@nokia.com> | 2012-05-29 15:47:06 -0400 |
---|---|---|
committer | Chris Craig <ext-chris.craig@nokia.com> | 2012-05-30 23:38:51 +0200 |
commit | 2beb33bc03b3b83aeaf83e1a5b0919c5f1ab3bef (patch) | |
tree | 9ae23bc5a860fad5c682bec008bf2d07e8e7a918 /tests | |
parent | b19fec0ecd76e36f21283c75c2ddbf265f6a11b5 (diff) |
handle endpoint name change
Change-Id: I53800873d9929d4b6f8b967327974ed916b8fc48
Reviewed-by: Alexei Rousskikh <ext-alexei.rousskikh@nokia.com>
Reviewed-by: Chris Craig <ext-chris.craig@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/jsonconnection/tst_jsonconnection.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/jsonconnection/tst_jsonconnection.cpp b/tests/auto/jsonconnection/tst_jsonconnection.cpp index b32c7d2..458022f 100644 --- a/tests/auto/jsonconnection/tst_jsonconnection.cpp +++ b/tests/auto/jsonconnection/tst_jsonconnection.cpp @@ -307,6 +307,7 @@ private slots: void multipleEndpointsTest(); void multipleThreadTest(); void autoreconnectTest(); + void nameChangeTest(); private: void registerQmlTypes(); @@ -857,6 +858,42 @@ void tst_JsonConnection::autoreconnectTest() child.waitForFinished(); } +void tst_JsonConnection::nameChangeTest() +{ + QString socketname = "/tmp/tst_socket"; + + Child child("testClient/testClient", + QStringList() << "-socket" << socketname); + + QSignalSpy spy0(&child, SIGNAL(serverReady())); + waitForSpy(spy0, 1); + + ConnectionContainer c(socketname,true); + c.connection()->setAutoReconnectEnabled(true); + QSignalSpy spyDef(&c, SIGNAL(messageReceived(const QJsonObject&, QObject *)));; + + JsonEndpoint *endpoint = c.addEndpoint("wrong"); + QVERIFY(endpoint->name() == "wrong"); + + QVERIFY(c.connection()->state() == JsonConnection::Unconnected); + c.doConnect(); + QVERIFY(c.connection()->state() == JsonConnection::Connected); + + c.sendMessage("test"); + + waitForSpy(spyDef, 1); + QObject *source = (spyDef.at(0).at(1)).value<QObject *>(); + QVERIFY(source == c.connection()->defaultEndpoint()); + spyDef.clear(); + + endpoint->setName("test"); + c.sendMessage("test"); + + waitForSpy(spyDef,1); + source = (spyDef.at(0).at(1)).value<QObject *>(); + QVERIFY(source == endpoint); +} + QTEST_MAIN (tst_JsonConnection) |