summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network.pro4
-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/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/qnetworkconfiguration/tst_qnetworkconfiguration.cpp8
-rw-r--r--tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp8
-rw-r--r--tests/auto/qnetworkreply/test/test.pro2
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp77
-rw-r--r--tests/auto/qnetworksession/test/tst_qnetworksession.cpp8
-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/manual/socketengine/main.cpp152
-rw-r--r--tests/manual/socketengine/socketengine.pro15
20 files changed, 488 insertions, 123 deletions
diff --git a/tests/auto/network.pro b/tests/auto/network.pro
index b427f1c1bd..50c4487613 100644
--- a/tests/auto/network.pro
+++ b/tests/auto/network.pro
@@ -16,7 +16,7 @@ SUBDIRS=\
qhttpnetworkconnection \
qhttpnetworkreply \
qhttpsocketengine \
- qnativesocketengine \
+ platformsocketengine \
qnetworkaccessmanager \
qnetworkaddressentry \
qnetworkconfiguration \
@@ -43,7 +43,7 @@ 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 0000000000..afe93891ff
--- /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 15f31fdbb5..15f31fdbb5 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 0000000000..faf745c679
--- /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 41eb1e2587..184371d0c9 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 2fa0c24a3d..21460be427 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/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 1b4b503fbc..7e3cd7548b 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 d76ebb6f10..6df619200b 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 4700e5e2f5..0000000000
--- 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 0275d378da..0000000000
--- 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/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index adcfd93655..c31eac7445 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 443fd182a4..7787608485 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/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro
index 7efc2fb24b..12fdf04912 100644
--- a/tests/auto/qnetworkreply/test/test.pro
+++ b/tests/auto/qnetworkreply/test/test.pro
@@ -33,6 +33,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 93e3051c34..7fde3f8d48 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>
@@ -64,6 +65,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>
@@ -133,6 +139,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();
@@ -414,16 +425,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:
@@ -501,6 +519,11 @@ public slots:
client = 0;
}
}
+
+ void threadStartedSlot()
+ {
+ ready.release();
+ }
};
class MyCookieJar: public QNetworkCookieJar
@@ -1138,6 +1161,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()
@@ -1145,6 +1180,9 @@ void tst_QNetworkReply::cleanupTestCase()
#if !defined Q_OS_WIN
QFile::remove(wronlyFileName);
#endif
+ if (networkSession && networkSession->isOpen()) {
+ networkSession->close();
+ }
}
void tst_QNetworkReply::init()
@@ -4507,6 +4545,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);
@@ -4516,11 +4574,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);
@@ -4533,8 +4589,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();
@@ -4542,7 +4596,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);
}
@@ -5157,6 +5211,7 @@ public:
void finishedSlot() {
// We should have already received all readyRead
+ QVERIFY(!bytesAvailableList.isEmpty());
QVERIFY(bytesAvailableList.last() == uploadSize);
}
};
@@ -5302,7 +5357,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);
@@ -5469,7 +5524,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 3315836d90..13ceddabfc 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/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro
index 171d428e15..c82c62d3e8 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 aeeae8ff8b..154f9cabd4 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 4beddadd13..a5b5b23357 100644
--- a/tests/auto/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp
@@ -531,6 +531,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;
@@ -539,7 +541,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);
@@ -648,7 +650,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));
@@ -682,7 +684,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()
@@ -1415,8 +1417,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))
@@ -1606,7 +1608,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/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp
new file mode 100644
index 0000000000..2f017a0c70
--- /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 0000000000..76a40be8e3
--- /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