#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/testing_pref_service.h"
#include "components/search_engines/search_engines_pref_names.h"
#include "components/search_engines/search_engines_switches.h"
#include "components/search_engines/search_engines_test_util.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_data.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_client.h"
#include "components/search_engines/template_url_starter_pack_data.h"
#include "components/search_engines/util.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/search_engine_specifics.pb.h"
#include "components/sync/test/sync_change_processor_wrapper_for_test.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
Time;
IsNull;
NotNull;
namespace {
const char kOmniboxScheme[] = …;
std::string GetGUID(const syncer::SyncData& sync_data) { … }
std::string GetURL(const syncer::SyncData& sync_data) { … }
std::string GetKeyword(const syncer::SyncData& sync_data) { … }
syncer::SyncData CreateCustomSyncData(const TemplateURL& turl,
bool autogenerate_keyword,
const std::string& url,
const std::string& sync_guid,
int prepopulate_id = -1) { … }
class TestChangeProcessor : public syncer::SyncChangeProcessor { … };
TestChangeProcessor::TestChangeProcessor() : … { … }
TestChangeProcessor::~TestChangeProcessor() { … }
std::optional<syncer::ModelError> TestChangeProcessor::ProcessSyncChanges(
const base::Location& from_here,
const syncer::SyncChangeList& change_list) { … }
class TestTemplateURLServiceClient : public TemplateURLServiceClient { … };
}
class TemplateURLServiceSyncTest : public testing::Test { … };
TemplateURLServiceSyncTest::TemplateURLServiceSyncTest()
: … { … }
void TemplateURLServiceSyncTest::SetUp() { … }
void TemplateURLServiceSyncTest::TearDown() { … }
std::unique_ptr<syncer::SyncChangeProcessor>
TemplateURLServiceSyncTest::PassProcessor() { … }
void TemplateURLServiceSyncTest::AssertEquals(const TemplateURL& expected,
const TemplateURL& actual) const { … }
void TemplateURLServiceSyncTest::AssertEquals(
const syncer::SyncDataList& data1,
const syncer::SyncDataList& data2) const { … }
syncer::SyncChange TemplateURLServiceSyncTest::CreateTestSyncChange(
syncer::SyncChange::SyncChangeType type,
std::unique_ptr<TemplateURL> turl) const { … }
syncer::SyncDataList TemplateURLServiceSyncTest::CreateInitialSyncData() const { … }
std::unique_ptr<TemplateURL> TemplateURLServiceSyncTest::Deserialize(
const syncer::SyncData& sync_data) { … }
std::unique_ptr<TemplateURL> TemplateURLServiceSyncTest::CopyTemplateURL(
const TemplateURLData* turl,
const std::string& url,
const std::string& guid) { … }
std::optional<syncer::ModelError>
TemplateURLServiceSyncTest::MergeAndExpectNotify(
syncer::SyncDataList initial_sync_data,
int expected_notify_count) { … }
std::optional<syncer::ModelError>
TemplateURLServiceSyncTest::MergeAndExpectNotifyAtLeast(
syncer::SyncDataList initial_sync_data) { … }
std::optional<syncer::ModelError>
TemplateURLServiceSyncTest::ProcessAndExpectNotify(
syncer::SyncChangeList changes,
int expected_notify_count) { … }
std::optional<syncer::ModelError>
TemplateURLServiceSyncTest::ProcessAndExpectNotifyAtLeast(
syncer::SyncChangeList changes) { … }
TEST_F(TemplateURLServiceSyncTest, SerializeDeserialize) { … }
TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataBasic) { … }
TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataWithOmniboxExtension) { … }
TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataWithSearchOverrideExtension) { … }
TEST_F(TemplateURLServiceSyncTest, GetAllSyncDataNoManagedEngines) { … }
TEST_F(TemplateURLServiceSyncTest, StartSyncEmpty) { … }
TEST_F(TemplateURLServiceSyncTest, MergeIntoEmpty) { … }
TEST_F(TemplateURLServiceSyncTest, MergeInAllNewData) { … }
TEST_F(TemplateURLServiceSyncTest, MergeSyncIsTheSame) { … }
TEST_F(TemplateURLServiceSyncTest, MergeUpdateFromSync) { … }
TEST_F(TemplateURLServiceSyncTest, MergeAddFromOlderSyncData) { … }
TEST_F(TemplateURLServiceSyncTest, MergeAddFromNewerSyncData) { … }
TEST_F(TemplateURLServiceSyncTest, MergeIgnoresPolicyAndPlayAPIEngines) { … }
TEST_F(TemplateURLServiceSyncTest, ProcessChangesEmptyModel) { … }
TEST_F(TemplateURLServiceSyncTest, ProcessChangesNoConflicts) { … }
TEST_F(TemplateURLServiceSyncTest,
ProcessChangesWithDuplicateKeywordsSyncWins) { … }
TEST_F(TemplateURLServiceSyncTest,
ProcessChangesWithDuplicateKeywordsLocalWins) { … }
TEST_F(TemplateURLServiceSyncTest, ProcessTemplateURLChange) { … }
TEST_F(TemplateURLServiceSyncTest, ProcessChangesWithLocalExtensions) { … }
TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordMigrated) { … }
TEST_F(TemplateURLServiceSyncTest, AutogeneratedKeywordConflicts) { … }
TEST_F(TemplateURLServiceSyncTest, DuplicateEncodingsRemoved) { … }
TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsBasic) { … }
TEST_F(TemplateURLServiceSyncTest, MergeTwoClientsDupesAndConflicts) { … }
TEST_F(TemplateURLServiceSyncTest, StopSyncing) { … }
TEST_F(TemplateURLServiceSyncTest, SyncErrorOnInitialSync) { … }
TEST_F(TemplateURLServiceSyncTest, SyncErrorOnLaterSync) { … }
TEST_F(TemplateURLServiceSyncTest, MergeTwiceWithSameSyncData) { … }
TEST_F(TemplateURLServiceSyncTest, SyncedDefaultGUIDArrivesFirst) { … }
TEST_F(TemplateURLServiceSyncTest, DefaultGuidDeletedBeforeNewDSPArrives) { … }
TEST_F(TemplateURLServiceSyncTest,
DefaultGuidDeletedAndUpdatedBeforeNewDSPArrives) { … }
TEST_F(TemplateURLServiceSyncTest, SyncedDefaultArrivesAfterStartup) { … }
TEST_F(TemplateURLServiceSyncTest, SyncedDefaultAlreadySetOnStartup) { … }
TEST_F(TemplateURLServiceSyncTest, SyncWithManagedDefaultSearch) { … }
TEST_F(TemplateURLServiceSyncTest, SyncWithExtensionDefaultSearch) { … }
TEST_F(TemplateURLServiceSyncTest, OverrideSyncPrefWithExtensionDefaultSearch) { … }
TEST_F(TemplateURLServiceSyncTest, ExtensionAndNormalEngineConflict) { … }
TEST_F(TemplateURLServiceSyncTest, SyncMergeDeletesDefault) { … }
TEST_F(TemplateURLServiceSyncTest, LocalDefaultWinsConflict) { … }
TEST_F(TemplateURLServiceSyncTest, DeleteBogusData) { … }
TEST_F(TemplateURLServiceSyncTest, PreSyncDeletes) { … }
TEST_F(TemplateURLServiceSyncTest, PreSyncUpdates) { … }
TEST_F(TemplateURLServiceSyncTest, SyncBaseURLs) { … }
TEST_F(TemplateURLServiceSyncTest, MergeInSyncTemplateURL) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, AddPrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, UpdatePrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, MergeEditedPrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, MergeConflictingPrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngineWithChangedKeyword) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Pref_Change_Add) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Pref_Add_Change) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Change_Add_Pref) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngine_Add_Change_Pref) { … }
TEST_F(TemplateURLServiceSyncTest, MergeNonEditedPrepopulatedEngine) { … }
TEST_F(TemplateURLServiceSyncTest, MergePrepopulatedEngineIgnoresId0) { … }
TEST_F(TemplateURLServiceSyncTest, MergeStarterPackEngine) { … }
TEST_F(TemplateURLServiceSyncTest, GUIDUpdatedOnDefaultSearchChange) { … }
TEST_F(TemplateURLServiceSyncTest, NonAsciiKeywordDoesNotCrash) { … }