diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-20 16:23:47 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-07-20 15:19:58 +0000 |
commit | cf73b53fb97ecf40c2cf391b7af150444ce4c097 (patch) | |
tree | 889499ac385f27242c303dc494c469e711eedd88 /tests/auto/qml/debugger | |
parent | 659d80886e32253d230e5a5b407b21aa83654700 (diff) |
Avoid potential race condition in qqmldebugjs test
The stopped() signal could arrive while we are waiting for the result()
signal.
Change-Id: I6dcc66aaf0b05221d7ad78572c483a506366e2bb
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/debugger')
-rw-r--r-- | tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index 065dddefed..c090be2633 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -1171,6 +1171,14 @@ void tst_QQmlDebugJS::changeBreakpoint() int sourceLine1 = 38; QCOMPARE(init(qmlscene, CHANGEBREAKPOINT_QMLFILE), ConnectSuccess); + bool isStopped = false; + QObject::connect(m_client, &QJSDebugClient::stopped, this, [&]() { isStopped = true; }); + + auto continueDebugging = [&]() { + m_client->continueDebugging(QJSDebugClient::Continue); + isStopped = false; + }; + m_client->connect(); auto extractBody = [&]() { @@ -1210,7 +1218,7 @@ void tst_QQmlDebugJS::changeBreakpoint() QVERIFY(breakpoint2 >= 0); auto verifyBreakpoint = [&](int sourceLine, int breakpointId) { - QVERIFY(waitForClientSignal(SIGNAL(stopped()))); + QTRY_VERIFY_WITH_TIMEOUT(isStopped, 30000); const QVariantMap body = extractBody(); QCOMPARE(body.value("sourceLine").toInt(), sourceLine); QCOMPARE(extractBreakPointId(body), breakpointId); @@ -1218,7 +1226,7 @@ void tst_QQmlDebugJS::changeBreakpoint() verifyBreakpoint(sourceLine2, breakpoint2); - m_client->continueDebugging(QJSDebugClient::Continue); + continueDebugging(); verifyBreakpoint(sourceLine2, breakpoint2); m_client->changeBreakpoint(breakpoint2, false); @@ -1227,10 +1235,10 @@ void tst_QQmlDebugJS::changeBreakpoint() m_client->changeBreakpoint(breakpoint1, true); QVERIFY(waitForClientSignal(SIGNAL(result()))); - m_client->continueDebugging(QJSDebugClient::Continue); + continueDebugging(); verifyBreakpoint(sourceLine1, breakpoint1); - m_client->continueDebugging(QJSDebugClient::Continue); + continueDebugging(); verifyBreakpoint(sourceLine1, breakpoint1); m_client->changeBreakpoint(breakpoint2, true); @@ -1240,7 +1248,7 @@ void tst_QQmlDebugJS::changeBreakpoint() QVERIFY(waitForClientSignal(SIGNAL(result()))); for (int i = 0; i < 3; ++i) { - m_client->continueDebugging(QJSDebugClient::Continue); + continueDebugging(); verifyBreakpoint(sourceLine2, breakpoint2); } } |