summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qlocalsocket/tst_qlocalsocket.cpp')
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp94
1 files changed, 85 insertions, 9 deletions
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 4f1eb1d..be8ec3f 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -47,9 +47,16 @@
#include <QtNetwork/qlocalserver.h>
#include "../../shared/util.h"
+#ifdef Q_OS_SYMBIAN
+ #include <unistd.h>
+#endif
//TESTED_CLASS=QLocalServer, QLocalSocket
//TESTED_FILES=network/socket/qlocalserver.cpp network/socket/qlocalsocket.cpp
-
+#ifdef Q_OS_SYMBIAN
+ #define STRINGIFY(x) #x
+ #define TOSTRING(x) STRINGIFY(x)
+ #define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/"
+#endif
Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError)
Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState)
@@ -105,6 +112,10 @@ private slots:
void debug();
+#ifdef Q_OS_SYMBIAN
+private:
+ void unlink(QString serverName);
+#endif
};
tst_QLocalSocket::tst_QLocalSocket()
@@ -291,6 +302,9 @@ void tst_QLocalSocket::listen()
QSignalSpy spyNewConnection(&server, SIGNAL(newConnection()));
QFETCH(QString, name);
+#ifdef Q_OS_SYMBIAN
+ unlink(name);
+#endif
QFETCH(bool, canListen);
QFETCH(bool, close);
QVERIFY2((server.listen(name) == canListen), server.errorString().toLatin1().constData());
@@ -341,7 +355,9 @@ void tst_QLocalSocket::listenAndConnect()
QFETCH(QString, name);
QFETCH(bool, canListen);
-
+#ifdef Q_OS_SYMBIAN
+ unlink(name);
+#endif
QCOMPARE(server.listen(name), canListen);
QTest::qWait(1000);
//QVERIFY(!server.errorString().isEmpty());
@@ -361,7 +377,7 @@ void tst_QLocalSocket::listenAndConnect()
QSignalSpy spyReadyRead(socket, SIGNAL(readyRead()));
socket->connectToServer(name);
-#ifdef QT_LOCALSOCKET_TCP
+#if defined(QT_LOCALSOCKET_TCP) || defined (Q_OS_SYMBIAN)
QTest::qWait(250);
#endif
@@ -464,6 +480,9 @@ void tst_QLocalSocket::sendData_data()
void tst_QLocalSocket::sendData()
{
QFETCH(QString, name);
+#ifdef Q_OS_SYMBIAN
+ unlink(name);
+#endif
QFETCH(bool, canListen);
LocalServer server;
@@ -481,8 +500,10 @@ void tst_QLocalSocket::sendData()
// test creating a connection
socket.connectToServer(name);
bool timedOut = true;
+
QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen);
-#ifdef QT_LOCALSOCKET_TCP
+
+#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN)
QTest::qWait(250);
#endif
QVERIFY(!timedOut);
@@ -492,7 +513,11 @@ void tst_QLocalSocket::sendData()
// test sending/receiving data
if (server.hasPendingConnections()) {
QString testLine = "test";
+#ifdef Q_OS_SYMBIAN
+ for (int i = 0; i < 25 * 1024; ++i)
+#else
for (int i = 0; i < 50000; ++i)
+#endif
testLine += "a";
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
@@ -513,7 +538,9 @@ void tst_QLocalSocket::sendData()
QCOMPARE(spyReadyRead.count(), 1);
QVERIFY(testLine.startsWith(in.readLine()));
+
QVERIFY(wrote || serverSocket->waitForBytesWritten(1000));
+
QCOMPARE(serverSocket->errorString(), QString("Unknown error"));
QCOMPARE(socket.errorString(), QString("Unknown error"));
}
@@ -536,7 +563,9 @@ void tst_QLocalSocket::fullPath()
{
LocalServer server;
QString name = "qlocalsocket_pathtest";
-#if defined(QT_LOCALSOCKET_TCP)
+#if defined(Q_OS_SYMBIAN)
+ QString path = "";
+#elif defined(QT_LOCALSOCKET_TCP)
QString path = "QLocalServer";
#elif defined(Q_OS_WIN)
QString path = "\\\\.\\pipe\\";
@@ -550,6 +579,10 @@ void tst_QLocalSocket::fullPath()
LocalSocket socket;
socket.connectToServer(serverName);
+#if defined (Q_OS_SYMBIAN)
+ QTest::qWait(250);
+#endif
+
QCOMPARE(socket.serverName(), serverName);
QCOMPARE(socket.fullServerName(), serverName);
socket.disconnectFromServer();
@@ -573,6 +606,9 @@ void tst_QLocalSocket::hitMaximumConnections()
QFETCH(int, max);
LocalServer server;
QString name = "tst_localsocket";
+#ifdef Q_OS_SYMBIAN
+ unlink(name);
+#endif
server.setMaxPendingConnections(max);
QVERIFY2(server.listen(name), server.errorString().toLatin1().constData());
int connections = server.maxPendingConnections() + 1;
@@ -621,7 +657,7 @@ public:
|| socket.error() == QLocalSocket::ConnectionRefusedError)
&& tries < 1000);
if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) {
- QVERIFY(socket.waitForConnected(3000));
+ QVERIFY(socket.waitForConnected(30000));
QVERIFY(socket.state() == QLocalSocket::ConnectedState);
}
@@ -651,7 +687,7 @@ public:
int done = clients;
while (done > 0) {
bool timedOut = true;
- QVERIFY(server.waitForNewConnection(3000, &timedOut));
+ QVERIFY(server.waitForNewConnection(30000, &timedOut));
QVERIFY(!timedOut);
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
@@ -686,20 +722,30 @@ void tst_QLocalSocket::threadedConnection_data()
void tst_QLocalSocket::threadedConnection()
{
+#ifdef Q_OS_SYMBIAN
+ unlink("qlocalsocket_threadtest");
+#endif
+
QFETCH(int, threads);
Server server;
+#if defined(Q_OS_SYMBIAN)
+ server.setStackSize(0x14000);
+#endif
server.clients = threads;
server.start();
QList<Client*> clients;
for (int i = 0; i < threads; ++i) {
clients.append(new Client());
+#if defined(Q_OS_SYMBIAN)
+ clients.last()->setStackSize(0x14000);
+#endif
clients.last()->start();
}
server.wait();
while (!clients.isEmpty()) {
- QVERIFY(clients.first()->wait(30000));
+ QVERIFY(clients.first()->wait(300000));
Client *client =clients.takeFirst();
client->terminate();
delete client;
@@ -722,7 +768,7 @@ void tst_QLocalSocket::processConnection_data()
*/
void tst_QLocalSocket::processConnection()
{
-#if defined(QT_NO_PROCESS)
+#if defined(QT_NO_PROCESS) || defined(Q_CC_NOKIAX86)
QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll);
#else
QFETCH(int, processes);
@@ -777,6 +823,9 @@ void tst_QLocalSocket::longPath()
void tst_QLocalSocket::waitForDisconnect()
{
QString name = "tst_localsocket";
+#ifdef Q_OS_SYMBIAN
+ unlink(name);
+#endif
LocalServer server;
QVERIFY(server.listen(name));
LocalSocket socket;
@@ -828,6 +877,10 @@ void tst_QLocalSocket::removeServer()
void tst_QLocalSocket::recycleServer()
{
+#ifdef Q_OS_SYMBIAN
+ unlink("recycletest1");
+#endif
+
LocalServer server;
QLocalSocket client;
@@ -879,6 +932,29 @@ void tst_QLocalSocket::debug()
qDebug() << QLocalSocket::ConnectionRefusedError << QLocalSocket::UnconnectedState;
}
+#ifdef Q_OS_SYMBIAN
+void tst_QLocalSocket::unlink(QString name)
+{
+ if(name.length() == 0)
+ return;
+
+ QString fullName;
+ // determine the full server path
+ if (name.startsWith(QLatin1Char('/'))) {
+ fullName = name;
+ } else {
+ fullName = QDir::cleanPath(QDir::tempPath());
+ fullName += QLatin1Char('/') + name;
+ fullName = QDir::toNativeSeparators(fullName);
+ }
+
+ int result = ::unlink(fullName.toUtf8().data());
+
+ if(result != 0) {
+ qWarning() << "Unlinking " << fullName << " failed with " << strerror(errno);
+ }
+}
+#endif
QTEST_MAIN(tst_QLocalSocket)
#include "tst_qlocalsocket.moc"