summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtcpsocket
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-03-02 09:39:54 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-03-02 10:16:05 (GMT)
commitdaace2df3eb80f1b62f38151f5cc3f3b355927e7 (patch)
tree434c8313e618a8caf9af28a35679aa516c80042b /tests/auto/qtcpsocket
parent5a028f794fe48dc7141acedbf0e896b488bb8cd5 (diff)
downloadQt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.zip
Qt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.tar.gz
Qt-daace2df3eb80f1b62f38151f5cc3f3b355927e7.tar.bz2
QAbstractSocket: Use new faster DNS function
Use qt_qhostinfo_lookup which avoids the event loop when the DNS result is already cached. Reviewed-by: Thiago
Diffstat (limited to 'tests/auto/qtcpsocket')
-rw-r--r--tests/auto/qtcpsocket/qtcpsocket.pro3
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp13
2 files changed, 14 insertions, 2 deletions
diff --git a/tests/auto/qtcpsocket/qtcpsocket.pro b/tests/auto/qtcpsocket/qtcpsocket.pro
index 4bbec23..3d4eba3 100644
--- a/tests/auto/qtcpsocket/qtcpsocket.pro
+++ b/tests/auto/qtcpsocket/qtcpsocket.pro
@@ -3,3 +3,6 @@ TEMPLATE = subdirs
!wince*: SUBDIRS = test stressTest
wince*|symbian*|vxworks* : SUBDIRS = test
+
+
+requires(contains(QT_CONFIG,private_tests))
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index e638e287..ef7ff83 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -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 @@ void tst_QTcpSocket::init()
}
QNetworkProxy::setApplicationProxy(proxy);
}
+
+ qt_qhostinfo_clear_cache();
}
QTcpSocket *tst_QTcpSocket::newSocket() const
@@ -1059,7 +1063,9 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
// 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 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot()
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;