diff options
author | Espen Riskedal <espenr@trolltech.com> | 2009-09-29 16:40:52 (GMT) |
---|---|---|
committer | Espen Riskedal <espenr@trolltech.com> | 2009-09-29 16:40:52 (GMT) |
commit | 26a9f6221b6d23c8a8dc81db6a5797a8d3db2397 (patch) | |
tree | 19601edd07171d0b66446f5cfedeea5bd87b87a8 | |
parent | 315df20f0e2e79f1c42396d5bd6146484dcb95d3 (diff) | |
parent | b0c5873f1b34fb67be5c552dcbee9c0fb72bb74e (diff) | |
download | Qt-26a9f6221b6d23c8a8dc81db6a5797a8d3db2397.zip Qt-26a9f6221b6d23c8a8dc81db6a5797a8d3db2397.tar.gz Qt-26a9f6221b6d23c8a8dc81db6a5797a8d3db2397.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
-rw-r--r-- | tests/auto/qlocalsocket/lackey/lackey.pro | 2 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 114 | ||||
-rw-r--r-- | tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp | 6 |
3 files changed, 119 insertions, 3 deletions
diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro index efb2f52..8182394 100644 --- a/tests/auto/qlocalsocket/lackey/lackey.pro +++ b/tests/auto/qlocalsocket/lackey/lackey.pro @@ -1,4 +1,4 @@ -include(../src/src.pri) +#include(../src/src.pri) QT = core script network diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 1180d4d..be39d00 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -87,6 +87,8 @@ private slots: void sendData_data(); void sendData(); + void readBufferOverflow(); + void fullPath(); void hitMaximumConnections_data(); @@ -102,13 +104,15 @@ private slots: void longPath(); void waitForDisconnect(); + void waitForDisconnectByServer(); void removeServer(); void recycleServer(); + void multiConnect(); + void writeOnlySocket(); void writeToClientAndDisconnect(); - void debug(); void bytesWrittenSignal(); @@ -151,7 +155,13 @@ public: LocalServer() : QLocalServer() { connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); - }; + } + + bool listen(const QString &name) + { + removeServer(name); + return QLocalServer::listen(name); + } QList<int> hits; @@ -553,6 +563,40 @@ void tst_QLocalSocket::sendData() QCOMPARE(spy.count(), (canListen ? 1 : 0)); } +void tst_QLocalSocket::readBufferOverflow() +{ + const int readBufferSize = 128; + const int dataBufferSize = readBufferSize * 2; + const QString serverName = QLatin1String("myPreciousTestServer"); + LocalServer server; + server.listen(serverName); + QVERIFY(server.isListening()); + + LocalSocket client; + client.setReadBufferSize(readBufferSize); + client.connectToServer(serverName); + + bool timedOut = true; + QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(!timedOut); + + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QVERIFY(server.hasPendingConnections()); + + QLocalSocket* serverSocket = server.nextPendingConnection(); + char buffer[dataBufferSize]; + memset(buffer, 0, dataBufferSize); + serverSocket->write(buffer, dataBufferSize); + serverSocket->flush(); + + QVERIFY(client.waitForReadyRead()); + QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); +#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN) + QTest::qWait(250); +#endif + QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); +} + // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { @@ -833,6 +877,25 @@ void tst_QLocalSocket::waitForDisconnect() QVERIFY(timer.elapsed() < 2000); } +void tst_QLocalSocket::waitForDisconnectByServer() +{ + QString name = "tst_localsocket"; + LocalServer server; + QVERIFY(server.listen(name)); + LocalSocket socket; + QSignalSpy spy(&socket, SIGNAL(disconnected())); + QVERIFY(spy.isValid()); + socket.connectToServer(name); + QVERIFY(socket.waitForConnected(3000)); + QVERIFY(server.waitForNewConnection(3000)); + QLocalSocket *serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + serverSocket->close(); + QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState); + QVERIFY(socket.waitForDisconnected(3000)); + QCOMPARE(spy.count(), 1); +} + void tst_QLocalSocket::removeServer() { // this is a hostile takeover, but recovering from a crash results in the same @@ -874,6 +937,53 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } +void tst_QLocalSocket::multiConnect() +{ + QLocalServer server; + QLocalSocket client1; + QLocalSocket client2; + QLocalSocket client3; + + QVERIFY(server.listen("multiconnect")); + + client1.connectToServer("multiconnect"); + client2.connectToServer("multiconnect"); + client3.connectToServer("multiconnect"); + + QVERIFY(client1.waitForConnected(201)); + QVERIFY(client2.waitForConnected(202)); + QVERIFY(client3.waitForConnected(203)); + + QVERIFY(server.waitForNewConnection(201)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(202)); + QVERIFY(server.nextPendingConnection() != 0); + QVERIFY(server.waitForNewConnection(203)); + QVERIFY(server.nextPendingConnection() != 0); +} + +void tst_QLocalSocket::writeOnlySocket() +{ + QLocalServer server; +#ifdef Q_OS_SYMBIAN + unlink("writeOnlySocket"); +#endif + QVERIFY(server.listen("writeOnlySocket")); + + QLocalSocket client; + client.connectToServer("writeOnlySocket", QIODevice::WriteOnly); + QVERIFY(client.waitForConnected()); +#if defined(Q_OS_SYMBIAN) + QTest::qWait(250); +#endif + QVERIFY(server.waitForNewConnection()); + QLocalSocket* serverSocket = server.nextPendingConnection(); + QVERIFY(serverSocket); + + QCOMPARE(client.bytesAvailable(), qint64(0)); + QCOMPARE(client.state(), QLocalSocket::ConnectedState); +} + void tst_QLocalSocket::writeToClientAndDisconnect() { #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 86a04d0..cc5104a 100644 --- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -259,6 +259,9 @@ void tst_QNetworkDiskCache::data_data() // public QIODevice* data(QUrl const& url) void tst_QNetworkDiskCache::data() { +#ifdef Q_OS_SYMBIAN + QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll); +#endif QFETCH(QNetworkCacheMetaData, data); SubQNetworkDiskCache cache; QUrl url(EXAMPLE_URL); @@ -335,6 +338,9 @@ void tst_QNetworkDiskCache::setCacheDirectory() // public void updateMetaData(QNetworkCacheMetaData const& metaData) void tst_QNetworkDiskCache::updateMetaData() { +#ifdef Q_OS_SYMBIAN + QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll); +#endif QUrl url(EXAMPLE_URL); SubQNetworkDiskCache cache; cache.setupWithOne(url); |