chromium/components/search_provider_logos/logo_service_impl_unittest.cc

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

#include "components/search_provider_logos/logo_service_impl.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <string_view>
#include <vector>

#include "base/base64.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/mock_callback.h"
#include "base/test/simple_test_clock.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/image_fetcher/core/image_decoder.h"
#include "components/search_engines/search_engines_test_environment.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_provider_logos/fixed_logo_api.h"
#include "components/search_provider_logos/google_logo_api.h"
#include "components/search_provider_logos/logo_cache.h"
#include "components/search_provider_logos/logo_observer.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "net/base/url_util.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/image/image.h"

_;
AnyNumber;
AtMost;
Eq;
InSequence;
Invoke;
Mock;
Ne;
NiceMock;
Not;
NotNull;
Pointee;
Return;
StrictMock;

TestingPrefServiceSyncable;

namespace search_provider_logos {

namespace {

MockLogoCallback;
MockEncodedLogoCallback;

scoped_refptr<base::RefCountedString> EncodeBitmapAsPNG(
    const SkBitmap& bitmap) {}

std::string EncodeBitmapAsPNGBase64(const SkBitmap& bitmap) {}

SkBitmap MakeBitmap(int width, int height) {}

SkBitmap MakeBitmap2(int width, int height) {}

EncodedLogo EncodeLogo(const Logo& logo) {}

Logo DecodeLogo(const EncodedLogo& encoded_logo) {}

Logo GetSampleLogo(const GURL& logo_url, base::Time response_time) {}

Logo GetSampleLogoWithoutDarkImage(const GURL& logo_url,
                                   base::Time response_time) {}

Logo GetSampleLogo2(const GURL& logo_url, base::Time response_time) {}

std::string MakeServerResponse(const SkBitmap& image,
                               const SkBitmap& dark_image,
                               const std::string& on_click_url,
                               const std::string& alt_text,
                               const std::string& animated_url,
                               const std::string& dark_animated_url,
                               const std::string& mime_type,
                               const std::string& dark_mime_type,
                               const std::string& fingerprint,
                               base::TimeDelta time_to_live) {}

std::string MakeServerResponse(const Logo& logo, base::TimeDelta time_to_live) {}

template <typename Arg, typename Matcher>
bool Match(const Arg& arg,
           const Matcher& matcher,
           ::testing::MatchResultListener* result_listener) {}

MATCHER_P(DecodesTo, decoded_logo, "") {}

class MockLogoCache : public LogoCache {};

class FakeImageDecoder : public image_fetcher::ImageDecoder {};

// A helper class that wraps around all the dependencies required to simulate
// signing in/out.
class SigninHelper {};

class LogoServiceImplTest : public ::testing::Test {};

void LogoServiceImplTest::CapturingInterceptor(
    const network::ResourceRequest& request) {}

std::string LogoServiceImplTest::ServerResponse(const Logo& logo) {}

void LogoServiceImplTest::SetServerResponse(const std::string& response,
                                            int error_code,
                                            net::HttpStatusCode response_code) {}

void LogoServiceImplTest::SetServerResponseWhenFingerprint(
    const std::string& fingerprint,
    const std::string& response_when_fingerprint,
    int error_code,
    net::HttpStatusCode response_code) {}

const GURL& LogoServiceImplTest::DoodleURL() const {}

void LogoServiceImplTest::GetLogo(LogoCallbacks callbacks) {}

void LogoServiceImplTest::GetDecodedLogo(LogoCallback cached,
                                         LogoCallback fresh) {}

void LogoServiceImplTest::GetEncodedLogo(EncodedLogoCallback cached,
                                         EncodedLogoCallback fresh) {}

void LogoServiceImplTest::AddSearchEngine(std::string_view keyword,
                                          std::string_view short_name,
                                          const std::string& url,
                                          GURL doodle_url,
                                          bool make_default) {}

// Tests -----------------------------------------------------------------------

TEST_F(LogoServiceImplTest, CTARequestedBackgroundCanUpdate) {}

TEST_F(LogoServiceImplTest, DownloadAndCacheLogo) {}

TEST_F(LogoServiceImplTest, DownloadAndCacheLogoWithoutDarkImage) {}

TEST_F(LogoServiceImplTest, DownloadAndCacheEncodedLogo) {}

TEST_F(LogoServiceImplTest, DownloadAndCacheEncodedLogoWithoutDarkImage) {}

TEST_F(LogoServiceImplTest, ShouldReturnDisabledWhenDSEHasNoLogo) {}

TEST_F(LogoServiceImplTest, EmptyCacheAndFailedDownload) {}

TEST_F(LogoServiceImplTest, AcceptMinimalLogoResponse) {}

TEST_F(LogoServiceImplTest, ReturnCachedLogo) {}

TEST_F(LogoServiceImplTest, ValidateCachedLogo) {}

TEST_F(LogoServiceImplTest, UpdateCachedLogoMetadata) {}

TEST_F(LogoServiceImplTest, UpdateCachedLogo) {}

TEST_F(LogoServiceImplTest, InvalidateCachedLogo) {}

TEST_F(LogoServiceImplTest, DeleteCachedLogoFromOldUrl) {}

TEST_F(LogoServiceImplTest, LogoWithTTLCannotBeShownAfterExpiration) {}

TEST_F(LogoServiceImplTest, LogoWithoutTTLCanBeShownAfterExpiration) {}

TEST_F(LogoServiceImplTest, UseSoftExpiredCachedLogo) {}

TEST_F(LogoServiceImplTest, RerequestSoftExpiredCachedLogo) {}

TEST_F(LogoServiceImplTest, DeleteAncientCachedLogo) {}

TEST_F(LogoServiceImplTest, DeleteExpiredCachedLogo) {}

TEST_F(LogoServiceImplTest, ClearLogoOnSignOut) {}

// Tests that deal with multiple listeners.

void EnqueueCallbacks(LogoServiceImpl* logo_service,
                      std::vector<LogoCallback>* cached_callbacks,
                      std::vector<LogoCallback>* fresh_callbacks,
                      size_t start_index) {}

TEST_F(LogoServiceImplTest, SupportOverlappingLogoRequests) {}

TEST_F(LogoServiceImplTest, DeleteCallbacksWhenLogoURLChanged) {}

}  // namespace

bool operator==(const Logo& a, const Logo& b) {}

bool operator==(const EncodedLogo& a, const EncodedLogo& b) {}

void PrintTo(const Logo& logo, std::ostream* ostr) {}

void PrintTo(const EncodedLogo& logo, std::ostream* ostr) {}

}  // namespace search_provider_logos