summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-01-31 18:50:13 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-02-03 14:37:49 (GMT)
commitf60ed3a2da4889cce6afbb059773a6c070929bb6 (patch)
tree0970ead015a71cc2144f65e1661a336e5a0e0f7f /tests
parentc466df7e67b1af663be73fca94bb1f2951ba7371 (diff)
downloadQt-f60ed3a2da4889cce6afbb059773a6c070929bb6.zip
Qt-f60ed3a2da4889cce6afbb059773a6c070929bb6.tar.gz
Qt-f60ed3a2da4889cce6afbb059773a6c070929bb6.tar.bz2
Fix low level broadcast test on symbian
Broadcast and multicast are optional features for network interfaces on Symbian. WLAN supports both, while IPv4 and IPv6 loopback support only multicast. The test tries to start the bearer, to get an interface that does support broadcast. There is an expect fail for the 0 bytes written case, as this is what happens on symbian if none of the interfaces support broadcast. On the phones which don't have WLAN, this is likely. Reviewed-by: Markus Goetz
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/platformsocketengine/tst_platformsocketengine.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/auto/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
index 2fb3724..fa21ed8 100644
--- a/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
@@ -63,6 +63,10 @@
#include <stddef.h>
#ifdef Q_OS_SYMBIAN
+#include <QNetworkConfigurationManager>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+#include <QScopedPointer>
#define PLATFORMSOCKETENGINE QSymbianSocketEngine
#include <private/qsymbiansocketengine_p.h>
#include <private/qcore_symbian_p.h>
@@ -310,6 +314,20 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
//---------------------------------------------------------------------------
void tst_PlatformSocketEngine::broadcastTest()
{
+#ifdef Q_OS_SYMBIAN
+ //broadcast isn't supported on loopback connections, but is on WLAN
+#ifndef QT_NO_BEARERMANAGEMENT
+ QScopedPointer<QNetworkConfigurationManager> netConfMan(new QNetworkConfigurationManager());
+ QNetworkConfiguration networkConfiguration(netConfMan->defaultConfiguration());
+ QScopedPointer<QNetworkSession> networkSession(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ bool ok = networkSession->waitForOpened(30000);
+ qDebug() << networkSession->isOpen() << networkSession->error() << networkSession->errorString();
+ QVERIFY(ok);
+ }
+#endif
+#endif
#ifdef Q_OS_AIX
QSKIP("Broadcast does not work on darko", SkipAll);
#endif
@@ -327,10 +345,18 @@ void tst_PlatformSocketEngine::broadcastTest()
// Broadcast an inappropriate troll message
QByteArray trollMessage
= "MOOT wtf is a MOOT? talk english not your sutpiD ENGLISH.";
- QVERIFY(broadcastSocket.writeDatagram(trollMessage.data(),
+ qint64 written = broadcastSocket.writeDatagram(trollMessage.data(),
trollMessage.size(),
QHostAddress::Broadcast,
- port) == trollMessage.size());
+ port);
+
+#ifdef Q_OS_SYMBIAN
+ //On symbian, broadcasts return 0 bytes written if none of the interfaces support it.
+ //Notably the loopback interfaces do not. (though they do support multicast!?)
+ if (written == 0)
+ QEXPECT_FAIL("", "No active interface supports broadcast", Abort);
+#endif
+ QCOMPARE((int)written, trollMessage.size());
// Wait until we receive it ourselves
#if defined(Q_OS_FREEBSD)