From 04b0424b8cf1aae3e0d9e8496650ce3329872917 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Sun, 12 May 2019 21:39:37 +0200 Subject: Move resourcesFromCoreLinkList() to the private class This change is based on the feedback from API review. Change-Id: I189b2505c64ba01f6a6294853a12074a0035585a Reviewed-by: Simon Hausmann --- src/coap/qcoapresourcediscoveryreply.cpp | 8 ++++++-- src/coap/qcoapresourcediscoveryreply.h | 3 --- src/coap/qcoapresourcediscoveryreply_p.h | 3 +++ tests/auto/qcoapresource/qcoapresource.pro | 2 +- tests/auto/qcoapresource/tst_qcoapresource.cpp | 8 +++++++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/coap/qcoapresourcediscoveryreply.cpp b/src/coap/qcoapresourcediscoveryreply.cpp index 81affc2..dabdeb6 100644 --- a/src/coap/qcoapresourcediscoveryreply.cpp +++ b/src/coap/qcoapresourcediscoveryreply.cpp @@ -60,7 +60,8 @@ void QCoapResourceDiscoveryReplyPrivate::_q_setContent(const QHostAddress &sende if (QtCoap::isError(responseCode)) { _q_setError(responseCode); } else { - auto res = QCoapResourceDiscoveryReply::resourcesFromCoreLinkList(sender, message.payload()); + auto res = QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList(sender, + message.payload()); resources.append(res); emit q->discovered(q, res); } @@ -117,12 +118,15 @@ QVector QCoapResourceDiscoveryReply::resources() const } /*! + \internal + Decodes the \a data received from the \a sender to a list of QCoapResource objects. The \a data byte array contains the frame returned by the discovery request. */ QVector -QCoapResourceDiscoveryReply::resourcesFromCoreLinkList(const QHostAddress &sender, const QByteArray &data) +QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList(const QHostAddress &sender, + const QByteArray &data) { QVector resourceList; diff --git a/src/coap/qcoapresourcediscoveryreply.h b/src/coap/qcoapresourcediscoveryreply.h index 132f3d7..65f386d 100644 --- a/src/coap/qcoapresourcediscoveryreply.h +++ b/src/coap/qcoapresourcediscoveryreply.h @@ -47,9 +47,6 @@ public: QVector resources() const; - static QVector resourcesFromCoreLinkList( - const QHostAddress &sender, const QByteArray &data); - Q_SIGNALS: void discovered(QCoapResourceDiscoveryReply *reply, QVector resources); diff --git a/src/coap/qcoapresourcediscoveryreply_p.h b/src/coap/qcoapresourcediscoveryreply_p.h index 3d2a539..d074dbf 100644 --- a/src/coap/qcoapresourcediscoveryreply_p.h +++ b/src/coap/qcoapresourcediscoveryreply_p.h @@ -56,6 +56,9 @@ public: void _q_setContent(const QHostAddress &sender, const QCoapMessage &, QtCoap::ResponseCode) override; + static QVector resourcesFromCoreLinkList( + const QHostAddress &sender, const QByteArray &data); + QVector resources; Q_DECLARE_PUBLIC(QCoapResourceDiscoveryReply) diff --git a/tests/auto/qcoapresource/qcoapresource.pro b/tests/auto/qcoapresource/qcoapresource.pro index 6687ad2..8acf36b 100644 --- a/tests/auto/qcoapresource/qcoapresource.pro +++ b/tests/auto/qcoapresource/qcoapresource.pro @@ -1,4 +1,4 @@ -QT = testlib network core-private core coap +QT = testlib network core-private core coap coap-private CONFIG += testcase SOURCES += tst_qcoapresource.cpp diff --git a/tests/auto/qcoapresource/tst_qcoapresource.cpp b/tests/auto/qcoapresource/tst_qcoapresource.cpp index c71b1d9..52743ee 100644 --- a/tests/auto/qcoapresource/tst_qcoapresource.cpp +++ b/tests/auto/qcoapresource/tst_qcoapresource.cpp @@ -33,6 +33,7 @@ #include #include +#include class tst_QCoapResource : public QObject { @@ -133,6 +134,7 @@ void tst_QCoapResource::parseCoreLink_data() void tst_QCoapResource::parseCoreLink() { +#ifdef QT_BUILD_INTERNAL QFETCH(int, resourceNumber); QFETCH(QString, senderAddress); QFETCH(QList, pathList); @@ -145,7 +147,8 @@ void tst_QCoapResource::parseCoreLink() QFETCH(QByteArray, coreLinkList); const QVector resourceList = - QCoapResourceDiscoveryReply::resourcesFromCoreLinkList(QHostAddress(senderAddress), coreLinkList); + QCoapResourceDiscoveryReplyPrivate::resourcesFromCoreLinkList( + QHostAddress(senderAddress), coreLinkList); QCOMPARE(resourceList.size(), resourceNumber); @@ -161,6 +164,9 @@ void tst_QCoapResource::parseCoreLink() QCOMPARE(resource.observable(), observableList[resourceIndex]); ++resourceIndex; } +#else + QSKIP("Not an internal build, skipping this test"); +#endif } QTEST_APPLESS_MAIN(tst_QCoapResource) -- cgit v1.2.3