From 6a0cfc0c6e8ca91414dfe8dd378b65aad099cbc9 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 27 Jan 2021 14:06:19 +0100 Subject: [PATCH] QmlDesigner: Fix flacky test ImageCacheGenerator.WaitForFinished Change-Id: I7c08ec68d20a54e125805ad98f87879c99b1aad3 Reviewed-by: Thomas Hartmann --- tests/unit/unittest/imagecachegenerator-test.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/unittest/imagecachegenerator-test.cpp b/tests/unit/unittest/imagecachegenerator-test.cpp index bcc4a5f47ad..898b3d90579 100644 --- a/tests/unit/unittest/imagecachegenerator-test.cpp +++ b/tests/unit/unittest/imagecachegenerator-test.cpp @@ -272,10 +272,16 @@ TEST_F(ImageCacheGenerator, CleanIsCallingAbortCallback) TEST_F(ImageCacheGenerator, WaitForFinished) { - ON_CALL(collectorMock, start(_, _, _, _, _)) + ON_CALL(collectorMock, start(Eq("name"), _, _, _, _)) + .WillByDefault([&](auto, auto, auto, auto captureCallback, auto) { + waitInThread.wait(); + captureCallback(QImage{image1}, QImage{smallImage1}); + }); + ON_CALL(collectorMock, start(Eq("name2"), _, _, _, _)) .WillByDefault([&](auto, auto, auto, auto captureCallback, auto) { captureCallback(QImage{image1}, QImage{smallImage1}); }); + generator.generateImage( "name", {}, {11}, imageCallbackMock.AsStdFunction(), abortCallbackMock.AsStdFunction(), {}); generator.generateImage( @@ -283,6 +289,7 @@ TEST_F(ImageCacheGenerator, WaitForFinished) EXPECT_CALL(imageCallbackMock, Call(_, _)).Times(2); + waitInThread.notify(); generator.waitForFinished(); }