From 76bd140c7c98d0db152db5104d3e38dbb33f7267 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 14 Apr 2021 12:50:21 +0200 Subject: [PATCH] UnitTests: Fix flaky test ImageCacheGenerator.CleanIsCallingAbortCallback was not waiting for the expected call. Task-number: QTCREATORBUG-25580 Change-Id: I43265389a36e568dea7c7ece5524ef597232d049 Reviewed-by: Christian Stenger --- tests/unit/unittest/imagecachegenerator-test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unit/unittest/imagecachegenerator-test.cpp b/tests/unit/unittest/imagecachegenerator-test.cpp index dd8bd4297da..2bd1fdf06a7 100644 --- a/tests/unit/unittest/imagecachegenerator-test.cpp +++ b/tests/unit/unittest/imagecachegenerator-test.cpp @@ -277,21 +277,21 @@ TEST_F(ImageCacheGenerator, CallWalCheckpointFullIfQueueIsEmpty) TEST_F(ImageCacheGenerator, CleanIsCallingAbortCallback) { - ON_CALL(collectorMock, start(_, _, _, _, _)) - .WillByDefault([&](auto, auto, auto, auto captureCallback, auto) { - captureCallback({}, {}); - waitInThread.wait(); - }); + ON_CALL(collectorMock, start(_, _, _, _, _)).WillByDefault([&](auto, auto, auto, auto, auto) { + notification.wait(); + }); generator.generateImage( "name", {}, {11}, imageCallbackMock.AsStdFunction(), abortCallbackMock.AsStdFunction(), {}); generator.generateImage( "name2", {}, {11}, imageCallbackMock.AsStdFunction(), abortCallbackMock.AsStdFunction(), {}); EXPECT_CALL(abortCallbackMock, Call(Eq(QmlDesigner::ImageCache::AbortReason::Abort))) - .Times(AtLeast(1)); + .Times(AtLeast(1)) + .WillRepeatedly([&](auto) { waitInThread.notify(); }); generator.clean(); - waitInThread.notify(); + notification.notify(); + waitInThread.wait(); } TEST_F(ImageCacheGenerator, WaitForFinished)