QmlDesigner: Check if callback is not null

The AsynchronousImageFactory is not interested in any callback. So it
is providing null callbacks. If they are called there will be a crash.

Change-Id: I252301e4289185e50720849a7cb148d8f1da3e7d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2022-01-04 17:17:12 +01:00
parent 70a9b3deae
commit 3e585483c9
2 changed files with 40 additions and 2 deletions

View File

@@ -485,4 +485,40 @@ TEST_F(ImageCacheGenerator, MergeAbortCallbackIfTasksAreMerged)
notification.wait();
}
TEST_F(ImageCacheGenerator, DontCallNullImageCallback)
{
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
.WillOnce([&](auto, auto, auto, auto captureCallback, auto) {
captureCallback(image1, smallImage1);
notification.notify();
});
generator.generateImage("name", {}, {}, {}, {}, {});
notification.wait();
}
TEST_F(ImageCacheGenerator, DontCallNullAbortCallbackForNullImage)
{
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
.WillOnce([&](auto, auto, auto, auto captureCallback, auto) {
captureCallback(QImage{}, QImage{});
notification.notify();
});
generator.generateImage("name", {}, {}, {}, {}, {});
notification.wait();
}
TEST_F(ImageCacheGenerator, DontCallNullAbortCallback)
{
EXPECT_CALL(collectorMock, start(_, _, _, _, _))
.WillOnce([&](auto, auto, auto, auto, auto abortCallback) {
abortCallback(QmlDesigner::ImageCache::AbortReason::Failed);
notification.notify();
});
generator.generateImage("name", {}, {}, {}, {}, {});
notification.wait();
}
} // namespace