#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/commerce/core/product_specifications/product_specifications_service.h"
#include <optional>
#include <vector>
#include "base/containers/to_vector.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/commerce_types.h"
#include "components/commerce/core/product_specifications/product_specifications_set.h"
#include "components/commerce/core/product_specifications/product_specifications_sync_bridge.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/model/in_memory_metadata_change_list.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 char kProductOneUrl[] = …;
const char kProductTwoUrl[] = …;
const char kProductSpecsName[] = …;
sync_pb::ProductComparisonSpecifics BuildProductComparisonSpecifics(
const std::string& uuid,
int64_t creation_time_millis_epoch,
int64_t update_time_millis_epoch,
const std::string& name,
std::vector<std::string> urls) { … }
void CheckSpecsAgainstSpecifics(
const commerce::ProductSpecificationsSet& specifications,
const sync_pb::ProductComparisonSpecifics& specifics) { … }
const sync_pb::ProductComparisonSpecifics kProductComparisonSpecifics[] = …;
syncer::EntityData MakeEntityData(
const sync_pb::ProductComparisonSpecifics& specifics) { … }
void AddTestSpecifics(commerce::ProductSpecificationsSyncBridge* bridge) { … }
template <class T>
void Swap(std::vector<T>& items, std::vector<std::pair<int, int>> indices) { … }
MATCHER_P(HasAllProductSpecs, product_comparison_specifics, "") { … }
MATCHER_P(IsSetWithUuid, uuid, "") { … }
MATCHER_P2(HasProductSpecsNameUrl, name, urls, "") { … }
MATCHER_P2(HasProductSpecsNameUrlInfos, name, url_infos, "") { … }
MATCHER_P(HasProductSpecsName, name, "") { … }
}
namespace commerce {
class MockProductSpecificationsSetObserver
: public ProductSpecificationsSet::Observer { … };
class ProductSpecificationsServiceTest : public testing::Test { … };
class ProductSpecificationsServiceSyncDisabledTest
: public ProductSpecificationsServiceTest { … };
class ProductSpecificationsServiceWithTitleTest
: public ProductSpecificationsServiceTest { … };
TEST_F(ProductSpecificationsServiceTest, TestGetProductSpecifications) { … }
TEST_F(ProductSpecificationsServiceTest, TestGetProductSpecificationsAsync) { … }
TEST_F(ProductSpecificationsServiceTest, TestGetSetByUuidAsync) { … }
TEST_F(ProductSpecificationsServiceTest,
TestGetSetByUuidAsyncAlreadyInitialized) { … }
TEST_F(ProductSpecificationsServiceTest, TestAddProductSpecificationsSuccess) { … }
TEST_F(ProductSpecificationsServiceTest, TestRemoveProductSpecifications) { … }
TEST_F(ProductSpecificationsServiceTest, TestObserverNewSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest, TestSetUrls) { … }
TEST_F(ProductSpecificationsServiceTest, TestSetName) { … }
TEST_F(ProductSpecificationsServiceTest, TestSetNameAndUrls_BadId) { … }
TEST_F(ProductSpecificationsServiceTest, TestObserverUpdateSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest, TestObserverRemoveSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest,
TestGetProductSpecificationsMultiSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest,
TestGetProductSpecificationsLargeURLList) { … }
TEST_F(ProductSpecificationsServiceTest,
TestAddProductSpecificationsMultipleSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest, TestDeleteProductSpecsMultiSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest, TestSetUrlsMultiSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest, TestSetNameMultiSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest,
TestSetNameMultiSpecificsTopLevelSpecificAbsent) { … }
TEST_F(ProductSpecificationsServiceTest, TestGetByUuidMultiSpecifics) { … }
TEST_F(ProductSpecificationsServiceTest,
TestGetByUuidMultiSpecificsTopLevelAbsent) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest,
TestGetProductSpecifications) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest, TestGetSetByUuid) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest,
TestAddProductSpecificationsSet) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest, TestSetUrls) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest, TestSetName) { … }
TEST_F(ProductSpecificationsServiceSyncDisabledTest, TestDelete) { … }
TEST_F(ProductSpecificationsServiceTest, TestMultiSpecificsAdded) { … }
TEST_F(ProductSpecificationsServiceTest, TestMultiSpecificsSetUrls) { … }
TEST_F(ProductSpecificationsServiceTest, TestMultiSpecificsSetNameUpdate) { … }
TEST_F(ProductSpecificationsServiceTest, TestMultiSpecificsDelete) { … }
TEST_F(ProductSpecificationsServiceTest, TestMigration) { … }
TEST_F(ProductSpecificationsServiceTest,
TestMultiSpecificsIgnoredForSingleSpecificsFlagOff) { … }
TEST_F(ProductSpecificationsServiceTest,
TestMultiSpecificsIgnoredForSingleSpecificsFlagOn) { … }
TEST_F(ProductSpecificationsServiceWithTitleTest, TestTitle) { … }
TEST_F(ProductSpecificationsServiceWithTitleTest, SetUrlWithTitle) { … }
}