summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui.pro5
-rw-r--r--tests/auto/network.pro9
-rw-r--r--tests/auto/platformsocketengine/.gitignore1
-rw-r--r--tests/auto/platformsocketengine/platformsocketengine.pri (renamed from tests/auto/qnativesocketengine/qsocketengine.pri)0
-rw-r--r--tests/auto/platformsocketengine/platformsocketengine.pro16
-rw-r--r--tests/auto/platformsocketengine/tst_platformsocketengine.cpp (renamed from tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp)192
-rw-r--r--tests/auto/qdir/tst_qdir.cpp6
-rw-r--r--tests/auto/qeventloop/qeventloop.pro1
-rw-r--r--tests/auto/qeventloop/tst_qeventloop.cpp5
-rw-r--r--tests/auto/qftp/tst_qftp.cpp88
-rw-r--r--tests/auto/qhttpsocketengine/qhttpsocketengine.pro2
-rw-r--r--tests/auto/qnativesocketengine/.gitignore1
-rw-r--r--tests/auto/qnativesocketengine/qnativesocketengine.pro13
-rw-r--r--tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro1
-rw-r--r--tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp8
-rw-r--r--tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp8
-rw-r--r--tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro1
-rw-r--r--tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp38
-rw-r--r--tests/auto/qnetworkreply/test/test.pro3
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp114
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp8
-rw-r--r--tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp14
-rw-r--r--tests/auto/qsocks5socketengine/qsocks5socketengine.pro2
-rw-r--r--tests/auto/qsslsocket/qsslsocket.pro2
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp14
-rw-r--r--tests/auto/qtcpserver/crashingServer/crashingServer.pro1
-rw-r--r--tests/auto/qtcpserver/qtcpserver.pro2
-rw-r--r--tests/auto/qtcpserver/test/test.pro7
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp34
-rw-r--r--tests/auto/qtcpsocket/qtcpsocket.pro1
-rw-r--r--tests/auto/qtcpsocket/stressTest/stressTest.pro1
-rw-r--r--tests/auto/qtcpsocket/test/test.pro5
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp63
-rw-r--r--tests/auto/qudpsocket/clientserver/clientserver.pro2
-rw-r--r--tests/auto/qudpsocket/qudpsocket.pro2
-rw-r--r--tests/auto/qudpsocket/test/test.pro2
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp52
-rw-r--r--tests/manual/socketengine/main.cpp152
-rw-r--r--tests/manual/socketengine/socketengine.pro15
39 files changed, 709 insertions, 182 deletions
diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro
index 186f00c..8dc7b5f 100644
--- a/tests/auto/gui.pro
+++ b/tests/auto/gui.pro
@@ -114,9 +114,6 @@ SUBDIRS=\
qmovie \
qvolatileimage \
qnetworkaccessmanager_and_qprogressdialog \
- qnetworkcachemetadata \
- qnetworkdiskcache \
- qnetworkreply \
qpaintengine \
qpainterpath \
qpainterpathstroker \
@@ -169,7 +166,6 @@ SUBDIRS=\
qtabbar \
qtableview \
qtablewidget \
- qtcpserver \
qtcpsocket \
qtessellator \
qtextblock \
@@ -196,7 +192,6 @@ SUBDIRS=\
qtreeview \
qtreewidget \
qtreewidgetitemiterator \
- qudpsocket \
qundogroup \
qundostack \
qvectornd \
diff --git a/tests/auto/network.pro b/tests/auto/network.pro
index b427f1c..e4cecce 100644
--- a/tests/auto/network.pro
+++ b/tests/auto/network.pro
@@ -16,15 +16,18 @@ SUBDIRS=\
qhttpnetworkconnection \
qhttpnetworkreply \
qhttpsocketengine \
- qnativesocketengine \
+ platformsocketengine \
qnetworkaccessmanager \
qnetworkaddressentry \
+ qnetworkcachemetadata \
qnetworkconfiguration \
qnetworkconfigurationmanager \
qnetworkcookie \
qnetworkcookiejar \
+ qnetworkdiskcache \
qnetworkinterface \
qnetworkproxy \
+ qnetworkreply \
qnetworkrequest \
qnetworksession \
qobjectperformance \
@@ -37,13 +40,15 @@ SUBDIRS=\
qsslsocket \
qsslsocket_onDemandCertificates_member \
qsslsocket_onDemandCertificates_static \
+ qtcpserver \
+ qudpsocket \
# qnetworkproxyfactory \ # Uses a hardcoded proxy configuration
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
qauthenticator \
qhttpnetworkconnection \
qhttpnetworkreply \
- qnativesocketengine \
+ platformsocketengine \
qsocketnotifier \
qsocks5socketengine \
diff --git a/tests/auto/platformsocketengine/.gitignore b/tests/auto/platformsocketengine/.gitignore
new file mode 100644
index 0000000..afe9389
--- /dev/null
+++ b/tests/auto/platformsocketengine/.gitignore
@@ -0,0 +1 @@
+tst_platformsocketengine
diff --git a/tests/auto/qnativesocketengine/qsocketengine.pri b/tests/auto/platformsocketengine/platformsocketengine.pri
index 15f31fd..15f31fd 100644
--- a/tests/auto/qnativesocketengine/qsocketengine.pri
+++ b/tests/auto/platformsocketengine/platformsocketengine.pri
diff --git a/tests/auto/platformsocketengine/platformsocketengine.pro b/tests/auto/platformsocketengine/platformsocketengine.pro
new file mode 100644
index 0000000..faf745c
--- /dev/null
+++ b/tests/auto/platformsocketengine/platformsocketengine.pro
@@ -0,0 +1,16 @@
+load(qttest_p4)
+SOURCES += tst_platformsocketengine.cpp
+
+include(../platformsocketengine/platformsocketengine.pri)
+
+requires(contains(QT_CONFIG,private_tests))
+
+MOC_DIR=tmp
+
+QT = core network
+
+symbian {
+ TARGET.CAPABILITY = NetworkServices
+ INCLUDEPATH += $$OS_LAYER_SYSTEMINCLUDE
+ LIBS += -lesock
+}
diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
index 41eb1e25..184371d 100644
--- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp
+++ b/tests/auto/platformsocketengine/tst_platformsocketengine.cpp
@@ -50,7 +50,6 @@
#include <qdatastream.h>
-#include <private/qnativesocketengine_p.h>
#include <qhostaddress.h>
#include <qdatetime.h>
@@ -63,6 +62,20 @@
#include <stddef.h>
+#ifdef Q_OS_SYMBIAN
+#include <QNetworkConfigurationManager>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+#include <QScopedPointer>
+#define PLATFORMSOCKETENGINE QSymbianSocketEngine
+#define PLATFORMSOCKETENGINESTRING "QSymbianSocketEngine"
+#include <private/qsymbiansocketengine_p.h>
+#include <private/qcore_symbian_p.h>
+#else
+#define PLATFORMSOCKETENGINE QNativeSocketEngine
+#define PLATFORMSOCKETENGINESTRING "QNativeSocketEngine"
+#include <private/qnativesocketengine_p.h>
+#endif
#include <qstringlist.h>
@@ -70,13 +83,13 @@
//TESTED_FILES=network/qnativesocketengine.cpp network/qnativesocketengine_p.h network/qnativesocketengine_unix.cpp
-class tst_QNativeSocketEngine : public QObject
+class tst_PlatformSocketEngine : public QObject
{
Q_OBJECT
public:
- tst_QNativeSocketEngine();
- virtual ~tst_QNativeSocketEngine();
+ tst_PlatformSocketEngine();
+ virtual ~tst_PlatformSocketEngine();
public slots:
@@ -92,35 +105,35 @@ private slots:
void udpLoopbackPerformance();
void tcpLoopbackPerformance();
void readWriteBufferSize();
- void tooManySockets();
void bind();
void networkError();
void setSocketDescriptor();
void invalidSend();
void receiveUrgentData();
+ void tooManySockets();
};
-tst_QNativeSocketEngine::tst_QNativeSocketEngine()
+tst_PlatformSocketEngine::tst_PlatformSocketEngine()
{
Q_SET_DEFAULT_IAP
}
-tst_QNativeSocketEngine::~tst_QNativeSocketEngine()
+tst_PlatformSocketEngine::~tst_PlatformSocketEngine()
{
}
-void tst_QNativeSocketEngine::init()
+void tst_PlatformSocketEngine::init()
{
}
-void tst_QNativeSocketEngine::cleanup()
+void tst_PlatformSocketEngine::cleanup()
{
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::construction()
+void tst_PlatformSocketEngine::construction()
{
- QNativeSocketEngine socketDevice;
+ PLATFORMSOCKETENGINE socketDevice;
QVERIFY(!socketDevice.isValid());
@@ -137,17 +150,17 @@ void tst_QNativeSocketEngine::construction()
QVERIFY(socketDevice.peerPort() == 0);
QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QVERIFY(socketDevice.bytesAvailable() == 0);
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::simpleConnectToIMAP()
+void tst_PlatformSocketEngine::simpleConnectToIMAP()
{
- QNativeSocketEngine socketDevice;
+ PLATFORMSOCKETENGINE socketDevice;
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
@@ -202,12 +215,9 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpLoopbackTest()
+void tst_PlatformSocketEngine::udpLoopbackTest()
{
-#ifdef SYMBIAN_WINSOCK_CONNECTIVITY
- QSKIP("Not working on Emulator without WinPCAP", SkipAll);
-#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
@@ -224,7 +234,7 @@ void tst_QNativeSocketEngine::udpLoopbackTest()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket));
// Connect device #2 to #1
@@ -253,12 +263,9 @@ void tst_QNativeSocketEngine::udpLoopbackTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
+void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
-#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
bool init = udpSocket.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol);
@@ -275,7 +282,7 @@ void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol));
// Connect device #2 to #1
@@ -305,12 +312,26 @@ void tst_QNativeSocketEngine::udpIPv6LoopbackTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::broadcastTest()
+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
- QNativeSocketEngine broadcastSocket;
+ PLATFORMSOCKETENGINE broadcastSocket;
// Initialize a regular Udp socket
QVERIFY(broadcastSocket.initialize(QAbstractSocket::UdpSocket));
@@ -324,10 +345,18 @@ void tst_QNativeSocketEngine::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)
@@ -346,9 +375,9 @@ void tst_QNativeSocketEngine::broadcastTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::serverTest()
+void tst_PlatformSocketEngine::serverTest()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
// Initialize a Tcp socket
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -363,7 +392,7 @@ void tst_QNativeSocketEngine::serverTest()
QVERIFY(server.state() == QAbstractSocket::ListeningState);
// Initialize a Tcp socket
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
@@ -377,7 +406,7 @@ void tst_QNativeSocketEngine::serverTest()
// A socket device is initialized on the server side, passing the
// socket descriptor from accept(). It's pre-connected.
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
@@ -400,12 +429,12 @@ void tst_QNativeSocketEngine::serverTest()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::udpLoopbackPerformance()
+void tst_PlatformSocketEngine::udpLoopbackPerformance()
{
#ifdef SYMBIAN_WINSOCK_CONNECTIVITY
QSKIP("Not working on Emulator without WinPCAP", SkipAll);
#endif
- QNativeSocketEngine udpSocket;
+ PLATFORMSOCKETENGINE udpSocket;
// Initialize device #1
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
@@ -422,7 +451,7 @@ void tst_QNativeSocketEngine::udpLoopbackPerformance()
QVERIFY(port != 0);
// Initialize device #2
- QNativeSocketEngine udpSocket2;
+ PLATFORMSOCKETENGINE udpSocket2;
QVERIFY(udpSocket2.initialize(QAbstractSocket::UdpSocket));
// Connect device #2 to #1
@@ -454,9 +483,9 @@ void tst_QNativeSocketEngine::udpLoopbackPerformance()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::tcpLoopbackPerformance()
+void tst_PlatformSocketEngine::tcpLoopbackPerformance()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
// Initialize a Tcp socket
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -471,7 +500,7 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
QVERIFY(server.state() == QAbstractSocket::ListeningState);
// Initialize a Tcp socket
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
// Connect to our server
@@ -481,17 +510,21 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
}
- // The server accepts the connectio
+ // The server accepts the connection
int socketDescriptor = server.accept();
QVERIFY(socketDescriptor > 0);
// A socket device is initialized on the server side, passing the
// socket descriptor from accept(). It's pre-connected.
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
+#if defined (Q_OS_SYMBIAN) && defined (__WINS__)
+ const int messageSize = 1024 * 16;
+#else
const int messageSize = 1024 * 256;
+#endif
QByteArray message1(messageSize, '@');
QByteArray answer(messageSize, '@');
@@ -517,9 +550,9 @@ void tst_QNativeSocketEngine::tcpLoopbackPerformance()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::readWriteBufferSize()
+void tst_PlatformSocketEngine::readWriteBufferSize()
{
- QNativeSocketEngine device;
+ PLATFORMSOCKETENGINE device;
QVERIFY(device.initialize(QAbstractSocket::TcpSocket));
@@ -539,15 +572,15 @@ void tst_QNativeSocketEngine::readWriteBufferSize()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::tooManySockets()
+void tst_PlatformSocketEngine::tooManySockets()
{
#if defined Q_OS_WIN
QSKIP("Certain windows machines suffocate and spend too much time in this test.", SkipAll);
#endif
- QList<QNativeSocketEngine *> sockets;
- QNativeSocketEngine *socketLayer = 0;
+ QList<PLATFORMSOCKETENGINE *> sockets;
+ PLATFORMSOCKETENGINE *socketLayer = 0;
for (;;) {
- socketLayer = new QNativeSocketEngine;
+ socketLayer = new PLATFORMSOCKETENGINE;
sockets.append(socketLayer);
if (!socketLayer->initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol))
@@ -560,20 +593,20 @@ void tst_QNativeSocketEngine::tooManySockets()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::bind()
+void tst_PlatformSocketEngine::bind()
{
#if !defined Q_OS_WIN && !defined Q_OS_SYMBIAN
- QNativeSocketEngine binder;
+ PLATFORMSOCKETENGINE binder;
QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder.bind(QHostAddress::Any, 82));
QVERIFY(binder.error() == QAbstractSocket::SocketAccessError);
#endif
- QNativeSocketEngine binder2;
+ PLATFORMSOCKETENGINE binder2;
QVERIFY(binder2.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(binder2.bind(QHostAddress::Any, 31180));
- QNativeSocketEngine binder3;
+ PLATFORMSOCKETENGINE binder3;
QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder3.bind(QHostAddress::Any, 31180));
@@ -586,9 +619,9 @@ void tst_QNativeSocketEngine::bind()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::networkError()
+void tst_PlatformSocketEngine::networkError()
{
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
@@ -604,6 +637,12 @@ void tst_QNativeSocketEngine::networkError()
#ifdef Q_OS_WIN
// could use shutdown to produce different errors
::closesocket(client.socketDescriptor());
+#elif defined(Q_OS_SYMBIAN)
+ RSocket sock;
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(client.socketDescriptor(), sock));
+ TRequestStatus stat;
+ sock.Shutdown(RSocket::EImmediate, stat);
+ User::WaitForRequest(stat);
#else
::close(client.socketDescriptor());
#endif
@@ -612,31 +651,31 @@ void tst_QNativeSocketEngine::networkError()
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::setSocketDescriptor()
+void tst_PlatformSocketEngine::setSocketDescriptor()
{
- QNativeSocketEngine socket1;
+ PLATFORMSOCKETENGINE socket1;
QVERIFY(socket1.initialize(QAbstractSocket::TcpSocket));
- QNativeSocketEngine socket2;
+ PLATFORMSOCKETENGINE socket2;
QVERIFY(socket2.initialize(socket1.socketDescriptor()));
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::invalidSend()
+void tst_PlatformSocketEngine::invalidSend()
{
- QNativeSocketEngine socket;
+ PLATFORMSOCKETENGINE socket;
QVERIFY(socket.initialize(QAbstractSocket::TcpSocket));
- QTest::ignoreMessage(QtWarningMsg, "QNativeSocketEngine::writeDatagram() was"
+ QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::writeDatagram() was"
" called by a socket other than QAbstractSocket::UdpSocket");
QCOMPARE(socket.writeDatagram("hei", 3, QHostAddress::LocalHost, 143),
(qlonglong) -1);
}
//---------------------------------------------------------------------------
-void tst_QNativeSocketEngine::receiveUrgentData()
+void tst_PlatformSocketEngine::receiveUrgentData()
{
- QNativeSocketEngine server;
+ PLATFORMSOCKETENGINE server;
QVERIFY(server.initialize(QAbstractSocket::TcpSocket));
@@ -648,7 +687,7 @@ void tst_QNativeSocketEngine::receiveUrgentData()
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
- QNativeSocketEngine client;
+ PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
@@ -660,7 +699,7 @@ void tst_QNativeSocketEngine::receiveUrgentData()
int socketDescriptor = server.accept();
QVERIFY(socketDescriptor > 0);
- QNativeSocketEngine serverSocket;
+ PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
@@ -676,7 +715,18 @@ void tst_QNativeSocketEngine::receiveUrgentData()
// The server sends an urgent message
msg = 'Q';
+#if defined(Q_OS_SYMBIAN)
+ RSocket sock;
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(socketDescriptor, sock));
+ TRequestStatus stat;
+ TSockXfrLength len;
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(socketDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The client receives the urgent message
QVERIFY(client.waitForRead());
@@ -689,7 +739,15 @@ void tst_QNativeSocketEngine::receiveUrgentData()
// The client sends an urgent message
msg = 'T';
int clientDescriptor = client.socketDescriptor();
+#if defined(Q_OS_SYMBIAN)
+ QVERIFY(QSymbianSocketManager::instance().lookupSocket(clientDescriptor, sock));
+ sock.Send(TPtrC8((TUint8*)&msg,1), KSockWriteUrgent, stat, len);
+ User::WaitForRequest(stat);
+ QVERIFY(stat == KErrNone);
+ QCOMPARE(len(), 1);
+#else
QCOMPARE(int(::send(clientDescriptor, &msg, sizeof(msg), MSG_OOB)), 1);
+#endif
// The server receives the urgent message
QVERIFY(serverSocket.waitForRead());
@@ -701,5 +759,5 @@ void tst_QNativeSocketEngine::receiveUrgentData()
}
-QTEST_MAIN(tst_QNativeSocketEngine)
-#include "tst_qnativesocketengine.moc"
+QTEST_MAIN(tst_PlatformSocketEngine)
+#include "tst_platformsocketengine.moc"
diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp
index 2fa0c24..21460be 100644
--- a/tests/auto/qdir/tst_qdir.cpp
+++ b/tests/auto/qdir/tst_qdir.cpp
@@ -571,6 +571,12 @@ void tst_QDir::entryList_data()
<< int(QDir::AllEntries | QDir::Writable) << int(QDir::Name)
<< filterLinks(QString(".,..,directory,linktodirectory.lnk,writable").split(','));
#endif
+ QTest::newRow("QDir::Files | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
+ << int(QDir::Files | QDir::Readable) << int(QDir::Name)
+ << filterLinks(QString("file,linktofile.lnk,writable").split(','));
+ QTest::newRow("QDir::Dirs | QDir::Readable") << SRCDIR "entrylist/" << QStringList("*")
+ << int(QDir::Dirs | QDir::Readable) << int(QDir::Name)
+ << filterLinks(QString(".,..,directory,linktodirectory.lnk").split(','));
QTest::newRow("Namefilters b*") << SRCDIR "entrylist/" << QStringList("d*")
<< int(QDir::NoFilter) << int(QDir::Name)
<< filterLinks(QString("directory").split(','));
diff --git a/tests/auto/qeventloop/qeventloop.pro b/tests/auto/qeventloop/qeventloop.pro
index f6c24ae..e7489fa 100644
--- a/tests/auto/qeventloop/qeventloop.pro
+++ b/tests/auto/qeventloop/qeventloop.pro
@@ -5,3 +5,4 @@ QT += network
win32:!wince*:LIBS += -luser32
+symbian:TARGET.CAPABILITY += NetworkServices \ No newline at end of file
diff --git a/tests/auto/qeventloop/tst_qeventloop.cpp b/tests/auto/qeventloop/tst_qeventloop.cpp
index 6860f19..fa2a34e 100644
--- a/tests/auto/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/qeventloop/tst_qeventloop.cpp
@@ -602,8 +602,10 @@ public slots:
QTcpSocket *serverSocket = server->nextPendingConnection();
serverSocket->write(data, size);
serverSocket->flush();
+ QTest::qSleep(200); //allow the TCP/IP stack time to loopback the data, so our socket is ready to read
QCoreApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
testResult = dataArrived;
+ QCoreApplication::processEvents(); //check the deferred event is processed
serverSocket->close();
QThread::currentThread()->exit(0);
}
@@ -620,9 +622,11 @@ public:
if (tester->init())
exec();
testResult = tester->testResult;
+ dataArrived = tester->dataArrived;
delete tester;
}
bool testResult;
+ bool dataArrived;
};
void tst_QEventLoop::processEventsExcludeSocket()
@@ -631,6 +635,7 @@ void tst_QEventLoop::processEventsExcludeSocket()
thread.start();
QVERIFY(thread.wait());
QVERIFY(!thread.testResult);
+ QVERIFY(thread.dataArrived);
}
class TimerReceiver : public QObject
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 1b4b503..7e3cd75 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -50,6 +50,10 @@
#include <time.h>
#include <stdlib.h>
#include <QNetworkProxy>
+#include <QNetworkConfiguration>
+#include <qnetworkconfigmanager.h>
+#include <QNetworkSession>
+#include <QtNetwork/private/qnetworksession_p.h>
#include "../network-settings.h"
@@ -62,7 +66,9 @@
#define SRCDIR ""
#endif
-
+#ifndef QT_NO_BEARERMANAGEMENT
+Q_DECLARE_METATYPE(QNetworkConfiguration)
+#endif
class tst_QFtp : public QObject
{
@@ -148,6 +154,10 @@ private:
void renameCleanup( const QString &host, const QString &user, const QString &password, const QString &fileToDelete );
QFtp *ftp;
+#ifndef QT_NO_BEARERMANAGEMENT
+ QSharedPointer<QNetworkSession> networkSessionExplicit;
+ QSharedPointer<QNetworkSession> networkSessionImplicit;
+#endif
QList<int> ids; // helper to make sure that all expected signals are emitted
int current_id;
@@ -186,9 +196,9 @@ private:
const int bytesTotal_init = -10;
const int bytesDone_init = -10;
-tst_QFtp::tst_QFtp()
+tst_QFtp::tst_QFtp() :
+ ftp(0)
{
- Q_SET_DEFAULT_IAP
}
tst_QFtp::~tst_QFtp()
@@ -199,33 +209,62 @@ void tst_QFtp::initTestCase_data()
{
QTest::addColumn<bool>("setProxy");
QTest::addColumn<int>("proxyType");
+ QTest::addColumn<bool>("setSession");
- QTest::newRow("WithoutProxy") << false << 0;
- QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
+ QTest::newRow("WithoutProxy") << false << 0 << false;
+ QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy) << false;
//### doesn't work well yet.
//QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy);
+
+#ifndef QT_NO_BEARERMANAGEMENT
+ QTest::newRow("WithoutProxyWithSession") << false << 0 << true;
+ QTest::newRow("WithSocks5ProxyAndSession") << true << int(QNetworkProxy::Socks5Proxy) << true;
+#endif
}
void tst_QFtp::initTestCase()
{
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager manager;
+ networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(manager.defaultConfiguration()));
+ networkSessionImplicit->open();
+ QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect
+#endif
}
void tst_QFtp::cleanupTestCase()
{
+#ifndef QT_NO_BEARERMANAGEMENT
+ networkSessionExplicit.clear();
+ networkSessionImplicit.clear();
+#endif
}
void tst_QFtp::init()
{
QFETCH_GLOBAL(bool, setProxy);
+ QFETCH_GLOBAL(int, proxyType);
+ QFETCH_GLOBAL(bool, setSession);
if (setProxy) {
- QFETCH_GLOBAL(int, proxyType);
if (proxyType == QNetworkProxy::Socks5Proxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
} else if (proxyType == QNetworkProxy::HttpProxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
}
}
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (setSession) {
+ networkSessionExplicit = networkSessionImplicit;
+ if (!networkSessionExplicit->isOpen()) {
+ networkSessionExplicit->open();
+ QVERIFY(networkSessionExplicit->waitForOpened(30000));
+ }
+ } else {
+ networkSessionExplicit.clear();
+ }
+#endif
+ delete ftp;
ftp = 0;
ids.clear();
@@ -266,6 +305,12 @@ void tst_QFtp::cleanup()
if (setProxy) {
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
}
+
+ delete ftp;
+ ftp = 0;
+#ifndef QT_NO_BEARERMANAGEMENT
+ networkSessionExplicit.clear();
+#endif
}
void tst_QFtp::connectToHost_data()
@@ -289,6 +334,7 @@ void tst_QFtp::connectToHost()
QTestEventLoop::instance().enterLoop( 61 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -337,6 +383,7 @@ void tst_QFtp::connectToUnresponsiveHost()
QVERIFY( it.value().success == 0 );
delete ftp;
+ ftp = 0;
}
void tst_QFtp::login_data()
@@ -369,6 +416,7 @@ void tst_QFtp::login()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -415,6 +463,7 @@ void tst_QFtp::close()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -482,6 +531,7 @@ void tst_QFtp::list()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -542,6 +592,7 @@ void tst_QFtp::cd()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
QFAIL( "Network operation timed out" );
}
@@ -617,6 +668,7 @@ void tst_QFtp::get()
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -743,6 +795,7 @@ void tst_QFtp::put()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -775,6 +828,7 @@ void tst_QFtp::put()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -792,6 +846,7 @@ void tst_QFtp::put()
QTestEventLoop::instance().enterLoop( timestep );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -860,6 +915,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -884,6 +940,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -903,6 +960,7 @@ void tst_QFtp::mkdir()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -942,6 +1000,7 @@ void tst_QFtp::mkdir2()
QVERIFY(commandFinishedSpy.at(3).at(1).toBool());
delete ftp;
+ ftp = 0;
}
void tst_QFtp::mkdir2Slot(int id, bool)
@@ -1019,6 +1078,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1043,6 +1103,7 @@ void tst_QFtp::renameCleanup( const QString &host, const QString &user, const QS
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1087,6 +1148,7 @@ void tst_QFtp::rename()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1273,6 +1335,7 @@ void tst_QFtp::commandSequence()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1330,6 +1393,7 @@ void tst_QFtp::abort()
break;
}
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1367,6 +1431,7 @@ void tst_QFtp::abort()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1425,6 +1490,7 @@ void tst_QFtp::bytesAvailable()
ftp->readAll();
QVERIFY( ftp->bytesAvailable() == 0 );
delete ftp;
+ ftp = 0;
}
void tst_QFtp::activeMode()
@@ -1497,6 +1563,7 @@ void tst_QFtp::proxy()
QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
QFAIL( "Network operation timed out" );
}
@@ -1512,7 +1579,6 @@ void tst_QFtp::proxy()
}
}
-
void tst_QFtp::binaryAscii()
{
QString file = "asciifile%1.txt";
@@ -1573,6 +1639,7 @@ void tst_QFtp::binaryAscii()
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1868,6 +1935,11 @@ void tst_QFtp::dataTransferProgress( qint64 done, qint64 total )
QFtp *tst_QFtp::newFtp()
{
QFtp *nFtp = new QFtp( this );
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (networkSessionExplicit) {
+ nFtp->setProperty("_q_networksession", QVariant::fromValue(networkSessionExplicit));
+ }
+#endif
connect( nFtp, SIGNAL(commandStarted(int)),
SLOT(commandStarted(int)) );
connect( nFtp, SIGNAL(commandFinished(int,bool)),
@@ -1920,6 +1992,7 @@ bool tst_QFtp::fileExists( const QString &host, quint16 port, const QString &use
inFileDirExistsFunction = TRUE;
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
qWarning("tst_QFtp::fileExists: Network operation timed out");
@@ -1970,6 +2043,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user
inFileDirExistsFunction = TRUE;
QTestEventLoop::instance().enterLoop( 30 );
delete ftp;
+ ftp = 0;
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
// QFAIL( "Network operation timed out" );
diff --git a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
index d76ebb6..6df6192 100644
--- a/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
+++ b/tests/auto/qhttpsocketengine/qhttpsocketengine.pro
@@ -2,7 +2,7 @@ load(qttest_p4)
SOURCES += tst_qhttpsocketengine.cpp
-include(../qnativesocketengine/qsocketengine.pri)
+include(../platformsocketengine/platformsocketengine.pri)
MOC_DIR=tmp
diff --git a/tests/auto/qnativesocketengine/.gitignore b/tests/auto/qnativesocketengine/.gitignore
deleted file mode 100644
index 4700e5e..0000000
--- a/tests/auto/qnativesocketengine/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qnativesocketengine
diff --git a/tests/auto/qnativesocketengine/qnativesocketengine.pro b/tests/auto/qnativesocketengine/qnativesocketengine.pro
deleted file mode 100644
index 0275d37..0000000
--- a/tests/auto/qnativesocketengine/qnativesocketengine.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_qnativesocketengine.cpp
-
-include(../qnativesocketengine/qsocketengine.pri)
-
-requires(contains(QT_CONFIG,private_tests))
-
-MOC_DIR=tmp
-
-QT = core network
-
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
index 77ad347..ae0941e 100644
--- a/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
+++ b/tests/auto/qnetworkcachemetadata/qnetworkcachemetadata.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
QT += network
SOURCES += tst_qnetworkcachemetadata.cpp
diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index adcfd93..c31eac7 100644
--- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
+++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
@@ -52,7 +52,7 @@
*/
#include <QNetworkAccessManager>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -73,7 +73,7 @@ private slots:
void isRoamingAvailable();
private:
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -85,7 +85,7 @@ private:
void tst_QNetworkConfiguration::initTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -158,7 +158,7 @@ void tst_QNetworkConfiguration::initTestCase()
void tst_QNetworkConfiguration::cleanupTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index 443fd18..7787608 100644
--- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -45,7 +45,7 @@
#include <QtNetwork/qnetworkconfiguration.h>
#include <QtNetwork/qnetworkconfigmanager.h>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -67,7 +67,7 @@ private slots:
void configurationFromIdentifier();
private:
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -79,7 +79,7 @@ private:
void tst_QNetworkConfigurationManager::initTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -153,7 +153,7 @@ void tst_QNetworkConfigurationManager::initTestCase()
void tst_QNetworkConfigurationManager::cleanupTestCase()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
index 3b13087..c05171d 100644
--- a/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
+++ b/tests/auto/qnetworkdiskcache/qnetworkdiskcache.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
QT += network
SOURCES += tst_qnetworkdiskcache.cpp
diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
index 0d7c68e..c630eca 100644
--- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -45,6 +45,8 @@
#include <qcoreapplication.h>
#include <qnetworkinterface.h>
#include <qtcpsocket.h>
+#include <QNetworkConfigurationManager>
+#include <QNetworkSession>
#include "../network-settings.h"
//TESTED_FILES=qnetworkinterface.cpp qnetworkinterface.h qnetworkinterface_unix.cpp qnetworkinterface_win.cpp
@@ -58,23 +60,52 @@ public:
virtual ~tst_QNetworkInterface();
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void dump();
void loopbackIPv4();
void loopbackIPv6();
void localAddress();
void interfaceFromXXX();
void copyInvalidInterface();
+
+private:
+#ifndef QT_NO_BEARER_MANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
};
tst_QNetworkInterface::tst_QNetworkInterface()
{
- Q_SET_DEFAULT_IAP
}
tst_QNetworkInterface::~tst_QNetworkInterface()
{
}
+void tst_QNetworkInterface::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
+}
+
+void tst_QNetworkInterface::cleanupTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ if (networkSession && networkSession->isOpen()) {
+ networkSession->close();
+ }
+#endif
+}
void tst_QNetworkInterface::dump()
{
@@ -127,10 +158,6 @@ void tst_QNetworkInterface::loopbackIPv4()
void tst_QNetworkInterface::loopbackIPv6()
{
-#ifdef Q_OS_SYMBIAN
- QSKIP( "Symbian: IPv6 is not yet supported", SkipAll );
-#else
-
QList<QHostAddress> all = QNetworkInterface::allAddresses();
bool loopbackfound = false;
@@ -144,7 +171,6 @@ void tst_QNetworkInterface::loopbackIPv6()
anyIPv6 = true;
QVERIFY(!anyIPv6 || loopbackfound);
-#endif
}
void tst_QNetworkInterface::localAddress()
diff --git a/tests/auto/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro
index 7efc2fb..80b879a 100644
--- a/tests/auto/qnetworkreply/test/test.pro
+++ b/tests/auto/qnetworkreply/test/test.pro
@@ -1,4 +1,5 @@
load(qttest_p4)
+QT -= gui
SOURCES += ../tst_qnetworkreply.cpp
TARGET = ../tst_qnetworkreply
@@ -33,6 +34,6 @@ symbian:{
# Symbian toolchain does not support correct include semantics
INCLUDEPATH+=..\\..\\..\\..\\include\\QtNetwork\\private
# bigfile test case requires more heap
- TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+ TARGET.EPOCHEAPSIZE="0x100 0x10000000"
TARGET.CAPABILITY="ALL -TCB"
}
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 6ed8f16..4b8dc3b 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -47,6 +47,7 @@
#include <QtCore/QEventLoop>
#include <QtCore/QFile>
#include <QtCore/QSharedPointer>
+#include <QtCore/QScopedPointer>
#include <QtCore/QTemporaryFile>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
@@ -66,6 +67,11 @@
#include <QtNetwork/qsslerror.h>
#include <QtNetwork/qsslconfiguration.h>
#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+#include <QtNetwork/qnetworkconfigmanager.h>
+#include <QtNetwork/qnetworkconfiguration.h>
+#include <QtNetwork/qnetworksession.h>
+#endif
#include <time.h>
@@ -137,6 +143,11 @@ class tst_QNetworkReply: public QObject
QSslConfiguration storedSslConfiguration;
QList<QSslError> storedExpectedSslErrors;
#endif
+#ifndef QT_NO_BEARER_MANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
+ QNetworkConfiguration networkConfiguration;
+ QScopedPointer<QNetworkSession> networkSession;
+#endif
public:
tst_QNetworkReply();
@@ -428,16 +439,23 @@ public:
QTcpSocket *client; // always the last one that was received
QByteArray dataToTransmit;
QByteArray receivedData;
+ QSemaphore ready;
bool doClose;
bool doSsl;
bool multiple;
int totalConnections;
- MiniHttpServer(const QByteArray &data, bool ssl = false)
+ MiniHttpServer(const QByteArray &data, bool ssl = false, QThread *thread = 0)
: client(0), dataToTransmit(data), doClose(true), doSsl(ssl),
multiple(false), totalConnections(0)
{
listen();
+ if (thread) {
+ connect(thread, SIGNAL(started()), this, SLOT(threadStartedSlot()));
+ moveToThread(thread);
+ thread->start();
+ ready.acquire();
+ }
}
protected:
@@ -514,6 +532,11 @@ public slots:
disconnect(client, 0, this, 0);
}
}
+
+ void threadStartedSlot()
+ {
+ ready.release();
+ }
};
class MyCookieJar: public QNetworkCookieJar
@@ -1241,6 +1264,18 @@ void tst_QNetworkReply::initTestCase()
#endif
QDir::setSearchPaths("srcdir", QStringList() << SRCDIR);
+#ifndef QT_NO_OPENSSL
+ QSslSocket::defaultCaCertificates(); //preload certificates
+#endif
+#ifndef QT_NO_BEARERMANAGEMENT
+ netConfMan = new QNetworkConfigurationManager(this);
+ networkConfiguration = netConfMan->defaultConfiguration();
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+#endif
}
void tst_QNetworkReply::cleanupTestCase()
@@ -1248,6 +1283,9 @@ void tst_QNetworkReply::cleanupTestCase()
#if !defined Q_OS_WIN
QFile::remove(wronlyFileName);
#endif
+ if (networkSession && networkSession->isOpen()) {
+ networkSession->close();
+ }
}
void tst_QNetworkReply::init()
@@ -1607,7 +1645,7 @@ void tst_QNetworkReply::getErrors()
QNetworkRequest request(url);
#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- if (qstrcmp(QTest::currentDataTag(), "empty-scheme-host") == 0)
+ if (qstrcmp(QTest::currentDataTag(), "empty-scheme-host") == 0 && QFileInfo(url).isAbsolute())
QTest::ignoreMessage(QtWarningMsg, "QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
#endif
@@ -1626,7 +1664,8 @@ void tst_QNetworkReply::getErrors()
QFETCH(int, error);
#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
- QEXPECT_FAIL("empty-scheme-host", "this is expected to fail on Windows and Symbian, QTBUG-17731", Abort);
+ if (QFileInfo(url).isAbsolute())
+ QEXPECT_FAIL("empty-scheme-host", "this is expected to fail on Windows and Symbian, QTBUG-17731", Abort);
#endif
QEXPECT_FAIL("ftp-is-dir", "QFtp cannot provide enough detail", Abort);
// the line below is not necessary
@@ -1832,6 +1871,7 @@ void tst_QNetworkReply::postToHttp()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply;
QFETCH(QByteArray, data);
@@ -1858,6 +1898,7 @@ void tst_QNetworkReply::postToHttpSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
@@ -3617,8 +3658,7 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket()
QString socketname = "networkreplytest";
QLocalServer server;
if (!server.listen(socketname)) {
- if (QFile::exists(server.fullServerName()))
- QFile::remove(server.fullServerName());
+ QLocalServer::removeServer(socketname);
QVERIFY(server.listen(socketname));
}
QLocalSocket active;
@@ -3663,7 +3703,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
{
#if defined(Q_OS_WINCE) || defined (Q_OS_SYMBIAN)
QSKIP("Currently no stdin/out supported for Windows CE / Symbian OS", SkipAll);
-#endif
+#else
#ifdef Q_OS_WIN
if (qstrcmp(QTest::currentDataTag(), "small") == 0)
@@ -3701,6 +3741,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
#endif
+#endif
}
void tst_QNetworkReply::ioPutToFtpFromFile_data()
@@ -3814,6 +3855,8 @@ void tst_QNetworkReply::ioPostToHttpFromFile()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+
QNetworkReplyPtr reply = manager.post(request, &sourceFile);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3890,8 +3933,10 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
socketpair.endPoints[0]->write(data);
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+
manager.setProxy(proxy);
- QNetworkReplyPtr reply = manager.post(QNetworkRequest(url), socketpair.endPoints[1]);
+ QNetworkReplyPtr reply = manager.post(request, socketpair.endPoints[1]);
socketpair.endPoints[0]->close();
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -3964,6 +4009,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/md5sum.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
true);
@@ -3993,7 +4039,8 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileToEnd()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
- QNetworkReplyPtr reply = manager.post(QNetworkRequest(url), &sourceFile);
+ request.setRawHeader("Content-Type", "application/octet-stream");
+ QNetworkReplyPtr reply = manager.post(request, &sourceFile);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
@@ -4019,6 +4066,7 @@ void tst_QNetworkReply::ioPostToHttpFromMiddleOfFileFiveBytes()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
// only send 5 bytes
request.setHeader(QNetworkRequest::ContentLengthHeader, 5);
QVERIFY(request.header(QNetworkRequest::ContentLengthHeader).isValid());
@@ -4079,6 +4127,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/protected/cgi-bin/md5sum.cgi";
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
// disallow buffering
request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true);
request.setHeader(QNetworkRequest::ContentLengthHeader, data.size());
@@ -4141,6 +4190,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress()
// create the request
QUrl url = QUrl(QString("https://127.0.0.1:%1/").arg(server.serverPort()));
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &sourceFile);
QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
connect(&server, SIGNAL(newEncryptedConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -4253,7 +4303,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
QTime loopTime;
loopTime.start();
- QTestEventLoop::instance().enterLoop(11);
+ QTestEventLoop::instance().enterLoop(30);
const int elapsedTime = loopTime.elapsed();
server.wait();
reader.wrapUp();
@@ -4285,10 +4335,9 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp()
const int minRate = rate * 1024 * (100-allowedDeviation) / 100;
const int maxRate = rate * 1024 * (100+allowedDeviation) / 100;
qDebug() << minRate << "<="<< server.transferRate << "<=" << maxRate << "?";
- QVERIFY(server.transferRate >= minRate);
QEXPECT_FAIL("http+limited", "Limiting is broken right now, check QTBUG-15065", Continue);
QEXPECT_FAIL("https+limited", "Limiting is broken right now, check QTBUG-15065", Continue);
- QVERIFY(server.transferRate <= maxRate);
+ QVERIFY(server.transferRate >= minRate && server.transferRate <= maxRate);
}
}
@@ -4363,6 +4412,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
// create the request
QUrl url = QUrl(QString("http://127.0.0.1:%1/").arg(server.serverPort()));
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply = manager.post(request, &buffer);
QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
connect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop()));
@@ -4709,6 +4759,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp()
QByteArray data = cookieString.toLatin1() + '\n';
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi");
QNetworkRequest request(url);
+ request.setRawHeader("Content-Type", "application/octet-stream");
QNetworkReplyPtr reply;
RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::PostOperation, request, reply, data));
@@ -4736,7 +4787,7 @@ void tst_QNetworkReply::receiveCookiesFromHttpSynchronous()
QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi");
QNetworkRequest request(url);
-
+ request.setRawHeader("Content-Type", "application/octet-stream");
request.setAttribute(
QNetworkRequest::SynchronousRequestAttribute,
true);
@@ -4952,6 +5003,26 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous_data()
httpProxyCommands_data();
}
+struct QThreadCleanup
+{
+ static inline void cleanup(QThread *thread)
+ {
+ thread->quit();
+ if (thread->wait(3000))
+ delete thread;
+ else
+ qWarning("thread hung, leaking memory so test can finish");
+ }
+};
+
+struct QDeleteLaterCleanup
+{
+ static inline void cleanup(QObject *o)
+ {
+ o->deleteLater();
+ }
+};
+
void tst_QNetworkReply::httpProxyCommandsSynchronous()
{
QFETCH(QUrl, url);
@@ -4961,11 +5032,9 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
// when using synchronous commands, we need a different event loop for
// the server thread, because the client is never returning to the
// event loop
- MiniHttpServer proxyServer(responseToSend);
- QThread serverThread;
- proxyServer.moveToThread(&serverThread);
- serverThread.start();
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer.serverPort());
+ QScopedPointer<QThread, QThreadCleanup> serverThread(new QThread);
+ QScopedPointer<MiniHttpServer, QDeleteLaterCleanup> proxyServer(new MiniHttpServer(responseToSend, false, serverThread.data()));
+ QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer->serverPort());
manager.setProxy(proxy);
QNetworkRequest request(url);
@@ -4978,8 +5047,6 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
QNetworkReplyPtr reply = manager.get(request);
QVERIFY(reply->isFinished()); // synchronous
manager.setProxy(QNetworkProxy());
- serverThread.quit();
- serverThread.wait(3000);
//qDebug() << reply->error() << reply->errorString();
@@ -4987,7 +5054,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous()
// especially since it won't succeed in the HTTPS case
// so just check that the command was correct
- QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length());
+ QString receivedHeader = proxyServer->receivedData.left(expectedCommand.length());
QCOMPARE(receivedHeader, expectedCommand);
}
@@ -5480,7 +5547,7 @@ void tst_QNetworkReply::getFromHttpIntoBuffer()
// FIXME we really need to consolidate all those server implementations
class GetFromHttpIntoBuffer2Server : QObject {
- Q_OBJECT;
+ Q_OBJECT
qint64 dataSize;
qint64 dataSent;
QTcpServer server;
@@ -5602,6 +5669,7 @@ public:
void finishedSlot() {
// We should have already received all readyRead
+ QVERIFY(!bytesAvailableList.isEmpty());
QVERIFY(bytesAvailableList.last() == uploadSize);
}
};
@@ -5747,7 +5815,7 @@ void tst_QNetworkReply::getFromUnreachableIp()
QNetworkReplyPtr reply = manager.get(request);
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTestEventLoop::instance().enterLoop(5);
+ QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(reply->error() != QNetworkReply::NoError);
@@ -5933,7 +6001,7 @@ void tst_QNetworkReply::synchronousRequest_data()
<< QString("text/plain");
QTest::newRow("simple-file")
- << QUrl(QString::fromLatin1("file:///" SRCDIR "/rfc3252.txt"))
+ << QUrl::fromLocalFile(SRCDIR "/rfc3252.txt")
<< QString("file:" SRCDIR "/rfc3252.txt")
<< true
<< QString();
diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
index 3315836..13cedda 100644
--- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp
@@ -48,7 +48,7 @@
#include <QtNetwork/qnetworkconfigmanager.h>
#include <QtNetwork/qnetworksession.h>
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -105,7 +105,7 @@ private:
int inProcessSessionManagementCount;
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -140,7 +140,7 @@ void tst_QNetworkSession::initTestCase()
testsToRun["userChoiceSession"] = true;
testsToRun["sessionOpenCloseStop"] = true;
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -226,7 +226,7 @@ void tst_QNetworkSession::cleanupTestCase()
"inProcessSessionManagement()");
}
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
+#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN)
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
index 0b7e7ef..5594dc3 100644
--- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -46,7 +46,13 @@
#include <QtCore/QSocketNotifier>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
+#ifdef Q_OS_SYMBIAN
+#include <private/qsymbiansocketengine_p.h>
+#define NATIVESOCKETENGINE QSymbianSocketEngine
+#else
#include <private/qnativesocketengine_p.h>
+#define NATIVESOCKETENGINE QNativeSocketEngine
+#endif
class tst_QSocketNotifier : public QObject
{
@@ -71,10 +77,10 @@ class UnexpectedDisconnectTester : public QObject
{
Q_OBJECT
public:
- QNativeSocketEngine *readEnd1, *readEnd2;
+ NATIVESOCKETENGINE *readEnd1, *readEnd2;
int sequence;
- UnexpectedDisconnectTester(QNativeSocketEngine *s1, QNativeSocketEngine *s2)
+ UnexpectedDisconnectTester(NATIVESOCKETENGINE *s1, NATIVESOCKETENGINE *s2)
: readEnd1(s1), readEnd2(s2), sequence(0)
{
QSocketNotifier *notifier1 =
@@ -124,7 +130,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
- QNativeSocketEngine readEnd1;
+ NATIVESOCKETENGINE readEnd1;
readEnd1.initialize(QAbstractSocket::TcpSocket);
bool b = readEnd1.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd1.waitForWrite());
@@ -135,7 +141,7 @@ void tst_QSocketNotifier::unexpectedDisconnection()
QTcpSocket *writeEnd1 = server.nextPendingConnection();
QVERIFY(writeEnd1 != 0);
- QNativeSocketEngine readEnd2;
+ NATIVESOCKETENGINE readEnd2;
readEnd2.initialize(QAbstractSocket::TcpSocket);
b = readEnd2.connectToHost(server.serverAddress(), server.serverPort());
QVERIFY(readEnd2.waitForWrite());
diff --git a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
index 171d428..c82c62d 100644
--- a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
+++ b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
@@ -2,7 +2,7 @@ load(qttest_p4)
SOURCES += tst_qsocks5socketengine.cpp
-include(../qnativesocketengine/qsocketengine.pri)
+include(../platformsocketengine/platformsocketengine.pri)
MOC_DIR=tmp
diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro
index aeeae8f..154f9ca 100644
--- a/tests/auto/qsslsocket/qsslsocket.pro
+++ b/tests/auto/qsslsocket/qsslsocket.pro
@@ -23,7 +23,7 @@ wince* {
DEPLOYMENT += certFiles
} else:symbian {
DEFINES += QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+ TARGET.EPOCHEAPSIZE="0x100 0x3000000"
TARGET.CAPABILITY=NetworkServices
certFiles.files = certs ssl.tar.gz
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp
index 472be69..023fbb3 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -533,6 +533,8 @@ void tst_QSslSocket::sslErrors()
QSslSocketPtr socket = newSocket();
socket->connectToHostEncrypted(host, port);
+ if (!socket->waitForConnected())
+ QEXPECT_FAIL("imap.trolltech.com", "server not open to internet", Continue);
socket->waitForEncrypted(5000);
SslErrorList output;
@@ -541,7 +543,7 @@ void tst_QSslSocket::sslErrors()
}
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
- if (output.last() == QSslError::CertificateUntrusted)
+ if (output.count() && output.last() == QSslError::CertificateUntrusted)
output.takeLast();
#endif
QCOMPARE(output, expected);
@@ -650,7 +652,7 @@ void tst_QSslSocket::sessionCipher()
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
QVERIFY(socket->sessionCipher().isNull());
socket->connectToHost(QtNetworkSettings::serverName(), 443 /* https */);
- QVERIFY(socket->waitForConnected(5000));
+ QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->sessionCipher().isNull());
socket->startClientEncryption();
QVERIFY(socket->waitForEncrypted(5000));
@@ -684,7 +686,7 @@ void tst_QSslSocket::localCertificate()
socket->setPrivateKey(QLatin1String(SRCDIR "certs/fluke.key"));
socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443);
- QVERIFY(socket->waitForEncrypted(5000));
+ QVERIFY(socket->waitForEncrypted(10000));
}
void tst_QSslSocket::mode()
@@ -1519,8 +1521,8 @@ protected:
// delayed start of encryption
QTest::qSleep(100);
QSslSocket *socket = server.socket;
- Q_ASSERT(socket);
- Q_ASSERT(socket->isValid());
+ QVERIFY(socket);
+ QVERIFY(socket->isValid());
socket->ignoreSslErrors();
socket->startServerEncryption();
if (!socket->waitForEncrypted(2000))
@@ -1710,7 +1712,7 @@ void tst_QSslSocket::disconnectFromHostWhenConnecting()
QCOMPARE(state, socket->state());
QVERIFY(socket->state() == QAbstractSocket::HostLookupState ||
socket->state() == QAbstractSocket::ConnectingState);
- QVERIFY(socket->waitForDisconnected(5000));
+ QVERIFY(socket->waitForDisconnected(10000));
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
// we did not call close, so the socket must be still open
QVERIFY(socket->isOpen());
diff --git a/tests/auto/qtcpserver/crashingServer/crashingServer.pro b/tests/auto/qtcpserver/crashingServer/crashingServer.pro
index 0bea655..700e952 100644
--- a/tests/auto/qtcpserver/crashingServer/crashingServer.pro
+++ b/tests/auto/qtcpserver/crashingServer/crashingServer.pro
@@ -6,3 +6,4 @@ DESTDIR = ./
# This means the auto test works on some machines for MinGW. No dialog stalls
# the application.
win32-g++*:CONFIG += console
+symbian: TARGET.CAPABILITY += NetworkServices ReadUserData
diff --git a/tests/auto/qtcpserver/qtcpserver.pro b/tests/auto/qtcpserver/qtcpserver.pro
index a3744a2..e123cfe 100644
--- a/tests/auto/qtcpserver/qtcpserver.pro
+++ b/tests/auto/qtcpserver/qtcpserver.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = test crashingServer
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qtcpserver/test/test.pro b/tests/auto/qtcpserver/test/test.pro
index e91ba20..65e1d82 100644
--- a/tests/auto/qtcpserver/test/test.pro
+++ b/tests/auto/qtcpserver/test/test.pro
@@ -13,9 +13,10 @@ wince*: {
}
symbian {
- crashApp.files = $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/crashingServer.exe
- crashApp.path = .
- DEPLOYMENT += crashApp
+ crashApp.files = $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/crashingServer.exe
+ crashApp.path = .
+ DEPLOYMENT += crashApp
+ TARGET.CAPABILITY += NetworkServices ReadUserData
}
TARGET = ../tst_qtcpserver
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index 3d377a4..cff2fe5 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -70,6 +70,9 @@
Q_DECLARE_METATYPE(QNetworkProxy)
Q_DECLARE_METATYPE(QList<QNetworkProxy>)
+#include <QNetworkSession>
+#include <QNetworkConfiguration>
+#include <QNetworkConfigurationManager>
#include "../network-settings.h"
//TESTED_CLASS=
@@ -86,6 +89,7 @@ public:
public slots:
void initTestCase_data();
+ void initTestCase();
void init();
void cleanup();
private slots:
@@ -107,6 +111,11 @@ private slots:
void proxyFactory();
void qtbug14268_peek();
+
+private:
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkSession *networkSession;
+#endif
};
// Testing get/set functions
@@ -141,6 +150,16 @@ void tst_QTcpServer::initTestCase_data()
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
}
+void tst_QTcpServer::initTestCase()
+{
+#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager man;
+ networkSession = new QNetworkSession(man.defaultConfiguration(), this);
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened());
+#endif
+}
+
void tst_QTcpServer::init()
{
QFETCH_GLOBAL(bool, setProxy);
@@ -190,7 +209,7 @@ void tst_QTcpServer::clientServerLoop()
QTcpSocket client;
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.serverAddress() == QHostAddress::Any))
+ if (!(server.serverAddress() == QHostAddress::Any) && !(server.serverAddress() == QHostAddress::AnyIPv6))
serverAddress = server.serverAddress();
client.connectToHost(serverAddress, server.serverPort());
@@ -222,9 +241,6 @@ void tst_QTcpServer::clientServerLoop()
//----------------------------------------------------------------------------------
void tst_QTcpServer::ipv6Server()
{
-#if defined(Q_OS_SYMBIAN)
- QSKIP("Symbian: IPv6 is not yet supported", SkipAll);
-#endif
//### need to enter the event loop for the server to get the connection ?? ( windows)
QTcpServer server;
if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) {
@@ -244,6 +260,8 @@ void tst_QTcpServer::ipv6Server()
QTcpSocket *serverSocket = 0;
QVERIFY((serverSocket = server.nextPendingConnection()));
+ serverSocket->close();
+ delete serverSocket;
}
//----------------------------------------------------------------------------------
@@ -379,7 +397,8 @@ void tst_QTcpServer::setSocketDescriptor()
QTcpServer server;
QVERIFY(!server.setSocketDescriptor(42));
QCOMPARE(server.serverError(), QAbstractSocket::UnsupportedSocketOperationError);
-
+#ifndef Q_OS_SYMBIAN
+ //adopting Open C sockets is not supported, neither is adopting externally created RSocket
#ifdef Q_OS_WIN
// ensure winsock is started
WSADATA wsaData;
@@ -402,6 +421,7 @@ void tst_QTcpServer::setSocketDescriptor()
#ifdef Q_OS_WIN
WSACleanup();
#endif
+#endif
}
//----------------------------------------------------------------------------------
@@ -493,6 +513,9 @@ void tst_QTcpServer::addressReusable()
void tst_QTcpServer::setNewSocketDescriptorBlocking()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("open C ioctls on Qt sockets not supported", SkipAll);
+#else
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QFETCH_GLOBAL(int, proxyType);
@@ -507,6 +530,7 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking()
socket.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(server.waitForNewConnection(5000));
QVERIFY(server.ok);
+#endif
}
void tst_QTcpServer::invalidProxy_data()
diff --git a/tests/auto/qtcpsocket/qtcpsocket.pro b/tests/auto/qtcpsocket/qtcpsocket.pro
index 8b1f664..5dfff5b 100644
--- a/tests/auto/qtcpsocket/qtcpsocket.pro
+++ b/tests/auto/qtcpsocket/qtcpsocket.pro
@@ -6,4 +6,3 @@ wince*|symbian|vxworks* : SUBDIRS = test
requires(contains(QT_CONFIG,private_tests))
-symbian: TARGET.CAPABILITY = NetworkServices
diff --git a/tests/auto/qtcpsocket/stressTest/stressTest.pro b/tests/auto/qtcpsocket/stressTest/stressTest.pro
index 9a653c6..adf0217 100644
--- a/tests/auto/qtcpsocket/stressTest/stressTest.pro
+++ b/tests/auto/qtcpsocket/stressTest/stressTest.pro
@@ -9,4 +9,5 @@ DESTDIR = ./
MOC_DIR = .moc/
TMP_DIR = .tmp/
+symbian: TARGET.CAPABILITY = NetworkServices
diff --git a/tests/auto/qtcpsocket/test/test.pro b/tests/auto/qtcpsocket/test/test.pro
index c4369df..f4207d6 100644
--- a/tests/auto/qtcpsocket/test/test.pro
+++ b/tests/auto/qtcpsocket/test/test.pro
@@ -11,7 +11,10 @@ wince*: {
QT += network
vxworks:QT -= gui
-symbian: TARGET.EPOCHEAPSIZE="0x100 0x1000000"
+symbian: {
+ TARGET.EPOCHEAPSIZE="0x100 0x3000000"
+ TARGET.CAPABILITY = NetworkServices
+}
TARGET = tst_qtcpsocket
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 21092c4..6852e29 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -336,7 +336,9 @@ void tst_QTcpSocket::init()
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QFETCH_GLOBAL(int, proxyType);
- QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString();
+ QList<QHostAddress> addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses();
+ QVERIFY2(addresses.count() > 0, "failed to get ip address for test server");
+ QString fluke = addresses.first().toString();
QNetworkProxy proxy;
switch (proxyType) {
@@ -443,6 +445,9 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
void tst_QTcpSocket::setSocketDescriptor()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("adopting open c socket handles is not supported", SkipAll);
+#else
QFETCH_GLOBAL(bool, setProxy);
if (setProxy)
return; // this test doesn't make sense with proxies
@@ -483,6 +488,7 @@ void tst_QTcpSocket::setSocketDescriptor()
#ifdef Q_OS_WIN
delete dummy;
#endif
+#endif
}
//----------------------------------------------------------------------------------
@@ -605,14 +611,14 @@ void tst_QTcpSocket::timeoutConnect()
// Port 1357 is configured to drop packets on the test server
socket->connectToHost(address, 1357);
- QVERIFY(timer.elapsed() < 50);
- QVERIFY(!socket->waitForConnected(200));
+ QVERIFY(timer.elapsed() < 150);
+ QVERIFY(!socket->waitForConnected(1000)); //200ms is too short when using SOCKS proxy authentication
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError));
timer.start();
socket->connectToHost(address, 1357);
- QVERIFY(timer.elapsed() < 50);
+ QVERIFY(timer.elapsed() < 150);
QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
@@ -975,6 +981,9 @@ void tst_QTcpSocket::disconnectWhileConnecting_data()
void tst_QTcpSocket::disconnectWhileConnecting()
{
QFETCH(QByteArray, data);
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -1035,7 +1044,7 @@ public:
: server(0), ok(false), quit(false)
{ }
- ~ReceiverThread() { /*delete server;*/ terminate(); wait(); }
+ ~ReceiverThread() { }
bool listen()
{
@@ -1047,6 +1056,14 @@ public:
return true;
}
+ static void cleanup(void *ptr)
+ {
+ ReceiverThread* self = reinterpret_cast<ReceiverThread*>(ptr);
+ self->quit = true;
+ self->wait(30000);
+ delete self;
+ }
+
protected:
void run()
{
@@ -1092,19 +1109,20 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop_data()
void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
{
QFETCH(QByteArray, data);
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
- ReceiverThread thread;
- QVERIFY(thread.listen());
- thread.start();
+ QScopedPointer<ReceiverThread, ReceiverThread> thread (new ReceiverThread);
+ QVERIFY(thread->listen());
+ thread->start();
// proceed to the connect-write-disconnect
QTcpSocket *socket = newSocket();
- socket->connectToHost("127.0.0.1", thread.serverPort);
+ socket->connectToHost("127.0.0.1", thread->serverPort);
if (!data.isEmpty())
socket->write(data);
if (socket->state() == QAbstractSocket::ConnectedState) {
- thread.quit = true;
- thread.wait();
QSKIP("localhost connections are immediate, test case is invalid", SkipSingle);
}
@@ -1130,9 +1148,9 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
delete socket;
// check if the other side received everything ok
- QVERIFY(thread.wait(30000));
- QVERIFY(thread.ok);
- QCOMPARE(thread.receivedData, data);
+ QVERIFY(thread->wait(30000));
+ QVERIFY(thread->ok);
+ QCOMPARE(thread->receivedData, data);
}
//----------------------------------------------------------------------------------
@@ -1194,6 +1212,7 @@ void tst_QTcpSocket::downloadBigFile()
connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot()));
connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot()));
+ connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80);
@@ -1380,7 +1399,7 @@ void tst_QTcpSocket::flush()
connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot()));
socket->connectToHost(QtNetworkSettings::serverName(), 143);
- enterLoop(5000);
+ enterLoop(60);
QVERIFY(socket->isOpen());
socket->write("1 LOGOUT\r\n");
@@ -1413,7 +1432,7 @@ void tst_QTcpSocket::dontCloseOnTimeout()
QVERIFY(server.listen());
QHostAddress serverAddress = QHostAddress::LocalHost;
- if (!(server.serverAddress() == QHostAddress::Any))
+ if (!(server.serverAddress() == QHostAddress::Any) && !(server.serverAddress() == QHostAddress::AnyIPv6))
serverAddress = server.serverAddress();
QTcpSocket *socket = newSocket();
@@ -1633,6 +1652,9 @@ private slots:
//----------------------------------------------------------------------------------
void tst_QTcpSocket::remoteCloseError()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
RemoteCloseErrorServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -1943,6 +1965,9 @@ void tst_QTcpSocket::linuxKernelBugLocalSocket()
//----------------------------------------------------------------------------------
void tst_QTcpSocket::abortiveClose()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
connect(&server, SIGNAL(newConnection()), this, SLOT(exitLoopSlot()));
@@ -1981,6 +2006,9 @@ void tst_QTcpSocket::abortiveClose_abortSlot()
//----------------------------------------------------------------------------------
void tst_QTcpSocket::localAddressEmptyOnBSD()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost));
@@ -2251,6 +2279,9 @@ void tst_QTcpSocket::moveToThread0()
void tst_QTcpSocket::increaseReadBufferSize()
{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return; //proxy not useful for localhost test case
QTcpServer server;
QTcpSocket *active = newSocket();
connect(active, SIGNAL(readyRead()), SLOT(exitLoopSlot()));
diff --git a/tests/auto/qudpsocket/clientserver/clientserver.pro b/tests/auto/qudpsocket/clientserver/clientserver.pro
index 5fe65b3..6da1486 100644
--- a/tests/auto/qudpsocket/clientserver/clientserver.pro
+++ b/tests/auto/qudpsocket/clientserver/clientserver.pro
@@ -5,4 +5,4 @@ CONFIG -= app_bundle
TARGET = clientserver
DESTDIR = ./
-
+symbian: TARGET.CAPABILITY += NetworkServices
diff --git a/tests/auto/qudpsocket/qudpsocket.pro b/tests/auto/qudpsocket/qudpsocket.pro
index 8fd3545..4ddb717 100644
--- a/tests/auto/qudpsocket/qudpsocket.pro
+++ b/tests/auto/qudpsocket/qudpsocket.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
SUBDIRS = test clientserver
-symbian: TARGET.CAPABILITY = NetworkServices
-
diff --git a/tests/auto/qudpsocket/test/test.pro b/tests/auto/qudpsocket/test/test.pro
index 7e5ffe4..b68d30c 100644
--- a/tests/auto/qudpsocket/test/test.pro
+++ b/tests/auto/qudpsocket/test/test.pro
@@ -22,4 +22,4 @@ wince*|symbian: {
TARGET = tst_qudpsocket
-
+symbian: TARGET.CAPABILITY += NetworkServices
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 6ba55b2..e6fe068 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -108,6 +108,8 @@ private slots:
void setMulticastInterface();
void multicast_data();
void multicast();
+ void echo_data();
+ void echo();
protected slots:
void empty_readyReadSlot();
@@ -1095,5 +1097,55 @@ void tst_QUdpSocket::multicast()
QVERIFY2(receiver.leaveMulticastGroup(groupAddress), qPrintable(receiver.errorString()));
}
+void tst_QUdpSocket::echo_data()
+{
+ QTest::addColumn<bool>("connect");
+ QTest::newRow("writeDatagram") << false;
+ QTest::newRow("write") << true;
+}
+
+void tst_QUdpSocket::echo()
+{
+ QFETCH(bool, connect);
+ QHostInfo info = QHostInfo::fromName(QtNetworkSettings::serverName());
+ QVERIFY(info.addresses().count());
+ QHostAddress remote = info.addresses().first();
+
+ QUdpSocket sock;
+ if (connect) {
+ sock.connectToHost(remote, 7);
+ } else {
+ sock.bind();
+ }
+ QByteArray out(30, 'x');
+ QByteArray in;
+ int successes = 0;
+ for (int i=0;i<20;i++) {
+ if (connect) {
+ sock.write(out);
+ } else {
+ sock.writeDatagram(out, remote, 7);
+ }
+ if (sock.waitForReadyRead(1000)) {
+ while (sock.hasPendingDatagrams()) {
+ QHostAddress from;
+ quint16 port;
+ if (connect) {
+ in = sock.read(sock.pendingDatagramSize());
+ } else {
+ in.resize(sock.pendingDatagramSize());
+ sock.readDatagram(in.data(), in.length(), &from, &port);
+ }
+ if (in==out)
+ successes++;
+ }
+ }
+ if (!sock.isValid())
+ QFAIL(sock.errorString().toLatin1().constData());
+ qDebug() << "packets in" << successes << "out" << i;
+ }
+ QVERIFY(successes >= 18);
+}
+
QTEST_MAIN(tst_QUdpSocket)
#include "tst_qudpsocket.moc"
diff --git a/tests/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp
new file mode 100644
index 0000000..2f017a0
--- /dev/null
+++ b/tests/manual/socketengine/main.cpp
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include "../../auto/network-settings.h"
+#include <QtNetwork>
+#include <QDebug>
+#include <private/qabstractsocketengine_p.h>
+#include <cstdio>
+#include <strings.h>
+#include <QNetworkConfigurationManager>
+#include <QNetworkConfiguration>
+#include <QNetworkSession>
+#include <QCoreApplication>
+
+const int bufsize = 16*1024;
+char buf[bufsize];
+
+int main(int argc, char**argv)
+{
+ QCoreApplication app(argc, argv);
+
+#ifdef Q_OS_SYMBIAN
+ QNetworkConfigurationManager configurationManager;
+ QNetworkConfiguration configuration = configurationManager.defaultConfiguration();
+ if (!configuration.isValid()) {
+ qDebug() << "Got an invalid session configuration";
+ exit(1);
+ }
+
+ qDebug() << "Opening session...";
+ QNetworkSession *session = new QNetworkSession(configuration);
+
+ // Does not work:
+// session->open();
+// session->waitForOpened();
+
+ // works:
+ QEventLoop loop;
+ QObject::connect(session, SIGNAL(opened()), &loop, SLOT(quit()), Qt::QueuedConnection);
+ QMetaObject::invokeMethod(session, "open", Qt::QueuedConnection);
+ loop.exec();
+
+
+ if (session->isOpen()) {
+ qDebug() << "session opened";
+ } else {
+ qDebug() << "session could not be opened -" << session->errorString();
+ exit(1);
+ }
+#endif
+
+ // create it
+ QAbstractSocketEngine *socketEngine =
+ QAbstractSocketEngine::createSocketEngine(QAbstractSocket::TcpSocket, QNetworkProxy(QNetworkProxy::NoProxy), 0);
+ if (!socketEngine) {
+ qDebug() << "could not create engine";
+ exit(1);
+ }
+
+ // initialize it
+ bool initialized = socketEngine->initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol);
+ if (!initialized) {
+ qDebug() << "not able to initialize engine";
+ exit(1);
+ }
+
+ // wait for connected
+ int r = socketEngine->connectToHost(QHostAddress("74.125.77.99"), 80); // google
+ bool readyToRead = false;
+ bool readyToWrite = false;
+ socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, true, 10*1000);
+ if (r <= 0) //timeout or error
+ exit(1);
+ if (readyToWrite) {
+ // write the request
+ QByteArray request("GET /robots.txt HTTP/1.0\r\n\r\n");
+ int ret = socketEngine->write(request.constData(), request.length());
+ if (ret == request.length()) {
+ // read the response in a loop
+ do {
+ bool waitReadResult = socketEngine->waitForRead(10*1000);
+ int available = socketEngine->bytesAvailable();
+ if (waitReadResult == true && available == 0) {
+ // disconnected
+ exit(0);
+ }
+ bzero(buf, bufsize);
+ ret = socketEngine->read(buf, available);
+ if (ret > 0) {
+#ifdef Q_OS_SYMBIAN
+ qDebug() << buf; //printf goes only to screen, this goes to remote debug channel
+#else
+ printf("%s", buf);
+#endif
+ } else {
+ // some failure when reading
+ exit(1);
+ }
+ } while (1);
+ } else {
+ qDebug() << "failed writing";
+ }
+ } else {
+ qDebug() << "failed connecting";
+ }
+ delete socketEngine;
+}
+
diff --git a/tests/manual/socketengine/socketengine.pro b/tests/manual/socketengine/socketengine.pro
new file mode 100644
index 0000000..76a40be
--- /dev/null
+++ b/tests/manual/socketengine/socketengine.pro
@@ -0,0 +1,15 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_socketengine
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network
+
+CONFIG += release
+
+symbian: TARGET.CAPABILITY = NetworkServices
+
+# Input
+SOURCES += main.cpp