chromium/chrome/browser/cart/fetch_discount_worker_unittest.cc

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

#include "chrome/browser/cart/fetch_discount_worker.h"

#include <string_view>

#include "base/containers/flat_map.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "chrome/browser/cart/cart_discount_fetcher.h"
#include "chrome/browser/cart/cart_service_factory.h"
#include "chrome/browser/commerce/coupons/coupon_service.h"
#include "chrome/browser/commerce/coupons/coupon_service_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/core/browser/data_model/autofill_offer_data.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/commerce_heuristics_data.h"
#include "components/endpoint_fetcher/endpoint_fetcher.h"
#include "components/prefs/pref_service.h"
#include "components/search/ntp_features.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/variations/variations.mojom.h"
#include "components/variations/variations_client.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_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {
cart_db::RuleDiscountInfoProto BuildPercentOffDiscountInfoProto(
    const std::string& rule_id,
    const std::string& merchant_rule_id,
    const std::string& raw_merchant_offer_id,
    const int percent_off) {}

cart_db::ChromeCartContentProto BuildCartContentProto(const char* domain,
                                                      const char* merchant_url,
                                                      const double timestamp) {}

coupon_db::FreeListingCouponInfoProto BuildFreeListingCouponInfoProto(
    const std::string& description,
    const std::string& code,
    const int64_t id,
    const double expiration_time) {}

std::unique_ptr<autofill::AutofillOfferData> BuildCouponsMapValueEntry(
    const GURL& cart_url,
    const coupon_db::FreeListingCouponInfoProto& coupon_info) {}

cart_db::ChromeCartContentProto AddRBDDiscountToProto(
    cart_db::ChromeCartContentProto proto,
    const std::string& merchant_id,
    cart_db::RuleDiscountInfoProto discount_proto) {}

cart_db::ChromeCartContentProto AddCouponDiscountToProto(
    cart_db::ChromeCartContentProto proto,
    const std::string& merchant_id,
    bool has_coupons) {}

MATCHER_P(EqualsProto, message, "") {}

testing::Matcher<autofill::DisplayStrings> EqualsDisplayStrings(
    const autofill::DisplayStrings& display_strings) {}

testing::Matcher<autofill::AutofillOfferData> EqualsAutofillOfferData(
    const autofill::AutofillOfferData& data) {}

const char kMockMerchantA[] =;
const char kMockMerchantACartUrl[] =;
const char kMockMerchantAId[] =;
const char kMockMerchantARuleId[] =;
const char kMockMerchantARawMerchantOfferId[] =;
const char kMockMerchantAHighestPercentOff[] =;
const int kMockMerchantAPercentOff =;
const double kMockMerchantATimestamp =;
const cart_db::ChromeCartContentProto kMockMerchantACartContentProto =;
const std::vector<cart_db::RuleDiscountInfoProto> kMockMerchantADiscounts =;
const char kEmail[] =;

const std::vector<coupon_db::FreeListingCouponInfoProto>
    kEmptyCouponDiscountList =;

const char kGlobalHeuristicsJSONData[] =;
}  // namespace

class FakeCartDiscountFetcher : public CartDiscountFetcher {};

int FakeCartDiscountFetcher::fetcher_fetch_count_ =;

class MockCartDiscountFetcher : public CartDiscountFetcher {};

class FakeCartDiscountFetcherFactory : public CartDiscountFetcherFactory {};

class FakeCartDiscountServiceDelegate : public CartDiscountServiceDelegate {};

class FakeVariationsClient : public variations::VariationsClient {};

class FetchDiscountWorkerTestBase : public testing::Test {};

class FetchDiscountWorkerTest : public FetchDiscountWorkerTestBase {};

TEST_F(FetchDiscountWorkerTest, TestStart_EndToEnd) {}

TEST_F(FetchDiscountWorkerTest, TestStart_DiscountUpdatedWithRBDDiscount) {}

TEST_F(FetchDiscountWorkerTest, TestStart_DiscountUpdatedWithCouponDiscount) {}

TEST_F(FetchDiscountWorkerTest, TestStart_DiscountUpdatedClearDiscount) {}

TEST_F(FetchDiscountWorkerTest, TestStart_FetcherRefetched) {}

TEST_F(FetchDiscountWorkerTest, TestTesterFetch) {}

TEST_F(FetchDiscountWorkerTest, TestFetchSkippedForNonPartnerMerchants) {}

TEST_F(FetchDiscountWorkerTest, TestFetchForCouponPartnerMerchants) {}

TEST_F(FetchDiscountWorkerTest, TestUpdateFreeListingCouponsWithCode) {}

class FetchMerchantWideDiscountWorkerTest : public FetchDiscountWorkerTestBase {};

TEST_F(FetchMerchantWideDiscountWorkerTest, TestFetch) {}

TEST_F(FetchMerchantWideDiscountWorkerTest,
       TestNoFetchForMerchantWithoutDiscounts) {}