#include "chrome/browser/commerce/coupons/coupon_service.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/raw_ref.h"
#include "chrome/browser/commerce/coupons/coupon_service_factory.h"
#include "chrome/browser/persisted_state_db/session_proto_db_factory.h"
#include "chrome/test/base/testing_profile.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/proto/coupon_db_content.pb.h"
#include "components/session_proto_db/session_proto_db.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
coupon_db::CouponContentProto BuildProtoWithOneCoupon(
const int64_t id,
const char* origin,
const char* coupon_description,
const char* coupon_code) { … }
autofill::AutofillOfferData BuildCouponOfferData(const int64_t id,
const char* origin,
const char* coupon_description,
const char* coupon_code) { … }
const int64_t kMockCouponIdA = …;
const int64_t kMockCouponIdB = …;
const char kMockMerchantA[] = …;
const char kMockMerchantB[] = …;
const char kMockCouponDescriptionA[] = …;
const char kMockCouponDescriptionB[] = …;
const char kMockCouponCodeA[] = …;
const char kMockCouponCodeB[] = …;
const coupon_db::CouponContentProto kMockProtoA = …;
const coupon_db::CouponContentProto kMockProtoB = …;
CouponProto;
Coupons;
CouponsMap;
const CouponProto kExpectedA = …;
const CouponProto kExpectedB = …;
const CouponProto kEmptyExpected = …;
struct CouponDataStruct { … };
}
class CouponServiceTest : public testing::Test { … };
TEST_F(CouponServiceTest, TestGetCouponForUrl) { … }
TEST_F(CouponServiceTest, TestUpdateCoupons) { … }
TEST_F(CouponServiceTest, TestDeleteCouponForUrl) { … }
TEST_F(CouponServiceTest, TestInitialization) { … }
TEST_F(CouponServiceTest, TestDeleteAllCoupons) { … }
TEST_F(CouponServiceTest, TestIsUrlEligible) { … }
TEST_F(CouponServiceTest, TestRecordCouponDisplayTimestamp) { … }
TEST_F(CouponServiceTest, TestUpdateCoupons_NotOverwriteLastDisplayTime) { … }
TEST_F(CouponServiceTest, TestUpdateCoupons_OldCouponDisplayTimeRemoved) { … }
TEST_F(CouponServiceTest, MaybeFeatureStatusChanged_FeatureDisabled) { … }
TEST_F(CouponServiceTest, TestSetupCouponServiceObserver) { … }
TEST_F(CouponServiceTest, TestDeleteCouponForUrl_NotifyObserver) { … }
TEST_F(CouponServiceTest, TestDeleteAllCoupons_NotifyObserver) { … }
TEST_F(CouponServiceTest, TestUpdateCoupons_NotifyObserver) { … }
TEST_F(CouponServiceTest, TestUpdateCoupons_SkipExisting) { … }
class CouponServiceFeatureDisabledTest : public CouponServiceTest { … };
TEST_F(CouponServiceFeatureDisabledTest, FeatureDisabled) { … }