diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-06-16 11:21:01 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2014-06-19 18:32:29 +0200 |
commit | fdedb07d73c3bf8e816fc0bb99497576bb3f89f9 (patch) | |
tree | 513aaa19e98ced19bed0eb6efe443158c1bef492 /tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp | |
parent | 3bc827feb38f0d90f6c2254eb0816504b8e1c2cb (diff) |
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 <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp')
-rw-r--r-- | tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp | 9 |
1 files 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(); } |