chromium/components/page_image_service/image_service_impl_unittest.cc

// Copyright 2023 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/page_image_service/image_service_impl.h"

#include <memory>

#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "components/omnibox/browser/remote_suggestions_service.h"
#include "components/omnibox/browser/test_scheme_classifier.h"
#include "components/optimization_guide/core/optimization_guide_decision.h"
#include "components/optimization_guide/core/optimization_guide_features.h"
#include "components/optimization_guide/core/test_optimization_guide_decider.h"
#include "components/optimization_guide/proto/common_types.pb.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/optimization_guide/proto/salient_image_metadata.pb.h"
#include "components/page_image_service/features.h"
#include "components/page_image_service/metrics_util.h"
#include "components/page_image_service/mojom/page_image_service.mojom-shared.h"
#include "components/page_image_service/mojom/page_image_service.mojom.h"
#include "components/search_engines/search_engines_test_environment.h"
#include "components/sync/test/test_sync_service.h"
#include "components/variations/scoped_variations_ids_provider.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

ElementsAre;

namespace optimization_guide {
namespace {

class ImageServiceTestOptGuide : public TestOptimizationGuideDecider {};

}  // namespace
}  // namespace optimization_guide

namespace page_image_service {

class ImageServiceImplTest : public testing::Test {};

// Helper method that stores `image_url` into `out_image_url`.
void StoreImageUrlResponse(GURL* out_image_url, const GURL& image_url) {}

// Stores an image response and exits out of `loop` if it is defined.
void QuitLoopAndStoreImageUrlResponse(base::RunLoop* loop,
                                      GURL* out_image_url,
                                      const GURL& image_url) {}

void AppendResponse(std::vector<GURL>* responses, const GURL& image_url) {}

TEST_F(ImageServiceImplTest, DoesNotRegisterForNavigationRelatedMetadata) {}

TEST_F(ImageServiceImplTest, GetConsentToFetchImage) {}

TEST_F(ImageServiceImplTest, SyncInitialization) {}

TEST_F(ImageServiceImplTest, SuggestBackendEndToEnd) {}

// This also tests batching, because it's an integral part of how Optimization
// Guide backend works.
TEST_F(ImageServiceImplTest, OptimizationGuideSalientImagesEndToEnd) {}

TEST_F(ImageServiceImplTest, OptimizationGuideBatchingRespectsMaxUrls) {}

class DisabledOptGuideImageServiceImplTest : public ImageServiceImplTest {};

TEST_F(DisabledOptGuideImageServiceImplTest, DoesNotFetch) {}

}  // namespace page_image_service