QmlDesigner: AsynchronousImageFactory generates if the image is null

If the image is update but null we still generate a new image. This
is a ugly workaround for the flaky generation process. Hopefully
we can fix it after all hidden dependencies are removed.

Change-Id: I0e344002a1952fb849393d3e245e31612c69d7bd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2022-01-06 17:06:23 +01:00
committed by Thomas Hartmann
parent d987d305ef
commit 3cf01fbf07
2 changed files with 43 additions and 18 deletions

View File

@@ -38,6 +38,13 @@ using QmlDesigner::ImageCache::FontCollectorSizesAuxiliaryData;
class AsynchronousImageFactory : public testing::Test
{
protected:
AsynchronousImageFactory()
{
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{123}));
}
protected:
Notification notification;
Notification waitInThread;
@@ -51,9 +58,6 @@ protected:
TEST_F(AsynchronousImageFactory, RequestImageRequestImageFromGenerator)
{
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{123}));
EXPECT_CALL(mockGenerator,
generateImage(Eq("/path/to/Component.qml"),
IsEmpty(),
@@ -69,9 +73,6 @@ TEST_F(AsynchronousImageFactory, RequestImageRequestImageFromGenerator)
TEST_F(AsynchronousImageFactory, RequestImageWithExtraIdRequestImageFromGenerator)
{
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{123}));
EXPECT_CALL(mockGenerator,
generateImage(Eq("/path/to/Component.qml"),
Eq("foo"),
@@ -88,8 +89,6 @@ TEST_F(AsynchronousImageFactory, RequestImageWithExtraIdRequestImageFromGenerato
TEST_F(AsynchronousImageFactory, RequestImageWithAuxiliaryDataRequestImageFromGenerator)
{
std::vector<QSize> sizes{{20, 11}};
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{123}));
EXPECT_CALL(mockGenerator,
generateImage(Eq("/path/to/Component.qml"),
@@ -114,6 +113,10 @@ TEST_F(AsynchronousImageFactory, RequestImageWithAuxiliaryDataRequestImageFromGe
TEST_F(AsynchronousImageFactory, DontRequestImageRequestImageFromGeneratorIfFileWasNotUpdated)
{
ON_CALL(mockStorage, fetchHasImage(Eq("/path/to/Component.qml"))).WillByDefault([&](auto) {
notification.notify();
return true;
});
ON_CALL(mockStorage, fetchModifiedImageTime(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{124}));
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
@@ -122,6 +125,29 @@ TEST_F(AsynchronousImageFactory, DontRequestImageRequestImageFromGeneratorIfFile
EXPECT_CALL(mockGenerator, generateImage(_, _, _, _, _, _)).Times(0);
factory.generate("/path/to/Component.qml");
notification.wait();
}
TEST_F(AsynchronousImageFactory,
RequestImageRequestImageFromGeneratorIfFileWasNotUpdatedButTheImageIsNull)
{
ON_CALL(mockStorage, fetchHasImage(Eq("/path/to/Component.qml"))).WillByDefault(Return(false));
ON_CALL(mockStorage, fetchModifiedImageTime(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{124}));
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{124}));
EXPECT_CALL(mockGenerator,
generateImage(Eq("/path/to/Component.qml"),
IsEmpty(),
Eq(Sqlite::TimeStamp{124}),
_,
_,
VariantWith<Utils::monostate>(Utils::monostate{})))
.WillRepeatedly([&](auto, auto, auto, auto, auto, auto) { notification.notify(); });
factory.generate("/path/to/Component.qml");
notification.wait();
}
TEST_F(AsynchronousImageFactory, CleanRemovesEntries)
@@ -147,8 +173,6 @@ TEST_F(AsynchronousImageFactory, CleanCallsGeneratorClean)
TEST_F(AsynchronousImageFactory, AfterCleanNewJobsWorks)
{
factory.clean();
ON_CALL(mockTimeStampProvider, timeStamp(Eq("/path/to/Component.qml")))
.WillByDefault(Return(Sqlite::TimeStamp{123}));
EXPECT_CALL(mockGenerator,
generateImage(Eq("/path/to/Component.qml"),