#include "chrome/browser/sync/test/integration/sync_test.h"
#include <utility>
#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/containers/to_vector.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/gcm/instance_id/instance_id_profile_service_factory.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/sync/test/integration/committed_all_nudged_changes_checker.h"
#include "chrome/browser/sync/test/integration/device_info_helper.h"
#include "chrome/browser/sync/test/integration/fake_sync_gcm_driver_for_instance_id.h"
#include "chrome/browser/sync/test/integration/session_hierarchy_match_checker.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_disabled_checker.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_service_impl_harness.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "components/browser_sync/browser_sync_switches.h"
#include "components/gcm_driver/fake_gcm_profile_service.h"
#include "components/gcm_driver/gcm_profile_service.h"
#include "components/gcm_driver/instance_id/instance_id.h"
#include "components/gcm_driver/instance_id/instance_id_driver.h"
#include "components/gcm_driver/instance_id/instance_id_profile_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/os_crypt/sync/os_crypt_mocker.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/sync/base/command_line_switches.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/engine/sync_protocol_error.h"
#include "components/sync/engine/sync_scheduler_impl.h"
#include "components/sync/invalidations/sync_invalidations_service_impl.h"
#include "components/sync/service/glue/sync_transport_data_prefs.h"
#include "components/sync/service/sync_service_impl.h"
#include "components/sync/service/sync_user_settings.h"
#include "components/sync/test/fake_server_network_resources.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/port_util.h"
#include "net/dns/mock_host_resolver.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
#include "url/url_constants.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/test/arc_util_test_support.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs_factory.h"
#include "chrome/browser/ash/app_list/test/fake_app_list_model_updater.h"
#include "chrome/browser/sync/test/integration/sync_arc_package_helper.h"
#include "chromeos/ash/components/account_manager/account_manager_factory.h"
#include "components/account_manager_core/chromeos/account_manager.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "components/account_manager_core/chromeos/account_manager.h"
#include "components/account_manager_core/chromeos/account_manager_facade_factory.h"
#endif
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/sync/test/integration/sync_test_utils_android.h"
#else
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "components/trusted_vault/command_line_switches.h"
#endif
SyncServiceImpl;
namespace {
void SetURLLoaderFactoryForTest(
Profile* profile,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
}
#if !BUILDFLAG(IS_ANDROID)
class SyncTest::ClosedBrowserObserver : public BrowserListObserver { … };
#endif
SyncTest::SyncTest(TestType test_type)
: … { … }
SyncTest::~SyncTest() = default;
void SyncTest::SetUp() { … }
void SyncTest::TearDown() { … }
void SyncTest::PostRunTestOnMainThread() { … }
void SyncTest::SetUpCommandLine(base::CommandLine* cl) { … }
void SyncTest::BeforeSetupClient(int index,
const base::FilePath& profile_path) { … }
base::FilePath SyncTest::GetProfileBaseName(int index) { … }
bool SyncTest::CreateProfile(int index) { … }
Profile* SyncTest::GetProfile(int index) const { … }
std::vector<raw_ptr<Profile, VectorExperimental>> SyncTest::GetAllProfiles() { … }
#if !BUILDFLAG(IS_ANDROID)
Browser* SyncTest::GetBrowser(int index) { … }
Browser* SyncTest::AddBrowser(int profile_index) { … }
void SyncTest::OnBrowserRemoved(Browser* browser) { … }
#endif
SyncServiceImplHarness* SyncTest::GetClient(int index) { … }
const SyncServiceImplHarness* SyncTest::GetClient(int index) const { … }
std::vector<SyncServiceImplHarness*> SyncTest::GetSyncClients() { … }
SyncServiceImpl* SyncTest::GetSyncService(int index) const { … }
syncer::UserSelectableTypeSet SyncTest::GetRegisteredSelectableTypes(
int index) { … }
std::vector<raw_ptr<SyncServiceImpl, VectorExperimental>>
SyncTest::GetSyncServices() { … }
Profile* SyncTest::verifier() { … }
bool SyncTest::UseVerifier() { … }
bool SyncTest::SetupClients() { … }
void SyncTest::InitializeProfile(int index, Profile* profile) { … }
void SyncTest::SetupMockGaiaResponsesForProfile(Profile* profile) { … }
void SyncTest::SetupSyncInternal(SetupSyncMode setup_mode) { … }
bool SyncTest::SetupSync(SetupSyncMode setup_mode) { … }
void SyncTest::TearDownOnMainThread() { … }
void SyncTest::SetUpInProcessBrowserTestFixture() { … }
void SyncTest::OnProfileWillBeDestroyed(Profile* profile) { … }
void SyncTest::OnWillCreateBrowserContextServices(
content::BrowserContext* context) { … }
std::unique_ptr<KeyedService> SyncTest::CreateGCMProfileService(
content::BrowserContext* context) { … }
void SyncTest::ResetSyncForPrimaryAccount() { … }
void SyncTest::SetUpOnMainThread() { … }
void SyncTest::WaitForDataModels(Profile* profile) { … }
void SyncTest::ReadPasswordFile() { … }
void SyncTest::SetupMockGaiaResponses() { … }
void SyncTest::SetOAuth2TokenResponse(const std::string& response_data,
net::HttpStatusCode status_code,
net::Error net_error) { … }
void SyncTest::ClearMockGaiaResponses() { … }
bool SyncTest::TestUsesSelfNotifications() { … }
bool SyncTest::AwaitQuiescence() { … }
void SyncTest::TriggerMigrationDoneError(syncer::DataTypeSet data_types) { … }
fake_server::FakeServer* SyncTest::GetFakeServer() const { … }
void SyncTest::TriggerSyncForDataTypes(int index,
syncer::DataTypeSet data_types) { … }
arc::SyncArcPackageHelper* SyncTest::sync_arc_helper() { … }
std::string SyncTest::GetCacheGuid(size_t profile_index) const { … }
bool SyncTest::WaitForAsyncChangesToBeCommitted(size_t profile_index) const { … }
void SyncTest::CheckForDataTypeFailures(size_t client_index) const { … }
void SyncTest::ExcludeDataTypesFromCheckForDataTypeFailures(
syncer::DataTypeSet types) { … }
syncer::DataTypeSet AllowedTypesInStandaloneTransportMode() { … }