#include "chrome/browser/cart/cart_discount_fetcher.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/cart/fetch_discount_worker.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/endpoint_fetcher/mock_endpoint_fetcher.h"
#include "components/search/ntp_features.h"
#include "components/session_proto_db/session_proto_db.h"
#include "content/public/test/browser_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_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"
namespace {
cart_db::ChromeCartContentProto BuildProto(
const char* domain,
const char* merchant_url,
const double timestamp,
const std::vector<std::string>& raw_merchant_offers) { … }
ShoppingCarts;
const char kMockMerchantA[] = …;
const char kMockMerchantCartURLA[] = …;
const char kMockMerchantAHighestDiscountString[] = …;
const int kMockMerchantALastTimestamp = …;
const int kThirtyMinutesInSeconds = …;
const char kMockMerchantARawOfferIdOne[] = …;
const char kMockMerchantARawOfferIdTwo[] = …;
const char kConfigurableEndpoint[] = …;
const char kLocales[] = …;
const char kVariationHeaders[] = …;
const char kEndpointResponse[] = …;
}
class CartDiscountFetcherTest { … };
TEST(CartDiscountFetcherTest, TestGeneratePostData) { … }
TEST(CartDiscountFetcherTest, TestOnDiscountsAvailableParsing) { … }
TEST(CartDiscountFetcherTest, TestHighestDiscounts) { … }
TEST(CartDiscountFetcherTest, TestRawMaerchantOffersIsOptional) { … }
TEST(CartDiscountFetcherTest, TestExternalTesterDiscount) { … }
TEST(CartDiscountFetcherTest, TestNoRuleDiscounts) { … }
TEST(CartDiscountFetcherTest, TestOverallDiscountText) { … }
TEST(CartDiscountFetcherTest, TestOverallDiscountTextWithRuleDiscounts) { … }
TEST(CartDiscountFetcherTest, TestCodeBasedRuleDiscount) { … }
class CartDiscountFetcherConfigurableEndpointTest : public testing::Test { … };
TEST_F(CartDiscountFetcherConfigurableEndpointTest,
TestServerConfiguraleEndpoint) { … }