#include "components/commerce/core/product_specifications/product_specifications_sync_bridge.h"
#include <vector>
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.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/product_specifications/product_specifications_set.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/model/data_batch.h"
#include "components/sync/model/entity_change.h"
#include "components/sync/model/in_memory_metadata_change_list.h"
#include "components/sync/protocol/entity_data.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/product_comparison_specifics.pb.h"
#include "components/sync/test/data_type_store_test_util.h"
#include "components/sync/test/mock_data_type_local_change_processor.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const std::vector<std::string> kInitUuid = …;
const std::vector<std::string> kInitName = …;
const std::vector<int64_t> kCreationTime = …;
const std::vector<int64_t> kUpdateTime = …;
const std::vector<std::vector<std::string>> kProductComparisonUrls = …;
std::vector<syncer::KeyAndData> GetKeyAndData(syncer::DataBatch* data_batch) { … }
void VerifySpecificsAgainstIndex(
sync_pb::ProductComparisonSpecifics* product_comparison_specifics,
uint64_t idx) { … }
std::string GetName(uint64_t idx) { … }
sync_pb::ProductComparisonSpecifics BuildProductComparisonSpecifics(
std::string uuid,
int64_t creation_time_millis_epoch,
int64_t update_time_millis_epoch,
std::string name,
const std::vector<std::string>& urls) { … }
const std::vector<sync_pb::ProductComparisonSpecifics> kInitCompareSpecifics = …;
const std::vector<sync_pb::ProductComparisonSpecifics>
kProductComparisonSpecifics = …;
syncer::EntityData MakeEntityData(
const sync_pb::ProductComparisonSpecifics& specifics) { … }
void VerifyCompareSpecifics(const sync_pb::ProductComparisonSpecifics& expected,
const sync_pb::ProductComparisonSpecifics& actual) { … }
MATCHER_P(IsMetadataSize, size, "") { … }
}
namespace commerce {
class ProductSpecificationsSyncBridgeObserver
: public ProductSpecificationsSyncBridge::Delegate { … };
class ProductSpecificationsSyncBridgeTest : public testing::Test { … };
class ProductSpecificationsSyncMultiSpecsBridgeTest
: public ProductSpecificationsSyncBridgeTest { … };
TEST_F(ProductSpecificationsSyncBridgeTest, TestGetStorageKey) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestGetClientTag) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestInitialization) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestGetDataForCommit) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestGetDataForDebugging) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestAdd) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestApplyUpdateLaterTimestamp) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestApplyUpdateEarlierTimestamp) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestDelete) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, AddSpecifics) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestUpdate) { … }
TEST_F(ProductSpecificationsSyncBridgeTest,
TestDeleteProductSpecificationsSet) { … }
TEST_F(ProductSpecificationsSyncBridgeTest,
TestDeleteProductSpecificationsSetNotTrackingMetadata) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestDeleteMultiSpecifics) { … }
TEST_F(ProductSpecificationsSyncBridgeTest,
TestTrimAllSupportedFieldsFromRemoteSpecifics) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestSupportedFieldsMetadataCache) { … }
TEST_F(ProductSpecificationsSyncBridgeTest,
TestNoSupportedFieldsMetadataCache) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestCreateEntityDataLegacy) { … }
TEST_F(ProductSpecificationsSyncBridgeTest, TestCreateEntityDataFallback) { … }
TEST_F(ProductSpecificationsSyncMultiSpecsBridgeTest,
TestCreateEntityDataTopLevelSpecifics) { … }
TEST_F(ProductSpecificationsSyncMultiSpecsBridgeTest,
TestCreateEntityDataItemLevelSpecifics) { … }
TEST_F(ProductSpecificationsSyncMultiSpecsBridgeTest,
TestTrimSpecificsForCachingTopLevelSpecific) { … }
TEST_F(ProductSpecificationsSyncMultiSpecsBridgeTest,
TestTrimSpecificsForCachingProductComparisonItem) { … }
}