forked from qt-creator/qt-creator
QmlDesigner: Compress generator tasks
A document change can generate new image request and if the are not in the database new task for the collector are generated. But if there are already tasks for an equal id they would generated twice. So the tasks are now merged. The auxilialry data is not merged because it is expected that it is not changing. Task-number: QDS-3388 Change-Id: Id1aceb564dd9dc7c5a1ea5ae4680d7ee36611cda Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -78,11 +78,11 @@ TEST_F(ImageCacheGenerator, CallsCollectorWithCaptureCallback)
|
||||
|
||||
TEST_F(ImageCacheGenerator, CallsCollectorOnlyIfNotProcessing)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
EXPECT_CALL(collectorMock, start(AnyOf(Eq("name"), Eq("name2")), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
|
||||
generator.generateImage("name", {}, {}, imageCallbackMock.AsStdFunction(), {}, {});
|
||||
generator.generateImage("name", {}, {}, imageCallbackMock.AsStdFunction(), {}, {});
|
||||
generator.generateImage("name2", {}, {}, imageCallbackMock.AsStdFunction(), {}, {});
|
||||
notification.wait(2);
|
||||
}
|
||||
|
||||
@@ -320,4 +320,134 @@ TEST_F(ImageCacheGenerator, CallsCollectorWithAuxiliaryData)
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, MergeTasks)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
EXPECT_CALL(collectorMock, start(Eq("notificationDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
|
||||
EXPECT_CALL(collectorMock, start(Eq("name"), _, _, _, _));
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
generator.generateImage("notificationDummy", {}, {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, DontMergeTasksWithDifferentId)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
|
||||
EXPECT_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
EXPECT_CALL(collectorMock, start(Eq("name2"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name2", {}, {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait(2);
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, MergeTasksWithSameExtraId)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
EXPECT_CALL(collectorMock, start(Eq("notificationDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
|
||||
EXPECT_CALL(collectorMock, start(Eq("name"), _, _, _, _));
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", "id1", {}, {}, {}, {});
|
||||
generator.generateImage("name", "id1", {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
generator.generateImage("notificationDummy", {}, {}, {}, {}, {});
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, DontMergeTasksWithDifferentExtraId)
|
||||
{
|
||||
EXPECT_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
|
||||
EXPECT_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
.Times(2)
|
||||
.WillRepeatedly([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", "id1", {}, {}, {}, {});
|
||||
generator.generateImage("name", "id2", {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait(2);
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, UseLastTimeStampIfTasksAreMerged)
|
||||
{
|
||||
ON_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
ON_CALL(collectorMock, start(Eq("notificationDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
ON_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto abortCallback) { abortCallback(); });
|
||||
|
||||
EXPECT_CALL(storageMock, storeImage(Eq("name"), _, _, _));
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {3}, {}, abortCallbackMock.AsStdFunction(), {});
|
||||
generator.generateImage("name", {}, {4}, {}, abortCallbackMock.AsStdFunction(), {});
|
||||
generator.generateImage("notificationDummy", {}, {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, MergeCaptureCallbackIfTasksAreMerged)
|
||||
{
|
||||
NiceMock<MockFunction<void(const QImage &, const QImage &)>> newerImageCallbackMock;
|
||||
ON_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
ON_CALL(collectorMock, start(Eq("notificationDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
ON_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto imageCallback, auto) {
|
||||
imageCallback(QImage{image1}, QImage{smallImage1});
|
||||
});
|
||||
|
||||
EXPECT_CALL(imageCallbackMock, Call(_, _));
|
||||
EXPECT_CALL(newerImageCallbackMock, Call(_, _));
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {}, imageCallbackMock.AsStdFunction(), {}, {});
|
||||
generator.generateImage("name", {}, {}, newerImageCallbackMock.AsStdFunction(), {}, {});
|
||||
generator.generateImage("notificationDummy", {}, {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
TEST_F(ImageCacheGenerator, MergeAbortCallbackIfTasksAreMerged)
|
||||
{
|
||||
NiceMock<MockFunction<void()>> newerAbortCallbackMock;
|
||||
ON_CALL(collectorMock, start(Eq("waitDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { waitInThread.wait(); });
|
||||
ON_CALL(collectorMock, start(Eq("notificationDummy"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto) { notification.notify(); });
|
||||
ON_CALL(collectorMock, start(Eq("name"), _, _, _, _))
|
||||
.WillByDefault([&](auto, auto, auto, auto, auto abortCallback) { abortCallback(); });
|
||||
|
||||
EXPECT_CALL(abortCallbackMock, Call());
|
||||
EXPECT_CALL(newerAbortCallbackMock, Call());
|
||||
|
||||
generator.generateImage("waitDummy", {}, {}, {}, {}, {});
|
||||
generator.generateImage("name", {}, {}, {}, abortCallbackMock.AsStdFunction(), {});
|
||||
generator.generateImage("name", {}, {}, {}, newerAbortCallbackMock.AsStdFunction(), {});
|
||||
generator.generateImage("notificationDummy", {}, {}, {}, {}, {});
|
||||
waitInThread.notify();
|
||||
notification.wait();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user