From fdedb07d73c3bf8e816fc0bb99497576bb3f89f9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 16 Jun 2014 11:21:01 +0200 Subject: Use QSignalSpy instead of waitFor in tst_qpacketprotocol QTcpServer::waitForNewConnection() blocks the event loop and prevents the client, that runs in the same event loop, from sending anything. Also, if the connection is established before waitForNewConnection() is called we're going to wait for another connection, which will never happen. It's not clear if this is actually the cause of the test failures but blocking the event loop is generally a bad idea and the last change to the test that actually made a difference to the functionality added exactly that line, see b36bbe3626bc68ac267d7653fa6408a8f258251d. Task-number: QTBUG-39655 Change-Id: Ic03a4e7cac78155532588476b99449664c343ee2 Reviewed-by: Simon Hausmann --- tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp index 26919af1b6..f91d0135a9 100644 --- a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp @@ -84,10 +84,15 @@ void tst_QPacketProtocol::init() QVERIFY(m_server->listen(QHostAddress("127.0.0.1"))); m_client = new QTcpSocket(this); + + QSignalSpy serverSpy(m_server, SIGNAL(newConnection())); + QSignalSpy clientSpy(m_client, SIGNAL(connected())); + m_client->connectToHost(m_server->serverAddress(), m_server->serverPort()); - QVERIFY(m_client->waitForConnected()); - QVERIFY(m_server->waitForNewConnection(10000)); + QVERIFY(clientSpy.count() > 0 || clientSpy.wait()); + QVERIFY(serverSpy.count() > 0 || serverSpy.wait()); + m_serverConn = m_server->nextPendingConnection(); } -- cgit v1.2.3