#include "components/commerce/core/discounts_storage.h"
#include "base/check.h"
#include "base/functional/callback.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/commerce_types.h"
#include "components/commerce/core/proto/discounts_db_content.pb.h"
#include "components/history/core/browser/history_types.h"
#include "components/session_proto_db/session_proto_storage.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
InSequence;
namespace {
const char kDiscountsUrlFromServer[] = …;
const char kDiscountsUrlInDb[] = …;
const char kDiscountLanguageCode[] = …;
const char kDiscountDetail[] = …;
const char kDiscountTerms[] = …;
const char kDiscountValueText[] = …;
const double kDiscountExpiryTime = …;
const char kDiscountCode[] = …;
const uint64_t kDiscountIdFromServer = …;
const uint64_t kDiscountIdInDb1 = …;
const uint64_t kDiscountIdInDb2 = …;
const uint64_t kDiscountOfferId = …;
const char kDeleteUrl1[] = …;
const char kDeleteUrl2[] = …;
std::vector<commerce::DiscountInfo> MockServerResults(
commerce::DiscountClusterType type) { … }
MATCHER(ExpectedServerProto, "") { … }
std::vector<SessionProtoStorage<commerce::DiscountsContent>::KeyAndValue>
MockDbLoadResponse(bool discount1_expired, bool discount2_expired) { … }
class MockProtoStorage
: public SessionProtoStorage<commerce::DiscountsContent> { … };
}
namespace commerce {
class DiscountsStorageTest : public testing::Test { … };
TEST_F(DiscountsStorageTest, TestHandleServerDiscounts_NotCheckingDB) { … }
TEST_F(DiscountsStorageTest, TestHandleServerDiscounts_DBFailToLoad) { … }
TEST_F(DiscountsStorageTest,
TestHandleServerDiscounts_CheckingDB_AllDiscountsUnexpired) { … }
TEST_F(DiscountsStorageTest,
TestHandleServerDiscounts_CheckingDB_AllDiscountsExpired) { … }
TEST_F(DiscountsStorageTest,
TestHandleServerDiscounts_CheckingDB_PartDiscountsExpired) { … }
TEST_F(DiscountsStorageTest, TestHandleServerDiscounts_NoDiscountsFound) { … }
TEST_F(DiscountsStorageTest,
TestHandleServerDiscounts_NotStoringPageLevelDiscounts_shoppyPageOn) { … }
TEST_F(DiscountsStorageTest,
TestHandleServerDiscounts_NotStoringPageLevelDiscounts_shoppyPageOff) { … }
TEST_F(DiscountsStorageTest, TestOnURLsDeleted_DeleteAll) { … }
TEST_F(DiscountsStorageTest, TestOnURLsDeleted_DeleteUrls) { … }
}