summaryrefslogtreecommitdiffstats
path: root/tests/auto/qudpsocket/tst_qudpsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qudpsocket/tst_qudpsocket.cpp')
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index db18eb5..e064967 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -228,7 +228,7 @@ void tst_QUdpSocket::broadcasting()
for (int j = 0; j < 100; ++j) {
broadcastSocket.writeDatagram(message[i], strlen(message[i]),
- QHostAddress::Broadcast, 5000);
+ QHostAddress::Broadcast, 5000);
QTestEventLoop::instance().enterLoop(15);
if (QTestEventLoop::instance().timeout()) {
#if defined(Q_OS_FREEBSD)
@@ -334,17 +334,17 @@ void tst_QUdpSocket::ipv6Loop()
quint16 paulPort = 28123;
if (!peter.bind(QHostAddress::LocalHostIPv6, peterPort)) {
- QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError);
+ QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError);
} else {
- QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort));
+ QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort));
- QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"),
+ QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"),
paulPort), qint64(peterMessage.length()));
- QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(),
+ QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(),
QHostAddress("::1"), peterPort), qint64(paulMessage.length()));
- char peterBuffer[16*1024];
- char paulBuffer[16*1024];
+ char peterBuffer[16*1024];
+ char paulBuffer[16*1024];
#if !defined(Q_OS_WINCE)
QVERIFY(peter.waitForReadyRead(5000));
QVERIFY(paul.waitForReadyRead(5000));
@@ -352,16 +352,16 @@ void tst_QUdpSocket::ipv6Loop()
QVERIFY(peter.waitForReadyRead(15000));
QVERIFY(paul.waitForReadyRead(15000));
#endif
- if (success) {
- QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length()));
- QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length()));
- } else {
- QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length());
- QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length());
- }
-
- QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage);
- QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage);
+ if (success) {
+ QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length()));
+ QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length()));
+ } else {
+ QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length());
+ QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length());
+ }
+
+ QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage);
+ QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage);
}
}
@@ -483,21 +483,21 @@ void tst_QUdpSocket::writeDatagram()
void tst_QUdpSocket::performance()
{
#if defined(Q_OS_SYMBIAN)
- // Large packets seems not to go through on Symbian
- // Reason might be also fragmentation due to VPN connection etc
-
+ // Large packets seems not to go through on Symbian
+ // Reason might be also fragmentation due to VPN connection etc
+
QFETCH_GLOBAL(bool, setProxy);
- QFETCH_GLOBAL(int, proxyType);
-
+ QFETCH_GLOBAL(int, proxyType);
+
int arrSize = 8192;
- if (setProxy && proxyType == QNetworkProxy::Socks5Proxy)
- arrSize = 1024;
-
- QByteArray arr(arrSize, '@');
+ if (setProxy && proxyType == QNetworkProxy::Socks5Proxy)
+ arrSize = 1024;
+
+ QByteArray arr(arrSize, '@');
#else
- QByteArray arr(8192, '@');
+ QByteArray arr(8192, '@');
#endif // Q_OS_SYMBIAN
-
+
QUdpSocket server;
QVERIFY2(server.bind(), server.errorString().toLatin1().constData());
@@ -507,13 +507,13 @@ void tst_QUdpSocket::performance()
QUdpSocket client;
client.connectToHost(serverAddress, server.localPort());
-
+
QTime stopWatch;
stopWatch.start();
qint64 nbytes = 0;
while (stopWatch.elapsed() < 5000) {
- for (int i = 0; i < 100; ++i) {
+ for (int i = 0; i < 100; ++i) {
if (client.write(arr.data(), arr.size()) > 0) {
do {
nbytes += server.readDatagram(arr.data(), arr.size());
@@ -525,14 +525,14 @@ void tst_QUdpSocket::performance()
float secs = stopWatch.elapsed() / 1000.0;
qDebug("\t%.2fMB/%.2fs: %.2fMB/s", float(nbytes / (1024.0*1024.0)),
secs, float(nbytes / (1024.0*1024.0)) / secs);
-
-#if defined(Q_OS_SYMBIAN)
+
+#if defined(Q_OS_SYMBIAN)
if(nbytes == 0) {
- qDebug("No bytes passed through local UDP socket, since UDP socket write returns EWOULDBLOCK");
- qDebug("Should try with blocking sockets, but it is not currently possible due to Open C defect");
+ qDebug("No bytes passed through local UDP socket, since UDP socket write returns EWOULDBLOCK");
+ qDebug("Should try with blocking sockets, but it is not currently possible due to Open C defect");
}
-#endif
-
+#endif
+
}
void tst_QUdpSocket::bindMode()
@@ -552,48 +552,48 @@ void tst_QUdpSocket::bindMode()
QUdpSocket socket2;
QVERIFY(!socket2.bind(socket.localPort()));
#if defined(Q_OS_SYMBIAN)
-
+
//RPRocess me;
if(RProcess().HasCapability(ECapabilityNetworkControl)) {
- qDebug("Test executed *with* NetworkControl capability");
- // In Symbian OS ReuseAddressHint together with NetworkControl capability
- // gives application *always* right to bind to port. I.e. it does not matter
- // if first socket was bound with any bind flag. Since autotests in Symbian
- // are currently executed with ALL -TCB rights, this path is the one executed.
- QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
- socket.close();
- socket2.close();
-
- QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
- QVERIFY(!socket2.bind(socket.localPort()));
- QVERIFY2(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData());
- socket.close();
- socket2.close();
-
- QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData());
- QVERIFY(!socket2.bind(socket.localPort()));
- QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
- socket.close();
- socket2.close();
- } else {
- qDebug("Test executed *without* NetworkControl capability");
- // If we don't have NetworkControl capability, attempt to bind already bound
- // address will *always* fail. I.e. it does not matter if first socket was
- // bound with any bind flag.
- QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
- socket.close();
-
- QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
- QVERIFY(!socket2.bind(socket.localPort()));
- QVERIFY2(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData());
- socket.close();
-
- QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData());
- QVERIFY(!socket2.bind(socket.localPort()));
- QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
- socket.close();
- }
-#elif defined(Q_OS_UNIX)
+ qDebug("Test executed *with* NetworkControl capability");
+ // In Symbian OS ReuseAddressHint together with NetworkControl capability
+ // gives application *always* right to bind to port. I.e. it does not matter
+ // if first socket was bound with any bind flag. Since autotests in Symbian
+ // are currently executed with ALL -TCB rights, this path is the one executed.
+ QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
+ socket.close();
+ socket2.close();
+
+ QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
+ QVERIFY(!socket2.bind(socket.localPort()));
+ QVERIFY2(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData());
+ socket.close();
+ socket2.close();
+
+ QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData());
+ QVERIFY(!socket2.bind(socket.localPort()));
+ QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
+ socket.close();
+ socket2.close();
+ } else {
+ qDebug("Test executed *without* NetworkControl capability");
+ // If we don't have NetworkControl capability, attempt to bind already bound
+ // address will *always* fail. I.e. it does not matter if first socket was
+ // bound with any bind flag.
+ QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
+ socket.close();
+
+ QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());
+ QVERIFY(!socket2.bind(socket.localPort()));
+ QVERIFY2(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData());
+ socket.close();
+
+ QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData());
+ QVERIFY(!socket2.bind(socket.localPort()));
+ QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
+ socket.close();
+ }
+#elif defined(Q_OS_UNIX)
QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint));
socket.close();
QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData());