summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/socket/qtcpsocket
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/socket/qtcpsocket')
-rw-r--r--tests/auto/network/socket/qtcpsocket/CMakeLists.txt6
-rw-r--r--tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp2
-rw-r--r--tests/auto/network/socket/qtcpsocket/stressTest/Test.h2
-rw-r--r--tests/auto/network/socket/qtcpsocket/stressTest/main.cpp2
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp27
5 files changed, 23 insertions, 16 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/CMakeLists.txt b/tests/auto/network/socket/qtcpsocket/CMakeLists.txt
index 051e58f3ab..7b6bb4d881 100644
--- a/tests/auto/network/socket/qtcpsocket/CMakeLists.txt
+++ b/tests/auto/network/socket/qtcpsocket/CMakeLists.txt
@@ -1,6 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtcpsocket LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
if(NOT QT_FEATURE_private_tests)
return()
endif()
diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp b/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
index 4a7c36d1c1..8d6e470220 100644
--- a/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
+++ b/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
// Qt
#include <QByteArray>
#include <QCoreApplication>
diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/Test.h b/tests/auto/network/socket/qtcpsocket/stressTest/Test.h
index f5a19ae16a..495b90d733 100644
--- a/tests/auto/network/socket/qtcpsocket/stressTest/Test.h
+++ b/tests/auto/network/socket/qtcpsocket/stressTest/Test.h
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef TEST_H
#define TEST_H
diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/main.cpp b/tests/auto/network/socket/qtcpsocket/stressTest/main.cpp
index 57fec691d6..f989a4de34 100644
--- a/tests/auto/network/socket/qtcpsocket/stressTest/main.cpp
+++ b/tests/auto/network/socket/qtcpsocket/stressTest/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "Test.h"
#include <QCoreApplication>
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 5dc12b924f..4ec01a9d94 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -1,11 +1,9 @@
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2017 Intel Corporation.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <qglobal.h>
-// To prevent windows system header files from re-defining min/max
-#define NOMINMAX 1
#if defined(_WIN32)
#include <winsock2.h>
#else
@@ -62,6 +60,8 @@
#include "../../../network-settings.h"
+using namespace Qt::StringLiterals;
+
QT_FORWARD_DECLARE_CLASS(QTcpSocket)
class SocketPair;
@@ -283,7 +283,7 @@ tst_QTcpSocket::tst_QTcpSocket()
tmpSocket = 0;
//This code relates to the socketsConstructedBeforeEventLoop test case
- earlyConstructedSockets = new SocketPair;
+ earlyConstructedSockets = new SocketPair(this);
QVERIFY(earlyConstructedSockets->create());
earlyBytesWrittenCount = 0;
earlyReadyReadCount = 0;
@@ -489,12 +489,13 @@ void tst_QTcpSocket::bind_data()
bool testIpv6 = false;
// iterate all interfaces, add all addresses on them as test data
- QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
- foreach (const QNetworkInterface &netinterface, interfaces) {
+ const QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
+ for (const QNetworkInterface &netinterface : interfaces) {
if (!netinterface.isValid())
continue;
- foreach (const QNetworkAddressEntry &entry, netinterface.addressEntries()) {
+ const auto entries = netinterface.addressEntries();
+ for (const QNetworkAddressEntry &entry : entries) {
if (entry.ip().isInSubnet(QHostAddress::parseSubnet("fe80::/10"))
|| entry.ip().isInSubnet(QHostAddress::parseSubnet("169.254/16")))
continue; // link-local bind will fail, at least on Linux, so skip it.
@@ -524,12 +525,12 @@ void tst_QTcpSocket::bind_data()
// these ranges are guaranteed to be reserved for 'documentation purposes',
// and thus, should be unused in the real world. Not that I'm assuming the
// world is full of competent administrators, or anything.
- QStringList knownBad;
- knownBad << "198.51.100.1";
- knownBad << "2001:0DB8::1";
- foreach (const QString &badAddress, knownBad) {
+ const QString knownBad[] = {
+ u"198.51.100.1"_s,
+ u"2001:0DB8::1"_s
+ };
+ for (const QString &badAddress : knownBad)
QTest::addRow("%s:0", badAddress.toLatin1().constData()) << badAddress << 0 << false << QString();
- }
// try to bind to a privileged ports
// we should fail if we're not root (unless the ports are in use!)
@@ -2582,7 +2583,7 @@ void tst_QTcpSocket::moveToThread0()
{
// Case 1: Moved after connecting, before waiting for connection.
- QTcpSocket *socket = newSocket();;
+ QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
socket->moveToThread(0);
QVERIFY(socket->waitForConnected(5000));