diff options
author | Andrew O'Doherty <andrew.odoherty@qt.io> | 2018-10-15 16:26:42 +0200 |
---|---|---|
committer | Andrew O'Doherty <andrew.odoherty@qt.io> | 2018-10-25 11:42:08 +0000 |
commit | 269bd4455d5f702f7e5e0962826a4a0ab92485c0 (patch) | |
tree | 75f053ba3702b5726a18ef2a1fb3de907734e7c4 | |
parent | 5d08db0442d59dc284ad503963fd4333091c9abc (diff) |
Extend tst_QKnxNetIpConnectionStateResponse
Change-Id: I4a5db66b44ce5c2753d2b4451c8b3b63e9bc26f2
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r-- | tests/auto/qknxnetipconnectionstateresponse/tst_qknxnetipconnectionstateresponse.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qknxnetipconnectionstateresponse/tst_qknxnetipconnectionstateresponse.cpp b/tests/auto/qknxnetipconnectionstateresponse/tst_qknxnetipconnectionstateresponse.cpp index decb4c1..f4d99e3 100644 --- a/tests/auto/qknxnetipconnectionstateresponse/tst_qknxnetipconnectionstateresponse.cpp +++ b/tests/auto/qknxnetipconnectionstateresponse/tst_qknxnetipconnectionstateresponse.cpp @@ -29,6 +29,8 @@ #include <QtCore/qdebug.h> #include <QtTest/qtest.h> #include <QtKnx/qknxnetipconnectionstateresponse.h> +#include <QtKnx/QKnxNetIpHpaiProxy> +#include <QtKnx/qknxnetip.h> static QString s_msg; static void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &msg) @@ -43,6 +45,7 @@ class tst_QKnxNetIpConnectionStateResponse: public QObject private slots: void testDefaultConstructor(); void testConstructor(); + void testProxyMethods(); void testDebugStream(); }; @@ -54,6 +57,16 @@ void tst_QKnxNetIpConnectionStateResponse::testDefaultConstructor() QCOMPARE(connectionStateResponse.isValid(), false); QCOMPARE(connectionStateResponse.channelId(), quint8(0)); QCOMPARE(connectionStateResponse.status(), QKnxNetIp::Error::None); + + frame = QKnxNetIpConnectionStateResponseProxy::builder().create(); + const QKnxNetIpConnectionStateResponseProxy response(frame); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QCOMPARE(response.isValid(), false); +#else + // TODO: isValid is not consistent with connection state request and + // connection state response when creating a frame from an empty builder... + QCOMPARE(response.isValid(), true); +#endif } void tst_QKnxNetIpConnectionStateResponse::testConstructor() @@ -74,6 +87,39 @@ void tst_QKnxNetIpConnectionStateResponse::testConstructor() QCOMPARE(connectionStateResponse.status(), QKnxNetIp::Error::ConnectionId); } +void tst_QKnxNetIpConnectionStateResponse::testProxyMethods() +{ + quint8 channelId = 200; + auto status = QKnxNetIp::Error::ConnectionId; + { + // Check channelId(), status() and isValid() with Wrong service type + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::ConnectionStateRequest, + QKnxByteArray { channelId, quint8(status) } }; + const QKnxNetIpConnectionStateResponseProxy view(frame); + QCOMPARE(view.channelId(), channelId); + QCOMPARE(view.status(), status); + QCOMPARE(view.isValid(), false); + } + { + // Check channelId(), status() and isValid() on a valid connection state response + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::ConnectionStateResponse, + QKnxByteArray { channelId, quint8(status) } }; + const QKnxNetIpConnectionStateResponseProxy view(frame); + QCOMPARE(view.channelId(), channelId); + QCOMPARE(view.status(), status); + QCOMPARE(view.isValid(), true); + } + { + // Check channelId(), status() and isValid() on a ivalid connection state response + // with no channelId and status. + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::ConnectionStateResponse }; + const QKnxNetIpConnectionStateResponseProxy view(frame); + QCOMPARE(frame.header().size(), 6); + QCOMPARE(frame.dataSize(), 0); + QCOMPARE(view.isValid(), false); + } +} + void tst_QKnxNetIpConnectionStateResponse::testDebugStream() { struct DebugHandler |