summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocalsocket
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-14 23:59:31 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-14 23:59:31 (GMT)
commiteaa981c943293bf346a041aa4ad3d254e99ebd78 (patch)
tree860d47d678f1ff9fb640b1046b8f67cf01df375a /tests/auto/qlocalsocket
parent7390cfbcbd5000a7da3eb5dbef790d114b06d042 (diff)
parent3d85883b9e4957f44a870ffb8530acc16882ac01 (diff)
downloadQt-eaa981c943293bf346a041aa4ad3d254e99ebd78.zip
Qt-eaa981c943293bf346a041aa4ad3d254e99ebd78.tar.gz
Qt-eaa981c943293bf346a041aa4ad3d254e99ebd78.tar.bz2
Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into 4.7-integration
* 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: Prospective S60 build fix Thread safety for QFontEngineS60 Allow to build Qt in static with mingw Fix incorrect line breaking in QtWebKit. QLocalSocket: don't emit readChannelFinished() twice on Windows QLocalSocket/Win: QLocalSocketPrivate::bytesAvailable renamed QLocalSocket: fix reading from a socket after broken connection QLocalServer: make many simultaneous connection attempts work on Windows tst_QLocalSocket::threadedConnection autotest stabilized tst_qlocalsocket: pro files of client / server examples fixed Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( d8a9d09376a47b92ea49f1a078c392cbfdbc0ed6 )
Diffstat (limited to 'tests/auto/qlocalsocket')
-rw-r--r--tests/auto/qlocalsocket/example/client/client.pro6
-rw-r--r--tests/auto/qlocalsocket/example/server/server.pro6
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp54
3 files changed, 25 insertions, 41 deletions
diff --git a/tests/auto/qlocalsocket/example/client/client.pro b/tests/auto/qlocalsocket/example/client/client.pro
index eb7e6e6..84f20d6 100644
--- a/tests/auto/qlocalsocket/example/client/client.pro
+++ b/tests/auto/qlocalsocket/example/client/client.pro
@@ -1,14 +1,8 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Wed Jun 6 17:07:12 2007
-######################################################################
-
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += console
-include(../../src/src.pri)
-# Input
QT = core network
SOURCES += main.cpp
diff --git a/tests/auto/qlocalsocket/example/server/server.pro b/tests/auto/qlocalsocket/example/server/server.pro
index 438462d..bfd14d2 100644
--- a/tests/auto/qlocalsocket/example/server/server.pro
+++ b/tests/auto/qlocalsocket/example/server/server.pro
@@ -1,7 +1,3 @@
-######################################################################
-# Automatically generated by qmake (2.01a) Wed Jun 6 15:16:48 2007
-######################################################################
-
TEMPLATE = app
TARGET =
DEPENDPATH += .
@@ -11,8 +7,6 @@ CONFIG += console
QT = core network
-include(../../src/src.pri)
-
# Input
SOURCES += main.cpp
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 44f3c12..d2cba6e 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -683,25 +683,11 @@ public:
QString testLine = "test";
LocalSocket socket;
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
- int tries = 0;
- do {
- socket.connectToServer("qlocalsocket_threadtest");
- if (socket.error() != QLocalSocket::ServerNotFoundError
- && socket.error() != QLocalSocket::ConnectionRefusedError)
- break;
- QTest::qWait(100);
- ++tries;
- } while ((socket.error() == QLocalSocket::ServerNotFoundError
- || socket.error() == QLocalSocket::ConnectionRefusedError)
- && tries < 1000);
- if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) {
- QVERIFY(socket.waitForConnected(7000));
- QVERIFY(socket.state() == QLocalSocket::ConnectedState);
- }
+ socket.connectToServer("qlocalsocket_threadtest");
+ QVERIFY(socket.waitForConnected(1000));
// We should *not* have this signal yet!
- if (tries == 0)
- QCOMPARE(spyReadyRead.count(), 0);
+ QCOMPARE(spyReadyRead.count(), 0);
socket.waitForReadyRead();
QCOMPARE(spyReadyRead.count(), 1);
QTextStream in(&socket);
@@ -715,6 +701,8 @@ class Server : public QThread
public:
int clients;
+ QMutex mutex;
+ QWaitCondition wc;
void run()
{
QString testLine = "test";
@@ -722,6 +710,9 @@ public:
server.setMaxPendingConnections(10);
QVERIFY2(server.listen("qlocalsocket_threadtest"),
server.errorString().toLatin1().constData());
+ mutex.lock();
+ wc.wakeAll();
+ mutex.unlock();
int done = clients;
while (done > 0) {
bool timedOut = true;
@@ -746,14 +737,9 @@ void tst_QLocalSocket::threadedConnection_data()
QTest::addColumn<int>("threads");
QTest::newRow("1 client") << 1;
QTest::newRow("2 clients") << 2;
-#ifdef Q_OS_WINCE
- QTest::newRow("4 clients") << 4;
-#endif
-#ifndef Q_OS_WIN
QTest::newRow("5 clients") << 5;
- QTest::newRow("10 clients") << 10;
-#endif
#ifndef Q_OS_WINCE
+ QTest::newRow("10 clients") << 10;
QTest::newRow("20 clients") << 20;
#endif
}
@@ -770,7 +756,9 @@ void tst_QLocalSocket::threadedConnection()
server.setStackSize(0x14000);
#endif
server.clients = threads;
+ server.mutex.lock();
server.start();
+ server.wc.wait(&server.mutex);
QList<Client*> clients;
for (int i = 0; i < threads; ++i) {
@@ -784,9 +772,7 @@ void tst_QLocalSocket::threadedConnection()
server.wait();
while (!clients.isEmpty()) {
QVERIFY(clients.first()->wait(3000));
- Client *client =clients.takeFirst();
- client->terminate();
- delete client;
+ delete clients.takeFirst();
}
}
@@ -994,6 +980,7 @@ void tst_QLocalSocket::writeToClientAndDisconnect()
QLocalServer server;
QLocalSocket client;
+ QSignalSpy readChannelFinishedSpy(&client, SIGNAL(readChannelFinished()));
QVERIFY(server.listen("writeAndDisconnectServer"));
client.connectToServer("writeAndDisconnectServer");
@@ -1006,10 +993,19 @@ void tst_QLocalSocket::writeToClientAndDisconnect()
memset(buffer, 0, sizeof(buffer));
QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer));
clientSocket->waitForBytesWritten();
- clientSocket->disconnectFromServer();
- QVERIFY(client.waitForReadyRead());
+ clientSocket->close();
+ server.close();
+
+ // Wait for the client to notice the broken connection.
+ int timeout = 5000;
+ do {
+ const int timestep = 100;
+ QTest::qWait(timestep);
+ timeout -= timestep;
+ } while (!readChannelFinishedSpy.count() && timeout > 0);
+
+ QCOMPARE(readChannelFinishedSpy.count(), 1);
QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer));
- QVERIFY(client.waitForDisconnected());
QCOMPARE(client.state(), QLocalSocket::UnconnectedState);
}