From cfe198948f1e4867918176df38b3e0b49757a4b8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 30 Sep 2010 17:49:19 +0200 Subject: QDeclarativeDebug: Make autotests more robust Always flush sockets after sending data, and make autotests more robust by using busy wait. Reviewed-by: Christiaan Janssen --- src/declarative/debugger/qdeclarativedebugclient.cpp | 3 +++ src/declarative/debugger/qdeclarativedebugservice.cpp | 1 + .../tst_qdeclarativedebugclient.cpp | 9 ++++----- .../tst_qdeclarativedebugservice.cpp | 14 ++++++-------- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp index 5baaf70..977e58e 100644 --- a/src/declarative/debugger/qdeclarativedebugclient.cpp +++ b/src/declarative/debugger/qdeclarativedebugclient.cpp @@ -99,6 +99,7 @@ void QDeclarativeDebugConnectionPrivate::advertisePlugins() QPacket pack; pack << serverId << 1 << plugins.keys(); protocol->send(pack); + q->flush(); } void QDeclarativeDebugConnectionPrivate::connected() @@ -106,6 +107,7 @@ void QDeclarativeDebugConnectionPrivate::connected() QPacket pack; pack << serverId << 0 << protocolVersion << plugins.keys(); protocol->send(pack); + q->flush(); } void QDeclarativeDebugConnectionPrivate::readyRead() @@ -274,6 +276,7 @@ void QDeclarativeDebugClient::sendMessage(const QByteArray &message) QPacket pack; pack << d->name << message; d->client->d->protocol->send(pack); + d->client->d->q->flush(); } void QDeclarativeDebugClient::statusChanged(Status) diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp index 62f2f39..d2ef00d 100644 --- a/src/declarative/debugger/qdeclarativedebugservice.cpp +++ b/src/declarative/debugger/qdeclarativedebugservice.cpp @@ -142,6 +142,7 @@ void QDeclarativeDebugServerPrivate::advertisePlugins() QPacket pack; pack << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << plugins.keys(); protocol->send(pack); + connection->flush(); } void QDeclarativeDebugServer::listen() diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index a5f9846..80241ba 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -112,12 +112,10 @@ void tst_QDeclarativeDebugClient::status() { QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::status()"); - QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())); - QCOMPARE(client.status(), QDeclarativeDebugClient::Enabled); + QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled); } - QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())); - QCOMPARE(client.status(), QDeclarativeDebugClient::Unavailable); + QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Unavailable); // duplicate plugin name QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugClient: Conflicting plugin name \"tst_QDeclarativeDebugClient::status()\" "); @@ -135,7 +133,8 @@ void tst_QDeclarativeDebugClient::sendMessage() QByteArray msg = "hello!"; - QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())); + QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled); + client.sendMessage(msg); QByteArray resp = client.waitForResponse(); QCOMPARE(resp, msg); diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index bce4713..538129c 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -103,12 +103,12 @@ void tst_QDeclarativeDebugService::status() { QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::status()", m_conn); - QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(statusHasChanged())); - QCOMPARE(service.status(), QDeclarativeDebugService::Enabled); + QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled); + QTRY_COMPARE(service.status(), QDeclarativeDebugService::Enabled); } - QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(statusHasChanged())); - QCOMPARE(service.status(), QDeclarativeDebugService::Unavailable); + + QTRY_COMPARE(service.status(), QDeclarativeDebugService::Unavailable); QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::status()\" "); @@ -123,10 +123,8 @@ void tst_QDeclarativeDebugService::sendMessage() QByteArray msg = "hello!"; - if (service.status() != QDeclarativeDebugService::Enabled) - QDeclarativeDebugTest::waitForSignal(&service, SIGNAL(statusHasChanged())); - if (client.status() != QDeclarativeDebugClient::Enabled) - QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged())); + QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled); + QTRY_COMPARE(service.status(), QDeclarativeDebugService::Enabled); client.sendMessage(msg); QByteArray resp = client.waitForResponse(); -- cgit v0.12