tests/auto/qudpsocket/tst_qudpsocket.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
    47 #include <qdatastream.h>
    47 #include <qdatastream.h>
    48 #include <qudpsocket.h>
    48 #include <qudpsocket.h>
    49 #include <qhostaddress.h>
    49 #include <qhostaddress.h>
    50 #include <qhostinfo.h>
    50 #include <qhostinfo.h>
    51 #include <qmap.h>
    51 #include <qmap.h>
    52 #ifdef TEST_QNETWORK_PROXY
    52 #include <QNetworkProxy>
    53 # include <QNetworkProxy>
       
    54 #endif
       
    55 
       
    56 
    53 
    57 #include <qstringlist.h>
    54 #include <qstringlist.h>
    58 #include "../network-settings.h"
    55 #include "../network-settings.h"
    59 
    56 
    60 Q_DECLARE_METATYPE(QHostAddress)
    57 Q_DECLARE_METATYPE(QHostAddress)
   116 {
   113 {
   117     QTest::addColumn<bool>("setProxy");
   114     QTest::addColumn<bool>("setProxy");
   118     QTest::addColumn<int>("proxyType");
   115     QTest::addColumn<int>("proxyType");
   119 
   116 
   120     QTest::newRow("WithoutProxy") << false << 0;
   117     QTest::newRow("WithoutProxy") << false << 0;
   121 #ifdef TEST_QNETWORK_PROXY
       
   122     QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
   118     QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
   123 #endif
       
   124 }
   119 }
   125 
   120 
   126 void tst_QUdpSocket::init()
   121 void tst_QUdpSocket::init()
   127 {
   122 {
   128     QFETCH_GLOBAL(bool, setProxy);
   123     QFETCH_GLOBAL(bool, setProxy);
   129     if (setProxy) {
   124     if (setProxy) {
   130 #ifdef TEST_QNETWORK_PROXY
       
   131         QFETCH_GLOBAL(int, proxyType);
   125         QFETCH_GLOBAL(int, proxyType);
   132         if (proxyType == QNetworkProxy::Socks5Proxy) {
   126         if (proxyType == QNetworkProxy::Socks5Proxy) {
   133             QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
   127             QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
   134         }
   128         }
   135 #endif
       
   136     }
   129     }
   137 }
   130 }
   138 
   131 
   139 void tst_QUdpSocket::cleanup()
   132 void tst_QUdpSocket::cleanup()
   140 {
   133 {
   141     QFETCH_GLOBAL(bool, setProxy);
       
   142     if (setProxy) {
       
   143 #ifdef TEST_QNETWORK_PROXY
       
   144         QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
   134         QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
   145 #endif
       
   146     }
       
   147 }
   135 }
   148 
   136 
   149 
   137 
   150 //----------------------------------------------------------------------------------
   138 //----------------------------------------------------------------------------------
   151 
   139 
   202 
   190 
   203 void tst_QUdpSocket::broadcasting()
   191 void tst_QUdpSocket::broadcasting()
   204 {
   192 {
   205     QFETCH_GLOBAL(bool, setProxy);
   193     QFETCH_GLOBAL(bool, setProxy);
   206     if (setProxy) {
   194     if (setProxy) {
   207 #ifdef TEST_QNETWORK_PROXY
       
   208         QFETCH_GLOBAL(int, proxyType);
   195         QFETCH_GLOBAL(int, proxyType);
   209         if (proxyType == QNetworkProxy::Socks5Proxy) {
   196         if (proxyType == QNetworkProxy::Socks5Proxy) {
   210             QSKIP("With socks5 Broadcast is not supported.", SkipSingle);
   197             QSKIP("With socks5 Broadcast is not supported.", SkipSingle);
   211         }
   198         }
   212 #endif
       
   213     }
   199     }
   214 #ifdef Q_OS_AIX
   200 #ifdef Q_OS_AIX
   215     QSKIP("Broadcast does not work on darko", SkipAll);
   201     QSKIP("Broadcast does not work on darko", SkipAll);
   216 #endif
   202 #endif
   217     const char *message[] = {"Yo mista", "", "Yo", "Wassap"};
   203     const char *message[] = {"Yo mista", "", "Yo", "Wassap"};
   537 
   523 
   538 void tst_QUdpSocket::bindMode()
   524 void tst_QUdpSocket::bindMode()
   539 {
   525 {
   540     QFETCH_GLOBAL(bool, setProxy);
   526     QFETCH_GLOBAL(bool, setProxy);
   541     if (setProxy) {
   527     if (setProxy) {
   542 #ifdef TEST_QNETWORK_PROXY
       
   543         QFETCH_GLOBAL(int, proxyType);
   528         QFETCH_GLOBAL(int, proxyType);
   544         if (proxyType == QNetworkProxy::Socks5Proxy) {
   529         if (proxyType == QNetworkProxy::Socks5Proxy) {
   545             QSKIP("With socks5 explicit port binding is not supported.", SkipAll);
   530             QSKIP("With socks5 explicit port binding is not supported.", SkipAll);
   546         }
   531         }
   547 #endif
       
   548     }
   532     }
   549 
   533 
   550     QUdpSocket socket;
   534     QUdpSocket socket;
   551     QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData());
   535     QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData());
   552     QUdpSocket socket2;
   536     QUdpSocket socket2;