summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocalsocket
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qlocalsocket')
-rw-r--r--tests/auto/qlocalsocket/lackey/lackey.pro4
-rw-r--r--tests/auto/qlocalsocket/lackey/main.cpp2
-rw-r--r--tests/auto/qlocalsocket/qlocalsocket.pro2
-rw-r--r--tests/auto/qlocalsocket/test/test.pro18
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp94
5 files changed, 104 insertions, 16 deletions
diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro
index 7460d8c..7bb6bc3 100644
--- a/tests/auto/qlocalsocket/lackey/lackey.pro
+++ b/tests/auto/qlocalsocket/lackey/lackey.pro
@@ -12,7 +12,7 @@ mac:CONFIG -= app_bundle
DEFINES += QLOCALSERVER_DEBUG
DEFINES += QLOCALSOCKET_DEBUG
-SOURCES += main.cpp
+SOURCES += main.cpp
TARGET = lackey
-
+symbian:TARGET.CAPABILITY = ALL -TCB \ No newline at end of file
diff --git a/tests/auto/qlocalsocket/lackey/main.cpp b/tests/auto/qlocalsocket/lackey/main.cpp
index 0506793..181e6be 100644
--- a/tests/auto/qlocalsocket/lackey/main.cpp
+++ b/tests/auto/qlocalsocket/lackey/main.cpp
@@ -41,7 +41,7 @@
#include <qscriptengine.h>
-#include <QtGui/QtGui>
+ #include <QFile>
#include <QTest>
#include <qlocalsocket.h>
diff --git a/tests/auto/qlocalsocket/qlocalsocket.pro b/tests/auto/qlocalsocket/qlocalsocket.pro
index 4df17de..0849453 100644
--- a/tests/auto/qlocalsocket/qlocalsocket.pro
+++ b/tests/auto/qlocalsocket/qlocalsocket.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = lackey test
-!wince*: SUBDIRS += example
+!wince*:!symbian*: SUBDIRS += example
diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro
index 7befdf9..da741b9 100644
--- a/tests/auto/qlocalsocket/test/test.pro
+++ b/tests/auto/qlocalsocket/test/test.pro
@@ -2,11 +2,14 @@ load(qttest_p4)
DEFINES += QLOCALSERVER_DEBUG
DEFINES += QLOCALSOCKET_DEBUG
-!wince*: {
- DEFINES += SRCDIR=\\\"$$PWD/../\\\"
-} else {
+
+symbian {
+ # nothing
+} else:wince* {
DEFINES += QT_LOCALSOCKET_TCP
DEFINES += SRCDIR=\\\"../\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/../\\\"
}
QT = core network
@@ -27,6 +30,15 @@ CONFIG(debug_and_release) {
wince* {
additionalFiles.sources = ../lackey/lackey.exe
additionalFiles.path = lackey
+}
+
+symbian {
+ additionalFiles.sources = lackey.exe
+ additionalFiles.path = \sys\bin
+ DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x",""))
+}
+
+wince*|symbian {
scriptFiles.sources = ../lackey/scripts/*.js
scriptFiles.path = lackey/scripts
DEPLOYMENT = additionalFiles scriptFiles
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 98e9023..c8abf2f 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)
@@ -108,6 +115,10 @@ private slots:
void debug();
+#ifdef Q_OS_SYMBIAN
+private:
+ void unlink(QString serverName);
+#endif
};
tst_QLocalSocket::tst_QLocalSocket()
@@ -294,6 +305,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());
@@ -344,7 +358,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());
@@ -364,7 +380,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
@@ -467,6 +483,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;
@@ -484,8 +503,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);
@@ -495,7 +516,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);
@@ -516,7 +541,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"));
}
@@ -573,7 +600,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\\";
@@ -587,6 +616,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();
@@ -610,6 +643,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;
@@ -658,7 +694,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);
}
@@ -688,7 +724,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);
@@ -723,20 +759,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;
@@ -759,7 +805,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);
@@ -814,6 +860,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;
@@ -865,6 +914,10 @@ void tst_QLocalSocket::removeServer()
void tst_QLocalSocket::recycleServer()
{
+#ifdef Q_OS_SYMBIAN
+ unlink("recycletest1");
+#endif
+
LocalServer server;
QLocalSocket client;
@@ -933,6 +986,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"