summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew O'Doherty <andrew.odoherty@qt.io>2018-10-09 10:42:47 +0200
committerAndrew O'Doherty <andrew.odoherty@qt.io>2018-10-25 11:41:30 +0000
commite275b354afde8f1b8349623834df2afde93fe1b0 (patch)
treea0be7345908f9264df3085b8f39e40e510334d06 /tests
parent05c0adcf39f3b0e88d0e5784a948a5908edeea58 (diff)
Extend autotest tst_QKnxNetIpTunnelingAcknowledge
Change-Id: I476c5cd44d0919f8bd58ef0e402ad0b057432272 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qknxnetiptunnelingacknowledge/tst_qknxnetiptunnelingacknowledge.cpp84
1 files changed, 83 insertions, 1 deletions
diff --git a/tests/auto/qknxnetiptunnelingacknowledge/tst_qknxnetiptunnelingacknowledge.cpp b/tests/auto/qknxnetiptunnelingacknowledge/tst_qknxnetiptunnelingacknowledge.cpp
index e41e083..3bc8fa3 100644
--- a/tests/auto/qknxnetiptunnelingacknowledge/tst_qknxnetiptunnelingacknowledge.cpp
+++ b/tests/auto/qknxnetiptunnelingacknowledge/tst_qknxnetiptunnelingacknowledge.cpp
@@ -29,6 +29,8 @@
#include <QtCore/qdebug.h>
#include <QtTest/qtest.h>
#include <QtKnx/qknxnetiptunnelingacknowledge.h>
+#include <QtKnx/qknxnetip.h>
+#include <QtKnx/QKnxNetIpConnectionHeader>
static QString s_msg;
static void myMessageHandler(QtMsgType, const QMessageLogContext &, const QString &msg)
@@ -44,6 +46,7 @@ private slots:
void testDefaultConstructor();
void testConstructor();
void testDebugStream();
+ void testValidationTunnelingAcknowledge();
};
void tst_QKnxNetIpTunnelingAcknowledge::testDefaultConstructor()
@@ -52,11 +55,90 @@ void tst_QKnxNetIpTunnelingAcknowledge::testDefaultConstructor()
QKnxNetIpTunnelingAcknowledgeProxy tunneling(frame);
QCOMPARE(tunneling.isValid(), false);
+
+ frame = QKnxNetIpTunnelingAcknowledgeProxy::builder().create();
+ const QKnxNetIpTunnelingAcknowledgeProxy view(frame);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ // TODO: make xxx::builder.create() consistent all around the module.
+ // if no setters used it should create an invalid object.
+ QCOMPARE(tunneling.isValid(), false);
+ QCOMPARE(view.isValid(), false);
+#else
+ QCOMPARE(tunneling.isValid(), true);
+ QCOMPARE(view.isValid(), true);
+#endif
}
void tst_QKnxNetIpTunnelingAcknowledge::testConstructor()
{
- // TODO: implement
+ quint8 channelId = 15;
+ quint8 sequenceNumber = 10;
+ QKnxNetIp::Error status = QKnxNetIp::Error::VersionNotSupported;
+
+ auto ackFrame = QKnxNetIpTunnelingAcknowledgeProxy::builder()
+ .setChannelId(channelId)
+ .setSequenceNumber(sequenceNumber)
+ .setStatus(status)
+ .create();
+
+ QCOMPARE(ackFrame.isValid(), true);
+ QCOMPARE(ackFrame.channelId(), channelId);
+ QCOMPARE(ackFrame.sequenceNumber(), sequenceNumber);
+ QCOMPARE(QKnxNetIp::Error(ackFrame.serviceTypeSpecificValue()), status);
+ QCOMPARE(ackFrame.data(), QKnxByteArray());
+
+ const QKnxNetIpTunnelingAcknowledgeProxy view(ackFrame);
+ QCOMPARE(view.isValid(), true);
+ QCOMPARE(view.channelId(), channelId);
+ QCOMPARE(view.sequenceNumber(), sequenceNumber);
+ QCOMPARE(QKnxNetIp::Error(view.status()), status);
+}
+
+void tst_QKnxNetIpTunnelingAcknowledge::testValidationTunnelingAcknowledge()
+{
+ quint8 channelId = 15;
+ quint8 sequenceNumber = 10;
+ QKnxNetIp::Error status = QKnxNetIp::Error::VersionNotSupported;
+ {
+ // test tunneling Acknowledge frame with wrong service type set
+ auto ackFrame = QKnxNetIpTunnelingAcknowledgeProxy::builder()
+ .setChannelId(channelId)
+ .setSequenceNumber(sequenceNumber)
+ .setStatus(status)
+ .create();
+ QCOMPARE(ackFrame.isValid(), true);
+ const QKnxNetIpTunnelingAcknowledgeProxy view(ackFrame);
+ QCOMPARE(view.isValid(), true);
+ ackFrame.setServiceType(QKnxNetIp::ServiceType::TunnelingRequest);
+ QCOMPARE(view.isValid(), false);
+ }
+ {
+ // missing channelId parameter, sequence number and status in header
+ QKnxNetIpConnectionHeader header;
+ QCOMPARE(header.size(), 0);
+ QCOMPARE(header.isValid(), false);
+ QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::TunnelingAcknowledge,
+ header };
+ QVERIFY(frame.size() != 10);
+ QCOMPARE(frame.isValid(), false);
+ const QKnxNetIpTunnelingAcknowledgeProxy view(frame);
+ QCOMPARE(view.isValid(), false);
+ }
+ {
+ QKnxNetIpConnectionHeader header {
+ channelId,
+ sequenceNumber,
+ quint8(status)
+ };
+ QCOMPARE(header.size(), 4);
+ QCOMPARE(header.isValid(), true);
+ QKnxNetIpFrame frame = { QKnxNetIp::ServiceType::TunnelingAcknowledge,
+ header };
+ QCOMPARE(frame.size(), 10);
+ QCOMPARE(frame.isValid(), true);
+ const QKnxNetIpTunnelingAcknowledgeProxy view(frame);
+ QCOMPARE(view.isValid(), true);
+ }
}
void tst_QKnxNetIpTunnelingAcknowledge::testDebugStream()