aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-05-09 18:01:35 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-05-14 15:14:33 +0000
commit804b10f3297822f4b12a4b971633f78965b756b0 (patch)
tree2eee142aaf317e74ca66eb96c535cffd461fca5e
parent18289e7c1d2778460dccb1135fe283bd234954ad (diff)
Hide the APIs of QCoapConnection and QCoapQUdpConnection
At the moment only the QCoapQUdpConnection class implements the QCoapConnection interface. If later we decide to add other implementations, and it turns out that the current API is not good enough, it won't be possible to change it without breaking the source compatibility. Let's make these classes private, we can make them public when there is a need for it. Change-Id: I41336dda0e6eaa762f0eb9c8f4aa98a9c7b62a2c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/coap/coap.pro2
-rw-r--r--src/coap/qcoapclient.cpp2
-rw-r--r--src/coap/qcoapclient_p.h1
-rw-r--r--src/coap/qcoapconnection.cpp28
-rw-r--r--src/coap/qcoapconnection.h87
-rw-r--r--src/coap/qcoapconnection_p.h49
-rw-r--r--src/coap/qcoapinternalrequest_p.h2
-rw-r--r--src/coap/qcoapprotocol.cpp1
-rw-r--r--src/coap/qcoapqudpconnection.cpp8
-rw-r--r--src/coap/qcoapqudpconnection.h81
-rw-r--r--src/coap/qcoapqudpconnection_p.h35
-rw-r--r--tests/auto/qcoapclient/tst_qcoapclient.cpp19
-rw-r--r--tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp28
13 files changed, 153 insertions, 190 deletions
diff --git a/src/coap/coap.pro b/src/coap/coap.pro
index 024de15..11e6932 100644
--- a/src/coap/coap.pro
+++ b/src/coap/coap.pro
@@ -7,14 +7,12 @@ QMAKE_DOCS = $$PWD/doc/qtcoap.qdocconf
PUBLIC_HEADERS += \
qcoapclient.h \
- qcoapconnection.h \
qcoapdiscoveryreply.h \
qcoapglobal.h \
qcoapmessage.h \
qcoapnamespace.h \
qcoapoption.h \
qcoapprotocol.h \
- qcoapqudpconnection.h \
qcoapreply.h \
qcoaprequest.h \
qcoapresource.h \
diff --git a/src/coap/qcoapclient.cpp b/src/coap/qcoapclient.cpp
index 767f7f0..21af3e2 100644
--- a/src/coap/qcoapclient.cpp
+++ b/src/coap/qcoapclient.cpp
@@ -34,7 +34,7 @@
#include "qcoapdiscoveryreply.h"
#include "qcoapnamespace.h"
#include "qcoapsecurityconfiguration.h"
-#include "qcoapqudpconnection.h"
+#include "qcoapqudpconnection_p.h"
#include <QtCore/qiodevice.h>
#include <QtCore/qurl.h>
#include <QtCore/qloggingcategory.h>
diff --git a/src/coap/qcoapclient_p.h b/src/coap/qcoapclient_p.h
index 40db811..60cd59d 100644
--- a/src/coap/qcoapclient_p.h
+++ b/src/coap/qcoapclient_p.h
@@ -31,7 +31,6 @@
#ifndef QCOAPCLIENT_P_H
#define QCOAPCLIENT_P_H
-#include <QtCoap/qcoapconnection.h>
#include <QtCoap/qcoapclient.h>
#include <QtCoap/qcoapprotocol.h>
#include <QtCore/qthread.h>
diff --git a/src/coap/qcoapconnection.cpp b/src/coap/qcoapconnection.cpp
index 96e98fa..e104fee 100644
--- a/src/coap/qcoapconnection.cpp
+++ b/src/coap/qcoapconnection.cpp
@@ -36,6 +36,8 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
/*!
+ \internal
+
\class QCoapConnection
\inmodule QtCoap
@@ -47,6 +49,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\enum QCoapConnection::ConnectionState
This enum specifies the state of the underlying transport.
@@ -60,6 +64,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::error(QAbstractSocket::SocketError error)
This signal is emitted when a connection error occurs. The \a error
@@ -67,6 +73,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::readyRead(const QByteArray &data, const QHostAddress &sender)
This signal is emitted when a network reply is available. The \a data
@@ -75,6 +83,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::bound()
This signal is emitted when the underlying transport is ready for data transmission.
@@ -91,6 +101,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::bind(const QString &host, quint16 port)
Prepares the underlying transport for data transmission to to the given \a host
@@ -102,6 +114,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::close()
Closes the open sockets and connections to free the underlying transport.
@@ -111,6 +125,8 @@ Q_LOGGING_CATEGORY(lcCoapConnection, "qt.coap.connection")
*/
/*!
+ \internal
+
\fn void QCoapConnection::writeData(const QByteArray &data, const QString &host, quint16 port)
Sends the given \a data frame to the host address \a host at port \a port.
@@ -151,6 +167,8 @@ QCoapConnection::QCoapConnection(QObjectPrivate &dd, QObject *parent)
}
/*!
+ \internal
+
Releases any resources held by QCoapConnection.
*/
QCoapConnection::~QCoapConnection()
@@ -182,6 +200,8 @@ QCoapConnectionPrivate::sendRequest(const QByteArray &request, const QString &ho
}
/*!
+ \internal
+
Returns \c true if security is used, returns \c false otherwise.
*/
bool QCoapConnection::isSecure() const
@@ -191,6 +211,8 @@ bool QCoapConnection::isSecure() const
}
/*!
+ \internal
+
Returns the security mode.
*/
QtCoap::SecurityMode QCoapConnection::securityMode() const
@@ -200,6 +222,8 @@ QtCoap::SecurityMode QCoapConnection::securityMode() const
}
/*!
+ \internal
+
Returns the connection state.
*/
QCoapConnection::ConnectionState QCoapConnection::state() const
@@ -243,6 +267,8 @@ void QCoapConnection::setSecurityConfiguration(const QCoapSecurityConfiguration
}
/*!
+ \internal
+
Returns the security configuration.
*/
QCoapSecurityConfiguration QCoapConnection::securityConfiguration() const
@@ -252,6 +278,8 @@ QCoapSecurityConfiguration QCoapConnection::securityConfiguration() const
}
/*!
+ \internal
+
Closes the open sockets and connections to free the transport and clears
the connection state.
*/
diff --git a/src/coap/qcoapconnection.h b/src/coap/qcoapconnection.h
deleted file mode 100644
index 6f2931f..0000000
--- a/src/coap/qcoapconnection.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCoap module.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOAPCONNECTION_H
-#define QCOAPCONNECTION_H
-
-#include <QtCoap/qcoapglobal.h>
-#include <QtCoap/qcoapnamespace.h>
-#include <QtCoap/qcoapsecurityconfiguration.h>
-
-#include <QtNetwork/QAbstractSocket>
-
-QT_BEGIN_NAMESPACE
-
-class QCoapConnectionPrivate;
-class Q_COAP_EXPORT QCoapConnection : public QObject
-{
- Q_OBJECT
-public:
- enum class ConnectionState : quint8 {
- Unconnected,
- Bound
- };
-
- explicit QCoapConnection(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSec,
- QObject *parent = nullptr);
- virtual ~QCoapConnection();
-
- bool isSecure() const;
- QtCoap::SecurityMode securityMode() const;
- ConnectionState state() const;
- QCoapSecurityConfiguration securityConfiguration() const;
-
- Q_INVOKABLE void setSecurityConfiguration(const QCoapSecurityConfiguration &configuration);
- Q_INVOKABLE void disconnect();
-
-Q_SIGNALS:
- void error(QAbstractSocket::SocketError error);
- void readyRead(const QByteArray &data, const QHostAddress &sender);
- void bound();
- void securityConfigurationChanged();
-
-private:
- void startToSendRequest();
-
-protected:
- QCoapConnection(QObjectPrivate &dd, QObject *parent = nullptr);
-
- virtual void bind(const QString &host, quint16 port) = 0;
- virtual void writeData(const QByteArray &data, const QString &host, quint16 port) = 0;
- virtual void close() = 0;
-
-private:
- friend class QCoapProtocolPrivate;
-
- Q_DECLARE_PRIVATE(QCoapConnection)
-};
-
-QT_END_NAMESPACE
-
-#endif // QCOAPCONNECTION_H
diff --git a/src/coap/qcoapconnection_p.h b/src/coap/qcoapconnection_p.h
index d75c794..07abe4a 100644
--- a/src/coap/qcoapconnection_p.h
+++ b/src/coap/qcoapconnection_p.h
@@ -30,9 +30,12 @@
#ifndef QCOAPCONNECTION_P_H
#define QCOAPCONNECTION_P_H
-#include <QtCoap/qcoapconnection.h>
+#include <QtCoap/qcoapnamespace.h>
+#include <QtCoap/qcoapsecurityconfiguration.h>
#include <QtCore/qqueue.h>
+#include <QtCore/qobject.h>
+#include <QtNetwork/qabstractsocket.h>
#include <private/qobject_p.h>
//
@@ -48,6 +51,50 @@
QT_BEGIN_NAMESPACE
+class QCoapConnectionPrivate;
+class Q_AUTOTEST_EXPORT QCoapConnection : public QObject
+{
+ Q_OBJECT
+public:
+ enum class ConnectionState : quint8 {
+ Unconnected,
+ Bound
+ };
+
+ explicit QCoapConnection(QtCoap::SecurityMode securityMode = QtCoap::SecurityMode::NoSec,
+ QObject *parent = nullptr);
+ virtual ~QCoapConnection();
+
+ bool isSecure() const;
+ QtCoap::SecurityMode securityMode() const;
+ ConnectionState state() const;
+ QCoapSecurityConfiguration securityConfiguration() const;
+
+ Q_INVOKABLE void setSecurityConfiguration(const QCoapSecurityConfiguration &configuration);
+ Q_INVOKABLE void disconnect();
+
+Q_SIGNALS:
+ void error(QAbstractSocket::SocketError error);
+ void readyRead(const QByteArray &data, const QHostAddress &sender);
+ void bound();
+ void securityConfigurationChanged();
+
+private:
+ void startToSendRequest();
+
+protected:
+ QCoapConnection(QObjectPrivate &dd, QObject *parent = nullptr);
+
+ virtual void bind(const QString &host, quint16 port) = 0;
+ virtual void writeData(const QByteArray &data, const QString &host, quint16 port) = 0;
+ virtual void close() = 0;
+
+private:
+ friend class QCoapProtocolPrivate;
+
+ Q_DECLARE_PRIVATE(QCoapConnection)
+};
+
struct CoapFrame {
QByteArray currentPdu;
QString host;
diff --git a/src/coap/qcoapinternalrequest_p.h b/src/coap/qcoapinternalrequest_p.h
index 549f5f0..f6875b3 100644
--- a/src/coap/qcoapinternalrequest_p.h
+++ b/src/coap/qcoapinternalrequest_p.h
@@ -35,7 +35,7 @@
#include <QtCoap/qcoapglobal.h>
#include <QtCoap/qcoapnamespace.h>
-#include <QtCoap/qcoapconnection.h>
+#include <private/qcoapconnection_p.h>
#include <QtCore/qglobal.h>
#include <QtCore/qtimer.h>
diff --git a/src/coap/qcoapprotocol.cpp b/src/coap/qcoapprotocol.cpp
index dd5f25d..63ee393 100644
--- a/src/coap/qcoapprotocol.cpp
+++ b/src/coap/qcoapprotocol.cpp
@@ -31,7 +31,6 @@
#include "qcoapprotocol_p.h"
#include "qcoapinternalrequest_p.h"
#include "qcoapinternalreply_p.h"
-#include "qcoapconnection.h"
#include "qcoapconnection_p.h"
#include <QtCore/qrandom.h>
diff --git a/src/coap/qcoapqudpconnection.cpp b/src/coap/qcoapqudpconnection.cpp
index e38fe5b..08d96d1 100644
--- a/src/coap/qcoapqudpconnection.cpp
+++ b/src/coap/qcoapqudpconnection.cpp
@@ -45,6 +45,8 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcCoapConnection)
/*!
+ \internal
+
\class QCoapQUdpConnection
\inmodule QtCoap
@@ -266,6 +268,8 @@ void QCoapQUdpConnection::close()
}
/*!
+ \internal
+
Sets the QUdpSocket socket \a option to \a value.
*/
void QCoapQUdpConnection::setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
@@ -339,6 +343,8 @@ void QCoapQUdpConnectionPrivate::socketReadyRead()
}
/*!
+ \internal
+
Returns the socket.
*/
QUdpSocket *QCoapQUdpConnection::socket() const
@@ -468,5 +474,3 @@ void QCoapQUdpConnectionPrivate::handleEncryptedDatagram()
#endif // dtls
QT_END_NAMESPACE
-
-#include "moc_qcoapqudpconnection.cpp"
diff --git a/src/coap/qcoapqudpconnection.h b/src/coap/qcoapqudpconnection.h
deleted file mode 100644
index f9ca356..0000000
--- a/src/coap/qcoapqudpconnection.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 Witekio.
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCoap module.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOAPQUDPCONNECTION_H
-#define QCOAPQUDPCONNECTION_H
-
-#include <QtCoap/qcoapconnection.h>
-#include <QtCoap/qcoapnamespace.h>
-#include <QtCoap/qcoapglobal.h>
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qstring.h>
-#include <QtNetwork/qudpsocket.h>
-
-QT_BEGIN_NAMESPACE
-
-class QCoapQUdpConnectionPrivate;
-class QSslPreSharedKeyAuthenticator;
-class Q_COAP_EXPORT QCoapQUdpConnection : public QCoapConnection
-{
- Q_OBJECT
-
-public:
- explicit QCoapQUdpConnection(QtCoap::SecurityMode security = QtCoap::SecurityMode::NoSec,
- QObject *parent = nullptr);
-
- ~QCoapQUdpConnection() override = default;
-
- QUdpSocket *socket() const;
-
-public Q_SLOTS:
- void setSocketOption(QAbstractSocket::SocketOption, const QVariant &value);
-
-#if QT_CONFIG(dtls)
-private Q_SLOTS:
- void pskRequired(QSslPreSharedKeyAuthenticator *authenticator);
- void handshakeTimeout();
-#endif
-
-protected:
- explicit QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject *parent = nullptr);
-
- void bind(const QString &host, quint16 port) override;
- void writeData(const QByteArray &data, const QString &host, quint16 port) override;
- void close() override;
-
- void createSocket();
-
- Q_DECLARE_PRIVATE(QCoapQUdpConnection)
-};
-
-QT_END_NAMESPACE
-
-#endif // QCOAPQUDPCONNECTION_H
diff --git a/src/coap/qcoapqudpconnection_p.h b/src/coap/qcoapqudpconnection_p.h
index 3901af8..1ac1603 100644
--- a/src/coap/qcoapqudpconnection_p.h
+++ b/src/coap/qcoapqudpconnection_p.h
@@ -31,7 +31,6 @@
#ifndef QCOAPQUDPCONNECTION_P_H
#define QCOAPQUDPCONNECTION_P_H
-#include <QtCoap/qcoapqudpconnection.h>
#include <QtCoap/qcoapsecurityconfiguration.h>
#include <private/qcoapconnection_p.h>
@@ -53,6 +52,40 @@ QT_BEGIN_NAMESPACE
class QDtls;
class QSslPreSharedKeyAuthenticator;
+class QCoapQUdpConnectionPrivate;
+class Q_AUTOTEST_EXPORT QCoapQUdpConnection : public QCoapConnection
+{
+ Q_OBJECT
+
+public:
+ explicit QCoapQUdpConnection(QtCoap::SecurityMode security = QtCoap::SecurityMode::NoSec,
+ QObject *parent = nullptr);
+
+ ~QCoapQUdpConnection() override = default;
+
+ QUdpSocket *socket() const;
+
+public Q_SLOTS:
+ void setSocketOption(QAbstractSocket::SocketOption, const QVariant &value);
+
+#if QT_CONFIG(dtls)
+private Q_SLOTS:
+ void pskRequired(QSslPreSharedKeyAuthenticator *authenticator);
+ void handshakeTimeout();
+#endif
+
+protected:
+ explicit QCoapQUdpConnection(QCoapQUdpConnectionPrivate &dd, QObject *parent = nullptr);
+
+ void bind(const QString &host, quint16 port) override;
+ void writeData(const QByteArray &data, const QString &host, quint16 port) override;
+ void close() override;
+
+ void createSocket();
+
+ Q_DECLARE_PRIVATE(QCoapQUdpConnection)
+};
+
class Q_AUTOTEST_EXPORT QCoapQUdpConnectionPrivate : public QCoapConnectionPrivate
{
public:
diff --git a/tests/auto/qcoapclient/tst_qcoapclient.cpp b/tests/auto/qcoapclient/tst_qcoapclient.cpp
index 3e5eac0..90b44cf 100644
--- a/tests/auto/qcoapclient/tst_qcoapclient.cpp
+++ b/tests/auto/qcoapclient/tst_qcoapclient.cpp
@@ -77,6 +77,8 @@ private Q_SLOTS:
void multicast_blockwise();
};
+#ifdef QT_BUILD_INTERNAL
+
class QCoapQUdpConnectionSocketTestsPrivate : public QCoapQUdpConnectionPrivate
{
bool bind() override
@@ -172,6 +174,7 @@ public:
}
};
+#endif
class Helper : public QObject
{
@@ -347,6 +350,7 @@ void tst_QCoapClient::setBlockSize_data()
void tst_QCoapClient::setBlockSize()
{
+#ifdef QT_BUILD_INTERNAL
QFETCH(int, blockSizeSet);
QFETCH(int, blockSizeExpected);
@@ -358,6 +362,9 @@ void tst_QCoapClient::setBlockSize()
eventLoop.exec();
QCOMPARE(client.protocol()->blockSize(), blockSizeExpected);
+#else
+ QSKIP("Not an internal build, skipping this test");
+#endif
}
void tst_QCoapClient::requestWithQIODevice_data()
@@ -479,6 +486,7 @@ void tst_QCoapClient::timeout_data()
void tst_QCoapClient::timeout()
{
+#ifdef QT_BUILD_INTERNAL
QFETCH(int, timeout);
QFETCH(int, maxRetransmit);
@@ -520,6 +528,9 @@ void tst_QCoapClient::timeout()
QCOMPARE(spyReplyFinished.count(), 1);
QCOMPARE(spyReplyAborted.count(), 0);
QCOMPARE(spyClientError.count(), 1);
+#else
+ QSKIP("Not an internal build, skipping this test");
+#endif
}
void tst_QCoapClient::abort()
@@ -786,6 +797,7 @@ void tst_QCoapClient::confirmableMulticast()
void tst_QCoapClient::multicast()
{
+#ifdef QT_BUILD_INTERNAL
QCoapClientForMulticastTests client;
QCoapRequest request = QCoapRequest(QUrl("224.0.1.187"));
request.setToken("abc");
@@ -811,10 +823,14 @@ void tst_QCoapClient::multicast()
QCOMPARE(message1.payload(), "Reply1");
QHostAddress sender1 = qvariant_cast<QHostAddress>(spyMulticastResponse.at(1).at(2));
QCOMPARE(sender1, host1);
+#else
+ QSKIP("Not an internal build, skipping this test");
+#endif
}
void tst_QCoapClient::multicast_blockwise()
{
+#ifdef QT_BUILD_INTERNAL
QCoapClientForMulticastTests client;
QCoapRequest request = QCoapRequest(QUrl("224.0.1.187"));
request.setToken("abc");
@@ -842,6 +858,9 @@ void tst_QCoapClient::multicast_blockwise()
QCOMPARE(message1.payload(), "Reply3Reply4");
QHostAddress sender1 = qvariant_cast<QHostAddress>(spyMulticastResponse.at(1).at(2));
QCOMPARE(sender1, host1);
+#else
+ QSKIP("Not an internal build, skipping this test");
+#endif
}
QTEST_MAIN(tst_QCoapClient)
diff --git a/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp b/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp
index 6ce5a87..daed5fb 100644
--- a/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp
+++ b/tests/auto/qcoapqudpconnection/tst_qcoapqudpconnection.cpp
@@ -37,12 +37,13 @@
#include <QtNetwork/qudpsocket.h>
#include <QtNetwork/qnetworkdatagram.h>
#include <QtCoap/qcoapglobal.h>
-#include <QtCoap/qcoapqudpconnection.h>
#include <QtCoap/qcoaprequest.h>
#include <private/qcoapqudpconnection_p.h>
#include <private/qcoapinternalrequest_p.h>
#include "../coapnetworksettings.h"
+#ifdef QT_BUILD_INTERNAL
+
using namespace QtCoapNetworkSettings;
struct QCoapRequestForTest : public QCoapRequest
@@ -86,7 +87,6 @@ void tst_QCoapQUdpConnection::ctor()
void tst_QCoapQUdpConnection::connectToHost()
{
-#ifdef QT_BUILD_INTERNAL
QCoapQUdpConnectionForTest connection;
QUdpSocket *socket = qobject_cast<QUdpSocket*>(connection.socket());
@@ -101,14 +101,10 @@ void tst_QCoapQUdpConnection::connectToHost()
QTRY_COMPARE(spySocketStateChanged.count(), 1);
QTRY_COMPARE(spyConnectionBound.count(), 1);
QCOMPARE(connection.state(), QCoapQUdpConnection::ConnectionState::Bound);
-#else
- QSKIP("Not an internal build, skipping this test");
-#endif
}
void tst_QCoapQUdpConnection::reconnect()
{
-#ifdef QT_BUILD_INTERNAL
QCoapQUdpConnectionForTest connection;
// This will trigger connection.bind()
@@ -124,9 +120,6 @@ void tst_QCoapQUdpConnection::reconnect()
connection.sendRequest(QByteArray(), QString(), 0);
QTRY_COMPARE(connectionBoundSpy.count(), 2);
QCOMPARE(connection.state(), QCoapQUdpConnection::ConnectionState::Bound);
-#else
- QSKIP("Not an internal build, skipping this test");
-#endif
}
void tst_QCoapQUdpConnection::sendRequest_data()
@@ -180,7 +173,6 @@ void tst_QCoapQUdpConnection::sendRequest_data()
void tst_QCoapQUdpConnection::sendRequest()
{
-#ifdef QT_BUILD_INTERNAL
QFETCH(QString, protocol);
QFETCH(QString, host);
QFETCH(QString, path);
@@ -208,10 +200,22 @@ void tst_QCoapQUdpConnection::sendRequest()
QByteArray data = spyConnectionReadyRead.first().first().value<QByteArray>();
QVERIFY(QString(data.toHex()).startsWith(dataHexaHeader));
QVERIFY(QString(data.toHex()).endsWith(dataHexaPayload));
+}
+
#else
- QSKIP("Not an internal build, skipping this test");
+
+class tst_QCoapQUdpConnection : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase()
+ {
+ QSKIP("Not an internal build, nothing to test");
+ }
+};
+
#endif
-}
QTEST_MAIN(tst_QCoapQUdpConnection)