summaryrefslogtreecommitdiffstats
path: root/tests/auto/network
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network')
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp38
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp4
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp6
3 files changed, 45 insertions, 3 deletions
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index 44edcc66c0..4740b92b84 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -62,6 +62,7 @@ public slots:
void cleanupTestCase();
void init();
void cleanup();
+ void accessAfterRemoveReadyReadSlot();
private slots:
void qnetworkdiskcache_data();
@@ -74,6 +75,7 @@ private slots:
void data();
void metaData();
void remove();
+ void accessAfterRemove(); // QTBUG-17400
void setCacheDirectory_data();
void setCacheDirectory();
void updateMetaData();
@@ -89,6 +91,8 @@ private slots:
private:
QTemporaryDir tempDir;
+ QUrl url; // used by accessAfterRemove()
+ QNetworkDiskCache *diskCache; // used by accessAfterRemove()
};
// FIXME same as in tst_qnetworkreply.cpp .. could be unified
@@ -370,6 +374,40 @@ void tst_QNetworkDiskCache::remove()
QCOMPARE(countFiles(cacheDirectory).count(), NUM_SUBDIRECTORIES + 2);
}
+void tst_QNetworkDiskCache::accessAfterRemove() // QTBUG-17400
+{
+ QByteArray data("HTTP/1.1 200 OK\r\n"
+ "Content-Length: 1\r\n"
+ "\r\n"
+ "a");
+
+ MiniHttpServer server(data);
+
+ QNetworkAccessManager *manager = new QNetworkAccessManager();
+ SubQNetworkDiskCache subCache;
+ subCache.setCacheDirectory(QLatin1String("cacheDir"));
+ diskCache = &subCache;
+ manager->setCache(&subCache);
+
+ url = QUrl("http://127.0.0.1:" + QString::number(server.serverPort()));
+ QNetworkRequest request(url);
+
+ QNetworkReply *reply = manager->get(request);
+ connect(reply, SIGNAL(readyRead()), this, SLOT(accessAfterRemoveReadyReadSlot()));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ reply->deleteLater();
+ manager->deleteLater();
+}
+
+void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot()
+{
+ diskCache->remove(url); // this used to cause a crash later on
+}
+
void tst_QNetworkDiskCache::setCacheDirectory_data()
{
QTest::addColumn<QString>("cacheDir");
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index c4d42206fe..99f677643c 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -55,6 +55,10 @@
# endif
#endif
+#ifdef Q_OS_ANDROID
+# include <netinet/in.h>
+#endif
+
class tst_QHostAddress : public QObject
{
Q_OBJECT
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 122ac63034..8e69d827a6 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -1976,9 +1976,9 @@ public slots:
attemptedToConnect = true;
sock->connectToHost(QtNetworkSettings::serverName(), 80);
-#ifdef Q_OS_MAC
+#if defined(Q_OS_MAC)
pthread_yield_np();
-#elif defined Q_OS_LINUX
+#elif defined Q_OS_LINUX && !defined Q_OS_ANDROID
pthread_yield();
#endif
if (!sock->waitForConnected()) {
@@ -2485,7 +2485,7 @@ void tst_QTcpSocket::increaseReadBufferSizeFromSlot() // like KIO's socketconnec
QVERIFY2(passive->waitForBytesWritten(5000), "Network timeout");
// set the read buffer size to less than what was written,
- // and increase it from the slot, first to 384 then to 1024.
+ // and increase it from the slot, first to 384 then to 512.
active->setReadBufferSize(256);
enterLoop(10);
QVERIFY2(!timeout(), "Network timeout");