OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "sync/internal_api/public/sync_manager.h" |
| 11 |
| 12 #include "base/observer_list.h" |
| 13 |
| 14 namespace syncer { |
| 15 |
| 16 class FakeSyncManager : public SyncManager { |
| 17 public: |
| 18 explicit FakeSyncManager(std::string name); |
| 19 virtual ~FakeSyncManager(); |
| 20 |
| 21 // The set of types that have initial_sync_ended set to true. This value will |
| 22 // be used by InitialSyncEndedTypes() until the next configuration is |
| 23 // performed. |
| 24 void set_initial_sync_ended_types(syncer::ModelTypeSet types); |
| 25 |
| 26 // The set of types that have valid progress markers. This will be used by |
| 27 // GetTypesWithEmptyProgressMarkerToken() until the next configuration is |
| 28 // performed. |
| 29 void set_progress_marker_types(syncer::ModelTypeSet types); |
| 30 |
| 31 // The set of types that will fail configuration. Once ConfigureSyncer is |
| 32 // called, the |initial_sync_ended_types_| and |
| 33 // |progress_marker_types_| will be updated to include those types |
| 34 // that didn't fail. |
| 35 void set_configure_fail_types(syncer::ModelTypeSet types); |
| 36 |
| 37 // Returns those types that have been cleaned (purged from the directory) |
| 38 // since the last call to GetAndResetCleanedTypes(), or since startup if never |
| 39 // called. |
| 40 syncer::ModelTypeSet GetAndResetCleanedTypes(); |
| 41 |
| 42 // Returns those types that have been downloaded since the last call to |
| 43 // GetAndResetDownloadedTypes(), or since startup if never called. |
| 44 syncer::ModelTypeSet GetAndResetDownloadedTypes(); |
| 45 |
| 46 // SyncManager overrides. |
| 47 virtual bool Init( |
| 48 const FilePath& database_location, |
| 49 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 50 const std::string& sync_server_and_path, |
| 51 int sync_server_port, |
| 52 bool use_ssl, |
| 53 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| 54 scoped_ptr<HttpPostProviderFactory> post_factory, |
| 55 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, |
| 56 const std::vector<syncer::ModelSafeWorker*>& workers, |
| 57 syncer::ExtensionsActivityMonitor* |
| 58 extensions_activity_monitor, |
| 59 ChangeDelegate* change_delegate, |
| 60 const SyncCredentials& credentials, |
| 61 scoped_ptr<syncer::SyncNotifier> sync_notifier, |
| 62 const std::string& restored_key_for_bootstrapping, |
| 63 TestingMode testing_mode, |
| 64 syncer::Encryptor* encryptor, |
| 65 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 66 syncer::ReportUnrecoverableErrorFunction |
| 67 report_unrecoverable_error_function) OVERRIDE; |
| 68 virtual syncer::ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
| 69 virtual syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 70 syncer::ModelTypeSet types) OVERRIDE; |
| 71 virtual void UpdateEnabledTypes(const syncer::ModelTypeSet& types) OVERRIDE; |
| 72 virtual void ConfigureSyncer( |
| 73 ConfigureReason reason, |
| 74 const syncer::ModelTypeSet& types_to_config, |
| 75 const syncer::ModelSafeRoutingInfo& new_routing_info, |
| 76 const base::Closure& ready_task, |
| 77 const base::Closure& retry_task) OVERRIDE; |
| 78 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 79 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 80 virtual void ShutdownOnSyncThread() OVERRIDE; |
| 81 virtual void RefreshNigori(const std::string& chrome_version, |
| 82 const base::Closure& done_callback) OVERRIDE; |
| 83 virtual bool ReceivedExperiment( |
| 84 syncer::Experiments* experiments) const OVERRIDE; |
| 85 |
| 86 private: |
| 87 ObserverList<SyncManager::Observer> observers_; |
| 88 |
| 89 // Faked directory state. |
| 90 syncer::ModelTypeSet initial_sync_ended_types_; |
| 91 syncer::ModelTypeSet progress_marker_types_; |
| 92 |
| 93 // Test specific state. |
| 94 // The types that should fail configuration attempts. These types will not |
| 95 // have their progress markers or initial_sync_ended bits set. |
| 96 syncer::ModelTypeSet configure_fail_types_; |
| 97 // The set of types that have been cleaned up. |
| 98 syncer::ModelTypeSet cleaned_types_; |
| 99 // The set of types that have been downloaded. |
| 100 syncer::ModelTypeSet downloaded_types_; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); |
| 103 }; |
| 104 |
| 105 } // namespace syncer |
| 106 |
| 107 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
OLD | NEW |