tests/auto/qtcpsocket/tst_qtcpsocket.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 4 3b1da2848fc7
child 13 c0432d11811c
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -92,6 +92,8 @@
 #include <unistd.h>
 #endif
 
+#include "private/qhostinfo_p.h"
+
 #include "../network-settings.h"
 
 Q_DECLARE_METATYPE(QAbstractSocket::SocketError)
@@ -315,6 +317,8 @@
         }
         QNetworkProxy::setApplicationProxy(proxy);
     }
+
+    qt_qhostinfo_clear_cache();
 }
 
 QTcpSocket *tst_QTcpSocket::newSocket() const
@@ -1059,7 +1063,9 @@
     // just connect and disconnect, then make sure nothing weird happened
     QTcpSocket *socket = newSocket();
     socket->connectToHost(QtNetworkSettings::serverName(), 21);
-    QVERIFY(socket->state() == QAbstractSocket::HostLookupState);
+
+    // check that connect is in progress
+    QVERIFY(socket->state() != QAbstractSocket::UnconnectedState);
 
     QFETCH(bool, doClose);
     if (doClose) {
@@ -1665,7 +1671,10 @@
     connect(tmpSocket, SIGNAL(hostFound()), this, SLOT(hostLookupSlot()));
     tmpSocket->connectToHost(QtNetworkSettings::serverName(), 143);
 
-    loop.exec();
+    // only execute the loop if not already connected
+    if (tmpSocket->state() != QAbstractSocket::ConnectedState)
+        loop.exec();
+
     QCOMPARE(timerSpy.count(), 0);
 
     delete tmpSocket;