diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-04-01 18:13:57 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2019-04-25 06:36:27 +0000 |
commit | e2faedb48d9bbfde275bec22aebb5c1ded430e2c (patch) | |
tree | 9b622bc2950a600cf80c3d65342b06158d7f5c7c /tests | |
parent | cf5699e4050b200b9ee80bf4a1c8fbcecb2877af (diff) |
Add an API for closing the connection's transport
Change-Id: I916ddb226b653aaf563ecf0adc3a1110d6da3132
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qcoapclient/tst_qcoapclient.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp index ee61f70..04db9f4 100644 --- a/tests/auto/qcoapclient/tst_qcoapclient.cpp +++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp @@ -154,6 +154,8 @@ public: Q_UNUSED(port); // Do nothing } + + void close() override {} }; class QCoapClientForMulticastTests : public QCoapClient diff --git a/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp b/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp index 6b3f0e9..898466d 100644 --- a/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp +++ b/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp @@ -58,6 +58,7 @@ class tst_QCoapQUdpConnection : public QObject private Q_SLOTS: void ctor(); void connectToHost(); + void reconnect(); void sendRequest_data(); void sendRequest(); }; @@ -105,6 +106,29 @@ void tst_QCoapQUdpConnection::connectToHost() #endif } +void tst_QCoapQUdpConnection::reconnect() +{ +#ifdef QT_BUILD_INTERNAL + QCoapQUdpConnectionForTest connection; + + // This will trigger connection.bind() + QSignalSpy connectionBoundSpy(&connection, SIGNAL(bound())); + connection.sendRequest(QByteArray(), QString(), 0); + QTRY_COMPARE(connectionBoundSpy.count(), 1); + QCOMPARE(connection.state(), QCoapQUdpConnection::Bound); + + connection.disconnect(); + QCOMPARE(connection.state(), QCoapQUdpConnection::Unconnected); + + // Make sure that we are able to connect again + connection.sendRequest(QByteArray(), QString(), 0); + QTRY_COMPARE(connectionBoundSpy.count(), 2); + QCOMPARE(connection.state(), QCoapQUdpConnection::Bound); +#else + QSKIP("Not an internal build, skipping this test"); +#endif +} + void tst_QCoapQUdpConnection::sendRequest_data() { QTest::addColumn<QString>("protocol"); |