summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp')
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp60
1 files changed, 24 insertions, 36 deletions
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 87e46bff09..ad88d14bc9 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** 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 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/QCoreApplication>
#include <QtNetwork/QtNetwork>
@@ -104,15 +79,20 @@ void tst_QIODevice::getSetCheck()
//----------------------------------------------------------------------------------
void tst_QIODevice::constructing_QTcpSocket()
{
+#ifdef QT_TEST_SERVER
+ if (!QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143))
+ QSKIP("No network test server available");
+#else
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
+#endif
QTcpSocket socket;
QIODevice *device = &socket;
QVERIFY(!device->isOpen());
- socket.connectToHost(QtNetworkSettings::serverName(), 143);
+ socket.connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket.waitForConnected(30000));
QVERIFY(device->isOpen());
QCOMPARE(device->readChannelCount(), 1);
@@ -130,7 +110,7 @@ void tst_QIODevice::constructing_QTcpSocket()
socket.close();
QCOMPARE(socket.readChannelCount(), 0);
QCOMPARE(socket.writeChannelCount(), 0);
- socket.connectToHost(QtNetworkSettings::serverName(), 143);
+ socket.connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket.waitForConnected(30000));
QVERIFY(device->isOpen());
@@ -191,16 +171,16 @@ void tst_QIODevice::constructing_QFile()
void tst_QIODevice::read_QByteArray()
{
QFile f(QFINDTESTDATA("tst_qiodevice.cpp"));
- f.open(QIODevice::ReadOnly);
+ QVERIFY(f.open(QIODevice::ReadOnly));
QByteArray b = f.read(10);
- QCOMPARE(b.length(), 10);
+ QCOMPARE(b.size(), 10);
b = f.read(256);
- QCOMPARE(b.length(), 256);
+ QCOMPARE(b.size(), 256);
b = f.read(0);
- QCOMPARE(b.length(), 0);
+ QCOMPARE(b.size(), 0);
}
//--------------------------------------------------------------------
@@ -270,9 +250,17 @@ void tst_QIODevice::unget()
result = QByteArray("ZXCV");
lineResult = "ZXCV";
} else {
- if (!QtNetworkSettings::verifyTestNetworkSettings())
- QSKIP("No network test server available");
- socket.connectToHost(QtNetworkSettings::serverName(), 80);
+#ifdef QT_TEST_SERVER
+ const bool hasNetworkServer =
+ QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80);
+#else
+ const bool hasNetworkServer = QtNetworkSettings::verifyTestNetworkSettings();
+#endif
+ if (!hasNetworkServer) {
+ qInfo("No network test server: skipping QTcpSocket part of test.");
+ continue;
+ }
+ socket.connectToHost(QtNetworkSettings::httpServerName(), 80);
socket.write("GET / HTTP/1.0\r\n\r\n");
QVERIFY(socket.waitForReadyRead());
dev = &socket;