Fix flaky QQmlProfilerService::scenegraphData test
authorKai Koehne <kai.koehne@digia.com>
Thu, 17 Oct 2013 07:24:09 +0000 (09:24 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 17 Oct 2013 10:53:26 +0000 (12:53 +0200)
QSGRenderThread::syncAndRender first triggers the frameSwapped() signal,
and only then adds the SceneGraphRenderLoopFrame message. We're waiting
for the frameSwapped signal to stop profiling, and therefore can't be sure
whether we'll get the final SceneGraphRenderLoopFrame message or not.

Task-number: QTBUG-33024
Change-Id: I3216667e8e5cdc79f210290ce22cc6b08c579b6a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp

index b9aefb3..902e525 100644 (file)
@@ -459,22 +459,21 @@ void tst_QQmlProfilerService::scenegraphData()
 
     // check that at least one frame was rendered
     // there should be a SGPolishAndSync + SGRendererFrame + SGRenderLoopFrame sequence
+    // (though we can't be sure to get the SGRenderLoopFrame in the threaded renderer)
+    //
     // since the rendering happens in a different thread, there could be other unrelated events interleaved
     int loopcheck = 0;
     foreach (const QQmlProfilerData &msg, m_client->traceMessages) {
         if (msg.messageType == QQmlProfilerClient::SceneGraphFrame) {
             if (loopcheck == 0 && msg.detailType == QQmlProfilerClient::SceneGraphContextFrame)
                 loopcheck = 1;
-            else
-            if (loopcheck == 1 && msg.detailType == QQmlProfilerClient::SceneGraphRendererFrame)
+            else if (loopcheck == 1 && msg.detailType == QQmlProfilerClient::SceneGraphRendererFrame)
                 loopcheck = 2;
-            else
-            if (loopcheck == 2 && msg.detailType == QQmlProfilerClient::SceneGraphRenderLoopFrame)
+            else if (loopcheck == 2 && msg.detailType == QQmlProfilerClient::SceneGraphRenderLoopFrame)
                loopcheck = 3;
         }
     }
-
-    QCOMPARE(loopcheck, 3);
+    QVERIFY(loopcheck >= 2);
 }
 
 void tst_QQmlProfilerService::profileOnExit()