From 13e39c059fbf9dd85f52fb0b7c71ad6f419adee0 Mon Sep 17 00:00:00 2001 From: Andrew O'Doherty Date: Fri, 19 Oct 2018 14:32:51 +0200 Subject: Expand autotest QKnxNetIpDeviceConfigurationAcknowledge Change-Id: I18187a48d3443b4f3af7139bd10070936f8ec9bc Reviewed-by: Karsten Heimrich --- ...tst_qknxnetipdeviceconfigurationacknowledge.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/auto/qknxnetipdeviceconfigurationacknowledge/tst_qknxnetipdeviceconfigurationacknowledge.cpp b/tests/auto/qknxnetipdeviceconfigurationacknowledge/tst_qknxnetipdeviceconfigurationacknowledge.cpp index f348511..34cf0a4 100644 --- a/tests/auto/qknxnetipdeviceconfigurationacknowledge/tst_qknxnetipdeviceconfigurationacknowledge.cpp +++ b/tests/auto/qknxnetipdeviceconfigurationacknowledge/tst_qknxnetipdeviceconfigurationacknowledge.cpp @@ -29,6 +29,7 @@ #include #include #include +#include static QString s_msg; static void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &msg) @@ -44,6 +45,7 @@ private slots: void testDefaultConstructor(); void testConstructor(); void testDebugStream(); + void testProxyMethods(); }; void tst_QKnxNetIpDeviceConfigurationAcknowledge::testDefaultConstructor() @@ -75,6 +77,55 @@ void tst_QKnxNetIpDeviceConfigurationAcknowledge::testConstructor() QCOMPARE(acknowledge.status(), QKnxNetIp::Error::ConnectionId); } +void tst_QKnxNetIpDeviceConfigurationAcknowledge::testProxyMethods() +{ + quint8 channelId = 255; + quint8 sequenceNumber = 250; + auto status = QKnxNetIp::Error::ConnectionId; + auto frame = QKnxNetIpDeviceConfigurationAcknowledgeProxy::builder() + .setChannelId(channelId) + .setSequenceNumber(sequenceNumber) + .setStatus(status) + .create(); + { + // Check channelId(), status() and isValid() with Wrong service type + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::DisconnectRequest, + QKnxNetIpConnectionHeader { channelId, + sequenceNumber, + quint8(status) } + }; + const QKnxNetIpDeviceConfigurationAcknowledgeProxy view(frame); + QCOMPARE(view.channelId(), channelId); + QCOMPARE(view.status(), status); + QCOMPARE(view.sequenceNumber(), sequenceNumber); + QCOMPARE(view.isValid(), false); + } + { + // Check channelId(), status(), sequenceNumber() and isValid() with + // valid device configuration acknowledge frame + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::DeviceConfigurationAcknowledge }; + QCOMPARE(frame.header().size(), 6); + QCOMPARE(frame.dataSize(), 0); + QCOMPARE(frame.size(), 6); + const QKnxNetIpDeviceConfigurationAcknowledgeProxy view(frame); + QCOMPARE(view.isValid(), false); + } + { + // Check channelId(), status(), sequenceNumber() and isValid() with + // valid device configuration acknowledge frame + QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::DeviceConfigurationAcknowledge, + QKnxNetIpConnectionHeader { channelId, + sequenceNumber, + quint8(status) } + }; + const QKnxNetIpDeviceConfigurationAcknowledgeProxy view(frame); + QCOMPARE(view.channelId(), channelId); + QCOMPARE(view.status(), status); + QCOMPARE(view.sequenceNumber(), sequenceNumber); + QCOMPARE(view.isValid(), true); + } +} + void tst_QKnxNetIpDeviceConfigurationAcknowledge::testDebugStream() { struct DebugHandler -- cgit v1.2.3