summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-12-08 15:04:45 +0000
committerQt by Nokia <qt-info@nokia.com>2011-12-09 12:25:14 +0100
commit2c4879a7676d6a75379ac6ff24ac4c2a6c2b9658 (patch)
tree764d94e5aff4723d637832e21b5e962ec7fc3062
parent002cb5d2c884793da85b8389a8283f3036438119 (diff)
Remove QtWidgets dependency from QTcpSocket autotest
QMessageBox was being used to test nested event loops. This has been changed to use QEventLoop directly. Also, there was an unnecessary use of QPushButton to trigger a test case, which has been removed. As a result, 3 test cases can be run on VXWORKS, and one more test case on Windows that were previously skipped. Change-Id: Ic65ed441cd37d242f89df3ef3b8638a1458d9cf3 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
-rw-r--r--tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro2
-rw-r--r--tests/auto/network/socket/qtcpsocket/test/test.pro5
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp38
3 files changed, 12 insertions, 33 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro b/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro
index c7a4308b17..2eb00593e0 100644
--- a/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro
+++ b/tests/auto/network/socket/qtcpsocket/stressTest/stressTest.pro
@@ -1,6 +1,6 @@
HEADERS += Test.h
SOURCES += main.cpp Test.cpp
-QT += network
+QT = core network testlib
CONFIG -= app_bundle
CONFIG += console
diff --git a/tests/auto/network/socket/qtcpsocket/test/test.pro b/tests/auto/network/socket/qtcpsocket/test/test.pro
index 897a875013..6c6697bfdc 100644
--- a/tests/auto/network/socket/qtcpsocket/test/test.pro
+++ b/tests/auto/network/socket/qtcpsocket/test/test.pro
@@ -1,7 +1,6 @@
CONFIG += testcase
-QT += widgets testlib
-QT += core-private network-private
+QT = core-private network-private testlib
SOURCES += ../tst_qtcpsocket.cpp
win32: {
wince*: {
@@ -10,8 +9,6 @@ wince*: {
LIBS += -lws2_32
}
}
-QT += network
-vxworks:QT -= gui
TARGET = tst_qtcpsocket
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 09bf8c98be..218e372e4d 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -63,10 +63,6 @@
#include <QHostAddress>
#include <QHostInfo>
#include <QMap>
-#ifndef Q_OS_VXWORKS
-#include <QMessageBox>
-#include <QPushButton>
-#endif
#include <QPointer>
#include <QProcess>
#include <QStringList>
@@ -175,7 +171,7 @@ private slots:
void socketsInThreads();
void waitForReadyReadInASlot();
void remoteCloseError();
- void openMessageBoxInErrorSlot();
+ void nestedEventLoopInErrorSlot();
#ifndef Q_OS_WIN
void connectToLocalHostNoService();
#endif
@@ -217,7 +213,7 @@ protected slots:
void downloadBigFileSlot();
void recursiveReadyReadSlot();
void waitForReadyReadInASlotSlot();
- void messageBoxSlot();
+ void enterLoopSlot();
void hostLookupSlot();
void abortiveClose_abortSlot();
void remoteCloseErrorSlot();
@@ -1829,35 +1825,29 @@ void tst_QTcpSocket::remoteCloseErrorSlot()
static_cast<QTcpSocket *>(sender())->close();
}
-void tst_QTcpSocket::messageBoxSlot()
+void tst_QTcpSocket::enterLoopSlot()
{
-#if !defined(Q_OS_VXWORKS) // no gui
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
socket->deleteLater();
- QMessageBox box;
- QTimer::singleShot(100, &box, SLOT(close()));
- // This should not delete the socket
- box.exec();
+ // enter nested event loop
+ QEventLoop loop;
+ QTimer::singleShot(100, &loop, SLOT(quit()));
+ loop.exec();
// Fire a non-0 singleshot to leave time for the delete
QTimer::singleShot(250, this, SLOT(exitLoopSlot()));
-#endif
}
//----------------------------------------------------------------------------------
-void tst_QTcpSocket::openMessageBoxInErrorSlot()
+void tst_QTcpSocket::nestedEventLoopInErrorSlot()
{
-#if defined(Q_OS_VXWORKS) // no gui
- QSKIP("no default gui available on VxWorks");
-#else
QTcpSocket *socket = newSocket();
QPointer<QTcpSocket> p(socket);
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(messageBoxSlot()));
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(enterLoopSlot()));
socket->connectToHost("hostnotfoundhostnotfound.troll.no", 9999); // Host not found, fyi
enterLoop(30);
QVERIFY(!p);
-#endif
}
//----------------------------------------------------------------------------------
@@ -1981,16 +1971,9 @@ public slots:
//----------------------------------------------------------------------------------
void tst_QTcpSocket::waitForConnectedInHostLookupSlot2()
{
-#if defined(Q_OS_WIN) || defined(Q_OS_VXWORKS)
- QSKIP("waitForConnectedInHostLookupSlot2 is not run on Windows and VxWorks");
-#else
-
Foo foo;
- QPushButton top("Go", 0);
- top.show();
- connect(&top, SIGNAL(clicked()), &foo, SLOT(doIt()));
- QTimer::singleShot(100, &top, SLOT(animateClick()));
+ QTimer::singleShot(100, &foo, SLOT(doIt()));
QTimer::singleShot(5000, &foo, SLOT(exitLoop()));
enterLoop(30);
@@ -1999,7 +1982,6 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot2()
QVERIFY(foo.attemptedToConnect);
QCOMPARE(foo.count, 1);
-#endif
}
//----------------------------------------------------------------------------------