diff options
Diffstat (limited to 'tests/auto/network/socket/qudpsocket')
3 files changed, 65 insertions, 29 deletions
diff --git a/tests/auto/network/socket/qudpsocket/clientserver/main.cpp b/tests/auto/network/socket/qudpsocket/clientserver/main.cpp index 44e75c554f..db48a0c830 100644 --- a/tests/auto/network/socket/qudpsocket/clientserver/main.cpp +++ b/tests/auto/network/socket/qudpsocket/clientserver/main.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 49a3a720c7..8de9987ed1 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1,8 +1,8 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2015 The Qt Company Ltd. ** Copyright (C) 2015 Intel Corporation. -** Contact: http://www.qt-project.org/legal +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -11,9 +11,9 @@ ** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -24,8 +24,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -85,7 +85,8 @@ private slots: void dualStack(); void dualStackAutoBinding(); void dualStackNoIPv4onV6only(); - void readLine(); + void connectToHost(); + void bindAndConnectToHost(); void pendingDatagramSize(); void writeDatagram(); void performance(); @@ -94,10 +95,8 @@ private slots: void writeDatagramToNonExistingPeer(); void writeToNonExistingPeer_data(); void writeToNonExistingPeer(); -#ifndef QT_NO_PROCESS void outOfProcessConnectedClientServerTest(); void outOfProcessUnconnectedClientServerTest(); -#endif void zeroLengthDatagram(); void multicastTtlOption_data(); void multicastTtlOption(); @@ -621,7 +620,7 @@ void tst_QUdpSocket::empty_connectedSlot() //---------------------------------------------------------------------------------- -void tst_QUdpSocket::readLine() +void tst_QUdpSocket::connectToHost() { QUdpSocket socket1; QUdpSocket socket2; @@ -629,6 +628,7 @@ void tst_QUdpSocket::readLine() socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif + QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); socket2.connectToHost(makeNonAny(socket1.localAddress()), socket1.localPort()); @@ -637,6 +637,36 @@ void tst_QUdpSocket::readLine() //---------------------------------------------------------------------------------- +void tst_QUdpSocket::bindAndConnectToHost() +{ + QUdpSocket socket1; + QUdpSocket socket2; + QUdpSocket dummysocket; +#ifdef FORCE_SESSION + socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); + socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); + dummysocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); +#endif + + // we use the dummy socket to use up a file descriptor + dummysocket.bind(); + + QVERIFY2(socket2.bind(), socket2.errorString().toLatin1()); + quint16 boundPort = socket2.localPort(); + qintptr fd = socket2.socketDescriptor(); + + QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); + + dummysocket.close(); + socket2.connectToHost(makeNonAny(socket1.localAddress()), socket1.localPort()); + QVERIFY(socket2.waitForConnected(5000)); + + QCOMPARE(socket2.localPort(), boundPort); + QCOMPARE(socket2.socketDescriptor(), fd); +} + +//---------------------------------------------------------------------------------- + void tst_QUdpSocket::pendingDatagramSize() { QUdpSocket server; @@ -905,9 +935,11 @@ void tst_QUdpSocket::writeToNonExistingPeer() QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState)); } -#ifndef QT_NO_PROCESS void tst_QUdpSocket::outOfProcessConnectedClientServerTest() { +#ifdef QT_NO_PROCESS + QSKIP("No qprocess support", SkipAll); +#else #if defined(Q_OS_WINCE) QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE)."); #endif @@ -964,12 +996,14 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() QVERIFY(clientProcess.waitForFinished()); serverProcess.kill(); QVERIFY(serverProcess.waitForFinished()); -} #endif +} -#ifndef QT_NO_PROCESS void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() { +#ifdef QT_NO_PROCESS + QSKIP("No qprocess support", SkipAll); +#else #if defined(Q_OS_WINCE) QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE)."); #endif @@ -1027,8 +1061,8 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() QVERIFY(clientProcess.waitForFinished()); serverProcess.kill(); QVERIFY(serverProcess.waitForFinished()); -} #endif +} void tst_QUdpSocket::zeroLengthDatagram() { @@ -1201,6 +1235,8 @@ void tst_QUdpSocket::setMulticastInterface_data() QTest::addColumn<QHostAddress>("address"); QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); foreach (const QNetworkInterface &iface, interfaces) { + if ((iface.flags() & QNetworkInterface::IsUp) == 0) + continue; foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) { QTest::newRow(QString("%1:%2").arg(iface.name()).arg(entry.ip().toString()).toLatin1()) << iface diff --git a/tests/auto/network/socket/qudpsocket/udpServer/main.cpp b/tests/auto/network/socket/qudpsocket/udpServer/main.cpp index 997926bb11..2562e58862 100644 --- a/tests/auto/network/socket/qudpsocket/udpServer/main.cpp +++ b/tests/auto/network/socket/qudpsocket/udpServer/main.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ |