From 59a55e376e6bf0c1925e46e71a62bd0df4eb4ded Mon Sep 17 00:00:00 2001 From: Jagadesh P Date: Thu, 19 Dec 2024 00:32:59 +0530 Subject: [PATCH] [Android][Sync] Add unit test for setting and resetting custom sync service URL --- .../brave_sync_service_impl_unittest.cc | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/sync/service/brave_sync_service_impl_unittest.cc b/components/sync/service/brave_sync_service_impl_unittest.cc index 635ec58337eb..f0bfea115810 100644 --- a/components/sync/service/brave_sync_service_impl_unittest.cc +++ b/components/sync/service/brave_sync_service_impl_unittest.cc @@ -714,6 +714,31 @@ TEST_F(BraveSyncServiceImplTest, NoLeaveDetailsWhenInitializeIOS) { EXPECT_FALSE(brave_sync_prefs()->GetLeaveChainDetails().empty()); } +TEST_F(BraveSyncServiceImplTest, SetsAndResetsCustomSyncServiceUrl) { + CreateSyncService(); + + // Ensure the default sync service URL is set + GURL default_service_url = + brave_sync_service_impl()->GetBraveSyncServiceURL(); + EXPECT_FALSE(default_service_url.is_empty()); + + // Set a custom sync service URL + GURL custom_sync_url("https://sync.example.com/v2"); + EXPECT_TRUE(brave_sync_service_impl()->SetCustomSyncServiceURL( + custom_sync_url.spec())); + + // Verify that the custom URL is set correctly + EXPECT_EQ(brave_sync_service_impl()->GetBraveSyncServiceURL(), + custom_sync_url); + + // Reset to the default sync service URL + EXPECT_TRUE(brave_sync_service_impl()->SetCustomSyncServiceURL("")); + + // Verify that the sync service URL is reset to the default + EXPECT_EQ(brave_sync_service_impl()->GetBraveSyncServiceURL(), + default_service_url); +} + namespace { enum class GACookiesMethodType { kOnAccountsCookieDeletedByUserAction,