fake_sync_service.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2015 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. #ifndef COMPONENTS_SYNC_DRIVER_FAKE_SYNC_SERVICE_H_
  5. #define COMPONENTS_SYNC_DRIVER_FAKE_SYNC_SERVICE_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "components/sync/driver/sync_service.h"
  10. #include "google_apis/gaia/google_service_auth_error.h"
  11. #include "url/gurl.h"
  12. namespace syncer {
  13. // Minimal fake implementation of SyncService. All methods return inactive/
  14. // empty/null etc. Tests can subclass this to override the parts they need, but
  15. // should consider using TestSyncService instead.
  16. class FakeSyncService : public SyncService {
  17. public:
  18. FakeSyncService();
  19. ~FakeSyncService() override;
  20. // Dummy methods.
  21. // SyncService implementation.
  22. syncer::SyncUserSettings* GetUserSettings() override;
  23. const syncer::SyncUserSettings* GetUserSettings() const override;
  24. DisableReasonSet GetDisableReasons() const override;
  25. TransportState GetTransportState() const override;
  26. CoreAccountInfo GetAccountInfo() const override;
  27. bool HasSyncConsent() const override;
  28. bool IsLocalSyncEnabled() const override;
  29. void TriggerRefresh(const ModelTypeSet& types) override;
  30. ModelTypeSet GetActiveDataTypes() const override;
  31. void AddObserver(SyncServiceObserver* observer) override;
  32. void RemoveObserver(SyncServiceObserver* observer) override;
  33. bool HasObserver(const SyncServiceObserver* observer) const override;
  34. void OnDataTypeRequestsSyncStartup(ModelType type) override;
  35. void StopAndClear() override;
  36. ModelTypeSet GetPreferredDataTypes() const override;
  37. std::unique_ptr<SyncSetupInProgressHandle> GetSetupInProgressHandle()
  38. override;
  39. bool IsSetupInProgress() const override;
  40. GoogleServiceAuthError GetAuthError() const override;
  41. base::Time GetAuthErrorTime() const override;
  42. bool RequiresClientUpgrade() const override;
  43. void DataTypePreconditionChanged(syncer::ModelType type) override;
  44. SyncTokenStatus GetSyncTokenStatusForDebugging() const override;
  45. bool QueryDetailedSyncStatusForDebugging(SyncStatus* result) const override;
  46. base::Time GetLastSyncedTimeForDebugging() const override;
  47. SyncCycleSnapshot GetLastCycleSnapshotForDebugging() const override;
  48. std::unique_ptr<base::Value> GetTypeStatusMapForDebugging() const override;
  49. void GetEntityCountsForDebugging(
  50. base::OnceCallback<void(const std::vector<TypeEntitiesCount>&)> callback)
  51. const override;
  52. const GURL& GetSyncServiceUrlForDebugging() const override;
  53. std::string GetUnrecoverableErrorMessageForDebugging() const override;
  54. base::Location GetUnrecoverableErrorLocationForDebugging() const override;
  55. void AddProtocolEventObserver(ProtocolEventObserver* observer) override;
  56. void RemoveProtocolEventObserver(ProtocolEventObserver* observer) override;
  57. void GetAllNodesForDebugging(
  58. base::OnceCallback<void(base::Value::List)> callback) override;
  59. void SetInvalidationsForSessionsEnabled(bool enabled) override;
  60. void AddTrustedVaultDecryptionKeysFromWeb(
  61. const std::string& gaia_id,
  62. const std::vector<std::vector<uint8_t>>& keys,
  63. int last_key_version) override;
  64. void AddTrustedVaultRecoveryMethodFromWeb(
  65. const std::string& gaia_id,
  66. const std::vector<uint8_t>& public_key,
  67. int method_type_hint,
  68. base::OnceClosure callback) override;
  69. // KeyedService implementation.
  70. void Shutdown() override;
  71. private:
  72. GURL sync_service_url_;
  73. };
  74. } // namespace syncer
  75. #endif // COMPONENTS_SYNC_DRIVER_FAKE_SYNC_SERVICE_H_