tests/auto/qtcpsocket/tst_qtcpsocket.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 14 c0432d11811c
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp	Mon May 03 13:17:34 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;