#include "components/commerce/core/shopping_service_test_base.h"
#include <optional>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/pref_names.h"
#include "components/commerce/core/proto/discounts.pb.h"
#include "components/commerce/core/proto/merchant_trust.pb.h"
#include "components/commerce/core/proto/price_insights.pb.h"
#include "components/commerce/core/proto/price_tracking.pb.h"
#include "components/commerce/core/proto/product_category.pb.h"
#include "components/commerce/core/proto/shopping_page_types.pb.h"
#include "components/commerce/core/test_utils.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/proto/common_types.pb.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync/test/test_sync_service.h"
#include "components/unified_consent/pref_names.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
OnDemandOptimizationGuideDecisionRepeatingCallback;
OptimizationGuideDecision;
OptimizationGuideDecisionCallback;
OptimizationGuideDecisionWithMetadata;
OptimizationMetadata;
Any;
OptimizationType;
RequestContext;
RequestContextMetadata;
namespace commerce {
const uint64_t kInvalidDiscountId = …;
MockOptGuideDecider::MockOptGuideDecider() { … }
MockOptGuideDecider::~MockOptGuideDecider() = default;
void MockOptGuideDecider::CanApplyOptimization(
const GURL& url,
OptimizationType optimization_type,
OptimizationGuideDecisionCallback callback) { … }
OptimizationGuideDecision MockOptGuideDecider::CanApplyOptimization(
const GURL& url,
OptimizationType optimization_type,
OptimizationMetadata* optimization_metadata) { … }
void MockOptGuideDecider::AddOnDemandShoppingResponse(
const GURL& url,
const OptimizationGuideDecision decision,
const OptimizationMetadata& data) { … }
void MockOptGuideDecider::SetResponse(const GURL& url,
const OptimizationType type,
const OptimizationGuideDecision decision,
const OptimizationMetadata& data) { … }
OptimizationMetadata MockOptGuideDecider::BuildPriceTrackingResponse(
const std::string& title,
const std::string& image_url,
const uint64_t offer_id,
const uint64_t product_cluster_id,
const std::string& country_code,
const int64_t amount_micros,
const std::string& currency_code,
const std::string& gpc_title,
const std::vector<std::vector<std::string>>& product_categories) { … }
void MockOptGuideDecider::AddPriceUpdateToPriceTrackingResponse(
OptimizationMetadata* out_meta,
const std::string& currency_code,
const int64_t current_price,
const int64_t previous_price) { … }
OptimizationMetadata MockOptGuideDecider::BuildMerchantTrustResponse(
const float star_rating,
const uint32_t count_rating,
const std::string& details_page_url,
const bool has_return_policy,
const bool contains_sensitive_content) { … }
OptimizationMetadata MockOptGuideDecider::BuildPriceInsightsResponse(
const uint64_t product_cluster_id,
const std::string& price_range_currency_code,
const int64_t low_typical_price_micros,
const int64_t high_typical_price_micros,
const std::string& price_history_currency_code,
const std::string& attributes,
const std::vector<std::tuple<std::string, int64_t>>& history_prices,
const std::string& jackpot_url,
const PriceBucket& price_bucket,
const bool has_multiple_catalogs) { … }
OptimizationMetadata MockOptGuideDecider::BuildDiscountsResponse(
const std::vector<DiscountInfo>& infos) { … }
void MockOptGuideDecider::SetDefaultShoppingPage(bool default_shopping_page) { … }
MockWebWrapper::MockWebWrapper(const GURL& last_committed_url,
bool is_off_the_record,
base::Value* result,
std::u16string title)
: … { … }
MockWebWrapper::~MockWebWrapper() = default;
void MockWebWrapper::SetIsFirstLoadForNavigationFinished(bool finished) { … }
MockWebExtractor::MockWebExtractor() { … }
MockWebExtractor::~MockWebExtractor() = default;
ShoppingServiceTestBase::ShoppingServiceTestBase()
: … { … }
ShoppingServiceTestBase::~ShoppingServiceTestBase() = default;
void ShoppingServiceTestBase::SetUp() { … }
void ShoppingServiceTestBase::TestBody() { … }
void ShoppingServiceTestBase::TearDown() { … }
void ShoppingServiceTestBase::DidNavigatePrimaryMainFrame(WebWrapper* web) { … }
void ShoppingServiceTestBase::DidFinishLoad(WebWrapper* web) { … }
void ShoppingServiceTestBase::SimulateProductInfoLocalExtractionTaskFinished() { … }
void ShoppingServiceTestBase::DidNavigateAway(WebWrapper* web,
const GURL& url) { … }
void ShoppingServiceTestBase::WebWrapperCreated(WebWrapper* web) { … }
void ShoppingServiceTestBase::WebWrapperDestroyed(WebWrapper* web) { … }
void ShoppingServiceTestBase::OnWebWrapperSwitched(WebWrapper* web) { … }
void ShoppingServiceTestBase::MergeProductInfoData(
ProductInfo* info,
const base::Value::Dict& on_page_data_map) { … }
int ShoppingServiceTestBase::GetProductInfoCacheOpenURLCount(const GURL& url) { … }
const ProductInfo* ShoppingServiceTestBase::GetFromProductInfoCache(
const GURL& url) { … }
CommerceInfoCache& ShoppingServiceTestBase::GetCache() { … }
MockOptGuideDecider* ShoppingServiceTestBase::GetMockOptGuideDecider() { … }
ProductSpecificationsSet::Observer*
ShoppingServiceTestBase::GetProductSpecServiceUrlRefObserver() { … }
}