Fix tst_QUdpSocket::multicastLeaveAfterClose

With IPv6, you cannot bind to a multicast address. You need to bind to a
local address only. The previous tests either checked this or didn't
check the result of bind().

Change-Id: Ief70887d8988fc1bc4394cf6ff34b5d560e5748e
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Thiago Macieira 2014-12-23 15:34:24 -02:00
parent 11b282d581
commit 14c5f149cd

View File

@ -1163,8 +1163,8 @@ void tst_QUdpSocket::multicastJoinBeforeBind()
void tst_QUdpSocket::multicastLeaveAfterClose_data()
{
QTest::addColumn<QHostAddress>("groupAddress");
QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62");
QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114");
QTest::newRow("ipv4") << QHostAddress("239.255.118.62");
QTest::newRow("ipv6") << QHostAddress("FF01::114");
}
void tst_QUdpSocket::multicastLeaveAfterClose()
@ -1180,7 +1180,10 @@ void tst_QUdpSocket::multicastLeaveAfterClose()
#ifdef FORCE_SESSION
udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession));
#endif
QVERIFY2(udpSocket.bind(groupAddress, 0),
QHostAddress bindAddress = QHostAddress::AnyIPv4;
if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol)
bindAddress = QHostAddress::AnyIPv6;
QVERIFY2(udpSocket.bind(bindAddress, 0),
qPrintable(udpSocket.errorString()));
QVERIFY2(udpSocket.joinMulticastGroup(groupAddress),
qPrintable(udpSocket.errorString()));