#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/commerce/core/shopping_service.h"
#include <string>
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/values.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_node.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/feature_utils.h"
#include "components/commerce/core/mock_account_checker.h"
#include "components/commerce/core/mock_discounts_storage.h"
#include "components/commerce/core/pref_names.h"
#include "components/commerce/core/proto/shopping_page_types.pb.h"
#include "components/commerce/core/shopping_service_test_base.h"
#include "components/commerce/core/test_utils.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/url_row.h"
#include "components/optimization_guide/core/optimization_guide_decider.h"
#include "components/optimization_guide/core/optimization_guide_decision.h"
#include "components/optimization_guide/core/optimization_metadata.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/power_bookmarks/core/power_bookmark_utils.h"
#include "components/power_bookmarks/core/proto/power_bookmark_meta.pb.h"
#include "components/power_bookmarks/core/proto/shopping_specifics.pb.h"
#include "components/prefs/testing_pref_service.h"
#include "components/search/ntp_features.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync/base/features.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/test/test_sync_service.h"
#include "components/unified_consent/pref_names.h"
#include "net/base/url_util.h"
#include "testing/gtest/include/gtest/gtest.h"
OptimizationGuideDecision;
OptimizationGuideDecisionCallback;
OptimizationMetadata;
Any;
OptimizationType;
_;
namespace commerce {
namespace {
const char kProductUrl[] = …;
const char kTitle[] = …;
const char kGpcTitle[] = …;
const char kImageUrl[] = …;
const uint64_t kOfferId = …;
const uint64_t kClusterId = …;
const char kCountryCode[] = …;
const char kCurrencyCode[] = …;
const int64_t kPrice = …;
const int64_t kNewPrice = …;
const char kMerchantUrl[] = …;
const float kStarRating = …;
const uint32_t kCountRating = …;
const char kDetailsPageUrl[] = …;
const bool kHasReturnPolicy = …;
const bool kContainsSensitiveContent = …;
const char kEligibleCountry[] = …;
const char kEligibleLocale[] = …;
const char kPriceInsightsUrl[] = …;
const int64_t kLowTypicalPrice = …;
const int64_t kHighTypicalPrice = …;
const char kAnotherCurrencyCode[] = …;
const char kAttributes[] = …;
const char kJackpotUrl[] = …;
const char kDiscountsUrl1[] = …;
const char kDiscountsUrl2[] = …;
const char kDiscountLanguageCode[] = …;
const char kDiscountDetail[] = …;
const char kDiscountTerms[] = …;
const char kDiscountValueText[] = …;
const double kDiscountExpiryTime = …;
const char kDiscountCode[] = …;
const uint64_t kDiscountId1 = …;
const uint64_t kDiscountOfferId = …;
const std::vector<std::vector<std::string>> kProductCategories = …;
NiceMockWebWrapper;
}
class ShoppingServiceTest : public ShoppingServiceTestBase,
public testing::WithParamInterface<bool> { … };
TEST_P(ShoppingServiceTest, TestProductInfoResponse) { … }
TEST_P(ShoppingServiceTest, TestProductInfoResponse_FallbackToOnDemand) { … }
TEST_P(ShoppingServiceTest, TestProductInfoResponse_MultipleOnDemandRequests) { … }
TEST_P(ShoppingServiceTest, TestProductInfoResponse_ApiDisabled) { … }
TEST_P(ShoppingServiceTest, TestProductInfoResponse_CurrencyMismatch) { … }
TEST_P(ShoppingServiceTest, TestProductInfoResponse_OptGuideFalse) { … }
TEST_P(ShoppingServiceTest, TestProductInfoCacheURLCount) { … }
TEST_P(ShoppingServiceTest, TestWebWrapperSet) { … }
TEST_P(ShoppingServiceTest, TestWebWrapperSetWithProducts) { … }
TEST_P(ShoppingServiceTest, TestRecentUrls_NoDuplicates) { … }
TEST_P(ShoppingServiceTest, TestRecentUrls_MaxCount) { … }
TEST_P(ShoppingServiceTest, TestRecentUrls_ClearedOnHistoryDeletion) { … }
TEST_P(ShoppingServiceTest, TestRecentUrls_SingleHistoryItemDeletion) { … }
TEST_P(ShoppingServiceTest, TestRecentUrls_CacheEntriesRetained) { … }
TEST_P(ShoppingServiceTest, TestProductSpecificationsSetUrlsRetained) { … }
TEST_P(ShoppingServiceTest, TestProductSpecificationsUrlCountMetrics) { … }
TEST_P(ShoppingServiceTest, TestProductInfoCacheFullLifecycle) { … }
TEST_P(ShoppingServiceTest,
TestProductInfoCacheFullLifecycleWithFallback_PageNotLoaded) { … }
TEST_P(ShoppingServiceTest,
TestProductInfoCacheFullLifecycleWithFallback_PageLoaded) { … }
TEST_P(ShoppingServiceTest, TestProductInfoWithFallback_NoOnDemandCalls) { … }
TEST_P(ShoppingServiceTest,
TestProductInfoWithFallback_CallsOnDemandOnce_RefInCache) { … }
TEST_P(ShoppingServiceTest, TestMerchantInfoResponse) { … }
TEST_P(ShoppingServiceTest, TestMerchantInfoResponse_ApiDisabled) { … }
TEST_P(ShoppingServiceTest, TestGetUpdatedProductInfoForBookmarks) { … }
TEST_P(ShoppingServiceTest, TestDataMergeWithLeadImage) { … }
TEST_P(ShoppingServiceTest, TestDataMergeWithNoLeadImage) { … }
TEST_P(ShoppingServiceTest, TestDataMergeWithTitle) { … }
TEST_P(ShoppingServiceTest, TestDataMergeWithNoTitle) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_Policy) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_FeatureFlagOff) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_MSBB) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_SignIn) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_ChildAccount) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_SyncState) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_CountryAndLocale) { … }
TEST_P(ShoppingServiceTest,
TestShoppingListEligible_CountryAndLocale_BothFlags) { … }
TEST_P(ShoppingServiceTest, TestShoppingListEligible_CountryAndLocale_NoFlags) { … }
TEST_P(ShoppingServiceTest,
TestShoppingListEligible_CountryAndLocale_RegionLaunched) { … }
class ShoppingServiceReadyTest : public ShoppingServiceTest { … };
TEST_P(ShoppingServiceReadyTest,
TestServiceReadyDelaysForSync_TransportStartsInactive) { … }
TEST_P(ShoppingServiceReadyTest,
TestServiceReadyDelaysForSync_TransportStartsActive) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ShoppingServiceTest, TestPriceInsightsInfoResponse) { … }
TEST_P(ShoppingServiceTest,
TestPriceInsightsInfoResponse_DifferentCurrencyCode) { … }
TEST_P(ShoppingServiceTest, TestPriceInsightsInfoResponse_EmptyClusterId) { … }
TEST_P(ShoppingServiceTest, TestPriceInsightsInfoResponse_EmptyRange) { … }
TEST_P(ShoppingServiceTest, TestPriceInsightsInfoResponse_WithoutCache) { … }
TEST_P(ShoppingServiceTest, TestPriceInsightsInfoResponse_WithCache) { … }
TEST_P(ShoppingServiceTest,
TestPriceInsightsInfoResponse_WithCacheMultipleTabs) { … }
TEST_P(ShoppingServiceTest, TestIsShoppingPage) { … }
TEST_P(ShoppingServiceTest, TestDiscountInfoResponse) { … }
TEST_P(ShoppingServiceTest, TestDiscountInfoResponse_InfoWithoutId) { … }
TEST_P(ShoppingServiceTest, TestDiscountInfoResponse_InfoWithoutTerms) { … }
TEST_P(ShoppingServiceTest, TestDiscountInfoResponse_InfoWithoutDiscountCode) { … }
INSTANTIATE_TEST_SUITE_P(…);
}