From 635ae612f153d0ba00ecb8cee7bdce5a4b218d99 Mon Sep 17 00:00:00 2001 From: Even Oscar Andersen Date: Mon, 2 Jun 2025 07:55:31 +0200 Subject: [PATCH] Implement waitForBytesWritten for the websockets case Not implementing this function causes a lot if Invalid Socket Specified in the tests. Also fixed a problem with broker_connection.h where DefaultVersionTestData did not evaluate to version(0) if MQTT_TEST_PROTOCOL was defined. Fixes: QTBUG-137305 Pick-to: 6.10 Change-Id: I4b825196548a3f5bf07c3bb4203a0b46033004ba Reviewed-by: Maurice Kalinowski --- src/mqtt/transportLayers/mqtt_websocket_io_base_p.h | 7 +++++++ tests/common/broker_connection.h | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/mqtt/transportLayers/mqtt_websocket_io_base_p.h b/src/mqtt/transportLayers/mqtt_websocket_io_base_p.h index 203542c..be32f93 100644 --- a/src/mqtt/transportLayers/mqtt_websocket_io_base_p.h +++ b/src/mqtt/transportLayers/mqtt_websocket_io_base_p.h @@ -56,6 +56,13 @@ public: return static_cast(m_buffer.size()) + QIODevice::bytesAvailable(); } + bool waitForBytesWritten(int msecs) override + { + Q_UNUSED(msecs); + m_socket->flush(); + return true; + } + bool isConnected() const { return (m_socket->state() == QAbstractSocket::ConnectedState); diff --git a/tests/common/broker_connection.h b/tests/common/broker_connection.h index 1d6d9f6..b2babfc 100644 --- a/tests/common/broker_connection.h +++ b/tests/common/broker_connection.h @@ -314,7 +314,14 @@ Q_DECLARE_METATYPE(QMqttClient::ProtocolVersion) VersionClientBase(MQTTVERSION, CLIENTNAME, qgetenv("MQTT_TEST_BROKER_TYPE")) #endif - +#ifdef MQTT_TEST_PROTOCOL +#define DefaultVersionTestData(FUNCTION) \ +void FUNCTION() \ +{ \ + QTest::addColumn("mqttVersion"); \ + QTest::newRow("V0") << QMqttClient::ProtocolVersion(0); \ +} +#else #define DefaultVersionTestData(FUNCTION) \ void FUNCTION() \ { \ @@ -326,3 +333,4 @@ void FUNCTION() \ QTest::newRow("V5.0.0") << QMqttClient::MQTT_5_0; \ } \ } +#endif