summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocalsocket
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-09-09 05:01:12 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-09-09 05:01:12 (GMT)
commit8e3e60b9ea7e4bccbc6d1a7fa90778e847e64190 (patch)
treee0243494d098a4a8f39f140d4d3e7b9370a765c5 /tests/auto/qlocalsocket
parenta88e4867b35c73af6e5b410e926b6df9dc2e19a5 (diff)
parent62d1b1db21d2660bd5f2322cb9f09cf2598bf90b (diff)
downloadQt-8e3e60b9ea7e4bccbc6d1a7fa90778e847e64190.zip
Qt-8e3e60b9ea7e4bccbc6d1a7fa90778e847e64190.tar.gz
Qt-8e3e60b9ea7e4bccbc6d1a7fa90778e847e64190.tar.bz2
Merge branch '4.6' of git@scm.dev.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests/auto/qlocalsocket')
-rw-r--r--tests/auto/qlocalsocket/example/client/main.cpp8
-rw-r--r--tests/auto/qlocalsocket/example/server/main.cpp8
-rw-r--r--tests/auto/qlocalsocket/lackey/main.cpp8
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp69
4 files changed, 70 insertions, 23 deletions
diff --git a/tests/auto/qlocalsocket/example/client/main.cpp b/tests/auto/qlocalsocket/example/client/main.cpp
index c5b6cfe..03de43b 100644
--- a/tests/auto/qlocalsocket/example/client/main.cpp
+++ b/tests/auto/qlocalsocket/example/client/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -20,10 +21,9 @@
** 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.
+** 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.
diff --git a/tests/auto/qlocalsocket/example/server/main.cpp b/tests/auto/qlocalsocket/example/server/main.cpp
index e572f1a..93a31e1 100644
--- a/tests/auto/qlocalsocket/example/server/main.cpp
+++ b/tests/auto/qlocalsocket/example/server/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -20,10 +21,9 @@
** 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.
+** 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.
diff --git a/tests/auto/qlocalsocket/lackey/main.cpp b/tests/auto/qlocalsocket/lackey/main.cpp
index 2c2f74c..c835d4d 100644
--- a/tests/auto/qlocalsocket/lackey/main.cpp
+++ b/tests/auto/qlocalsocket/lackey/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -20,10 +21,9 @@
** 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.
+** 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.
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index fdfbd8a..3c4af48 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 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.
@@ -20,10 +21,9 @@
** 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.
+** 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.
@@ -110,6 +110,7 @@ private slots:
void writeToClientAndDisconnect();
void debug();
+ void bytesWrittenSignal();
#ifdef Q_OS_SYMBIAN
@@ -423,7 +424,7 @@ void tst_QLocalSocket::listenAndConnect()
for (int j = 0; j < spyStateChanged.count(); ++j) {
QLocalSocket::LocalSocketState s;
s = qVariantValue<QLocalSocket::LocalSocketState>(spyStateChanged.at(j).at(0));
- qDebug() << s;
+ qDebug() << s;
}
#endif
if (canListen)
@@ -508,11 +509,11 @@ void tst_QLocalSocket::sendData()
if (server.hasPendingConnections()) {
QString testLine = "test";
#ifdef Q_OS_SYMBIAN
- for (int i = 0; i < 25 * 1024; ++i)
+ for (int i = 0; i < 25 * 1024; ++i)
#else
- for (int i = 0; i < 50000; ++i)
+ for (int i = 0; i < 50000; ++i)
#endif
- testLine += "a";
+ testLine += "a";
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
QCOMPARE(serverSocket->state(), QLocalSocket::ConnectedState);
@@ -646,7 +647,7 @@ public:
++tries;
} while ((socket.error() == QLocalSocket::ServerNotFoundError
|| socket.error() == QLocalSocket::ConnectionRefusedError)
- && tries < 1000);
+ && tries < 1000);
if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) {
QVERIFY(socket.waitForConnected(3000));
QVERIFY(socket.state() == QLocalSocket::ConnectedState);
@@ -738,8 +739,8 @@ void tst_QLocalSocket::threadedConnection()
while (!clients.isEmpty()) {
QVERIFY(clients.first()->wait(3000));
Client *client =clients.takeFirst();
- client->terminate();
- delete client;
+ client->terminate();
+ delete client;
}
}
@@ -906,6 +907,52 @@ void tst_QLocalSocket::debug()
qDebug() << QLocalSocket::ConnectionRefusedError << QLocalSocket::UnconnectedState;
}
+class WriteThread : public QThread
+{
+Q_OBJECT
+public:
+ void run() {
+ QLocalSocket socket;
+ socket.connectToServer("qlocalsocket_readyread");
+
+ if (!socket.waitForConnected(3000))
+ exec();
+ connect(&socket, SIGNAL(bytesWritten(qint64)),
+ this, SLOT(bytesWritten(qint64)), Qt::QueuedConnection);
+ socket.write("testing\n");
+ exec();
+ }
+public slots:
+ void bytesWritten(qint64) {
+ exit();
+ }
+
+private:
+};
+
+/*
+ Tests the emission of the bytesWritten(qint64)
+ signal.
+
+ Create a thread that will write to a socket.
+ If the bytesWritten(qint64) signal is generated,
+ the slot connected to it will exit the thread,
+ indicating test success.
+
+*/
+void tst_QLocalSocket::bytesWrittenSignal()
+{
+ QLocalServer server;
+ QVERIFY(server.listen("qlocalsocket_readyread"));
+ WriteThread writeThread;
+ writeThread.start();
+ bool timedOut = false;
+ QVERIFY(server.waitForNewConnection(3000, &timedOut));
+ QVERIFY(!timedOut);
+ QTest::qWait(2000);
+ QVERIFY(writeThread.wait(2000));
+}
+
#ifdef Q_OS_SYMBIAN
void tst_QLocalSocket::unlink(QString name)
{