chromium/chrome/browser/ui/views/autofill/popup/password_favicon_loader_unittest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/autofill/popup/password_favicon_loader.h"

#include <memory>

#include "base/memory/ref_counted_memory.h"
#include "base/test/mock_callback.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/favicon_base/favicon_types.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/image_fetcher/core/image_fetcher_types.h"
#include "components/image_fetcher/core/mock_image_fetcher.h"
#include "components/image_fetcher/core/request_metadata.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/resources/grit/ui_resources.h"

namespace autofill {
namespace {

// TODO(crbug.com/325246516): Move to components/favicon/core/test.
class MockLargeIconService : public favicon::LargeIconService {};

MATCHER_P(ImagesAreEqual, img, "") {}

favicon_base::LargeIconResult GetFaviconResult(const gfx::Image& image) {}

// `LargeIconService::GetLargeIconFromCacheFallbackToGoogleServer()` wrapper
// that simplifies its mocking by ignoring all arguments except the callback.
auto MockGetLargeIcon(
    testing::OnceAction<void(favicon_base::LargeIconCallback callback)>
        callback_handler) {}

// `ImageFetcher::FetchImageAndData_()` wrapper that simplifies its mocking by
// ignoring all arguments except the callback.
auto MockFetchImageAndData(
    testing::OnceAction<void(image_fetcher::ImageFetcherCallback* callback)>
        callback_handler) {}

}  // namespace

class PasswordFaviconLoaderTest : public testing::Test {};

TEST_F(PasswordFaviconLoaderTest, LoadsImagesFromFaviconService) {}

TEST_F(PasswordFaviconLoaderTest, FailsWithInvalidResponseFromFaviconService) {}

TEST_F(PasswordFaviconLoaderTest, LoadsImagesFromImageFetcher) {}

TEST_F(PasswordFaviconLoaderTest, FailsWithInvalidResponseFromImageFetcher) {}

TEST_F(PasswordFaviconLoaderTest, ImagesFromFaviconServiceAreCached) {}

TEST_F(PasswordFaviconLoaderTest, ImagesFromImageFetcherAreCached) {}
}  // namespace autofill