#include "components/favicon/core/large_icon_service_impl.h"
#include <memory>
#include <string>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/favicon/core/favicon_client.h"
#include "components/favicon/core/test/mock_favicon_service.h"
#include "components/favicon_base/fallback_icon_style.h"
#include "components/favicon_base/favicon_types.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/image_fetcher/core/mock_image_fetcher.h"
#include "components/image_fetcher/core/request_metadata.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "url/gurl.h"
namespace favicon {
namespace {
MockImageFetcher;
_;
Eq;
HasSubstr;
IsEmpty;
IsNull;
NiceMock;
Not;
Property;
Return;
SaveArg;
StartsWith;
const char kDummyPageUrl[] = …;
const char kDummyIconUrl[] = …;
const SkColor kTestColor = …;
ACTION_P(PostFetchReply, p0) { … }
ACTION_P2(PostFetchReplyWithMetadata, p0, p1) { … }
favicon_base::FaviconRawBitmapResult CreateTestBitmapResult(int w,
int h,
SkColor color) { … }
bool HasBackgroundColor(
const favicon_base::FallbackIconStyle& fallback_icon_style,
SkColor color) { … }
class LargeIconServiceTest : public testing::Test { … };
TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServer) { … }
TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithOriginalUrl) { … }
TEST_F(LargeIconServiceTest, ShouldTrimQueryParametersForGoogleServer) { … }
TEST_F(LargeIconServiceTest, ShouldNotQueryGoogleServerIfInvalidScheme) { … }
TEST_F(LargeIconServiceTest, ShouldNotQueryGoogleServerIfInvalidURL) { … }
TEST_F(LargeIconServiceTest, ShouldReportUnavailableIfFetchFromServerFails) { … }
TEST_F(LargeIconServiceTest, ShouldNotGetFromGoogleServerIfUnavailable) { … }
TEST_F(LargeIconServiceTest, ShouldNotGetFromGoogleServerIfCannotSet) { … }
class LargeIconServiceGetterTest : public LargeIconServiceTest,
public ::testing::WithParamInterface<bool> { … };
TEST_P(LargeIconServiceGetterTest,
ShouldReturnIconFromLocalCacheIfSameSizeAvailable) { … }
TEST_P(LargeIconServiceGetterTest,
ShouldReturnResizedIconFromLocalCacheIfLargerSizeAvailable) { … }
TEST_P(LargeIconServiceGetterTest,
ShouldReturnResizedIconFromServerIfCachedIconIsTooSmall) { … }
TEST_P(LargeIconServiceGetterTest,
ShouldReturnResizedIconFromServerIfNoIconInCache) { … }
TEST_P(LargeIconServiceGetterTest, CancelableTaskTrackerDestroyedEarly) { … }
TEST_P(LargeIconServiceGetterTest, SameSize) { … }
TEST_P(LargeIconServiceGetterTest, ScaleDown) { … }
TEST_P(LargeIconServiceGetterTest, ScaleUp) { … }
TEST_P(LargeIconServiceGetterTest, NoScale) { … }
TEST_P(LargeIconServiceGetterTest, FallbackSinceIconTooSmall) { … }
TEST_P(LargeIconServiceGetterTest, FallbackSinceIconNotSquare) { … }
TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissing) { … }
TEST_P(LargeIconServiceGetterTest, FallbackSinceIconMissingNoScale) { … }
TEST_P(LargeIconServiceGetterTest, FallbackSinceTooPicky) { … }
TEST_P(LargeIconServiceGetterTest, IconTooSmallStillWantBitmap) { … }
TEST_P(LargeIconServiceGetterTest, IconTooSmallDontWantAnything) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}