sync_service_impl_bundle.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/sync/driver/sync_service_impl_bundle.h"
  5. #include <string>
  6. #include <utility>
  7. #include "components/pref_registry/pref_registry_syncable.h"
  8. #include "components/sync/base/sync_prefs.h"
  9. #include "services/network/public/cpp/shared_url_loader_factory.h"
  10. #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
  11. #include "services/network/test/test_network_connection_tracker.h"
  12. #include "services/network/test/test_url_loader_factory.h"
  13. #include "testing/gmock/include/gmock/gmock.h"
  14. namespace syncer {
  15. using testing::Return;
  16. SyncServiceImplBundle::SyncServiceImplBundle()
  17. : identity_test_env_(&test_url_loader_factory_) {
  18. SyncPrefs::RegisterProfilePrefs(pref_service_.registry());
  19. identity_test_env_.SetAutomaticIssueOfAccessTokens(true);
  20. }
  21. SyncServiceImplBundle::~SyncServiceImplBundle() = default;
  22. std::unique_ptr<SyncClientMock> SyncServiceImplBundle::CreateSyncClientMock() {
  23. auto sync_client = std::make_unique<testing::NiceMock<SyncClientMock>>();
  24. ON_CALL(*sync_client, GetPrefService()).WillByDefault(Return(&pref_service_));
  25. ON_CALL(*sync_client, GetSyncApiComponentFactory())
  26. .WillByDefault(Return(&component_factory_));
  27. ON_CALL(*sync_client, GetSyncInvalidationsService())
  28. .WillByDefault(Return(sync_invalidations_service()));
  29. ON_CALL(*sync_client, GetTrustedVaultClient())
  30. .WillByDefault(Return(trusted_vault_client()));
  31. return std::move(sync_client);
  32. }
  33. SyncServiceImpl::InitParams SyncServiceImplBundle::CreateBasicInitParams(
  34. SyncServiceImpl::StartBehavior start_behavior,
  35. std::unique_ptr<SyncClient> sync_client) {
  36. SyncServiceImpl::InitParams init_params;
  37. init_params.start_behavior = start_behavior;
  38. init_params.sync_client = std::move(sync_client);
  39. init_params.identity_manager = identity_manager();
  40. init_params.url_loader_factory =
  41. base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
  42. &test_url_loader_factory_);
  43. init_params.network_connection_tracker =
  44. network::TestNetworkConnectionTracker::GetInstance();
  45. init_params.debug_identifier = "dummyDebugName";
  46. return init_params;
  47. }
  48. } // namespace syncer