QmlDesigner: Use optional for ImageCache*

There are now matcher in google test for optional.

Change-Id: Ib3389fb0f537fd19a2930e7108483736bbba1628
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marco Bubke
2021-12-28 15:03:31 +01:00
parent 3816250f27
commit d479047275
13 changed files with 89 additions and 142 deletions

View File

@@ -54,7 +54,7 @@ TEST_F(AsynchronousImageCache, RequestImageFetchesImageFromStorage)
EXPECT_CALL(mockStorage, fetchImage(Eq("/path/to/Component.qml"), _))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestImage("/path/to/Component.qml",
@@ -70,7 +70,7 @@ TEST_F(AsynchronousImageCache, RequestImageFetchesImageFromStorageWithTimeStamp)
EXPECT_CALL(mockStorage, fetchImage(Eq("/path/to/Component.qml"), Eq(Sqlite::TimeStamp{123})))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestImage("/path/to/Component.qml",
@@ -82,7 +82,7 @@ TEST_F(AsynchronousImageCache, RequestImageFetchesImageFromStorageWithTimeStamp)
TEST_F(AsynchronousImageCache, RequestImageCallsCaptureCallbackWithImageFromStorage)
{
ON_CALL(mockStorage, fetchImage(Eq("/path/to/Component.qml"), _))
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{image1, true}));
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{image1}));
EXPECT_CALL(mockCaptureCallback, Call(Eq(image1))).WillRepeatedly([&](const QImage &) {
notification.notify();
@@ -97,7 +97,7 @@ TEST_F(AsynchronousImageCache, RequestImageCallsCaptureCallbackWithImageFromStor
TEST_F(AsynchronousImageCache, RequestImageCallsAbortCallbackWithoutImage)
{
ON_CALL(mockStorage, fetchImage(Eq("/path/to/Component.qml"), _))
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}, true}));
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}}));
EXPECT_CALL(mockAbortCallback, Call(Eq(QmlDesigner::ImageCache::AbortReason::Failed)))
.WillRepeatedly([&](auto) { notification.notify(); });
@@ -160,7 +160,7 @@ TEST_F(AsynchronousImageCache, RequestSmallImageFetchesSmallImageFromStorage)
EXPECT_CALL(mockStorage, fetchSmallImage(Eq("/path/to/Component.qml"), _))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestSmallImage("/path/to/Component.qml",
@@ -176,7 +176,7 @@ TEST_F(AsynchronousImageCache, RequestSmallImageFetchesSmallImageFromStorageWith
EXPECT_CALL(mockStorage, fetchSmallImage(Eq("/path/to/Component.qml"), Eq(Sqlite::TimeStamp{123})))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestSmallImage("/path/to/Component.qml",
@@ -188,7 +188,7 @@ TEST_F(AsynchronousImageCache, RequestSmallImageFetchesSmallImageFromStorageWith
TEST_F(AsynchronousImageCache, RequestSmallImageCallsCaptureCallbackWithImageFromStorage)
{
ON_CALL(mockStorage, fetchSmallImage(Eq("/path/to/Component.qml"), _))
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{smallImage1, true}));
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{smallImage1}));
EXPECT_CALL(mockCaptureCallback, Call(Eq(smallImage1))).WillRepeatedly([&](const QImage &) {
notification.notify();
@@ -203,7 +203,7 @@ TEST_F(AsynchronousImageCache, RequestSmallImageCallsCaptureCallbackWithImageFro
TEST_F(AsynchronousImageCache, RequestSmallImageCallsAbortCallbackWithoutSmallImage)
{
ON_CALL(mockStorage, fetchSmallImage(Eq("/path/to/Component.qml"), _))
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}, true}));
.WillByDefault(Return(QmlDesigner::ImageCacheStorageInterface::ImageEntry{QImage{}}));
EXPECT_CALL(mockAbortCallback, Call(Eq(QmlDesigner::ImageCache::AbortReason::Failed)))
.WillRepeatedly([&](auto) { notification.notify(); });
@@ -329,7 +329,7 @@ TEST_F(AsynchronousImageCache, RequestImageWithExtraIdFetchesImageFromStorage)
EXPECT_CALL(mockStorage, fetchImage(Eq("/path/to/Component.qml+extraId1"), _))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestImage("/path/to/Component.qml",
@@ -344,7 +344,7 @@ TEST_F(AsynchronousImageCache, RequestSmallImageWithExtraIdFetchesImageFromStora
EXPECT_CALL(mockStorage, fetchSmallImage(Eq("/path/to/Component.qml+extraId1"), _))
.WillRepeatedly([&](Utils::SmallStringView, auto) {
notification.notify();
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{{}, false};
return QmlDesigner::ImageCacheStorageInterface::ImageEntry{};
});
cache.requestSmallImage("/path/to/Component.qml",