| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/sync/glue/data_type_manager_impl.h" | 13 #include "chrome/browser/sync/glue/data_type_manager_impl.h" |
| 14 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 14 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 15 #include "chrome/browser/sync/profile_sync_service.h" | 15 #include "chrome/browser/sync/profile_sync_service.h" |
| 16 #include "chrome/browser/sync/sync_prefs.h" | 16 #include "chrome/browser/sync/sync_prefs.h" |
| 17 #include "chrome/test/base/profile_mock.h" | 17 #include "chrome/test/base/profile_mock.h" |
| 18 #include "sync/internal_api/public/test/test_internal_components_factory.h" |
| 18 #include "sync/test/engine/test_id_factory.h" | 19 #include "sync/test/engine/test_id_factory.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 | 21 |
| 21 class Profile; | 22 class Profile; |
| 22 class Task; | 23 class Task; |
| 23 class TestProfileSyncService; | 24 class TestProfileSyncService; |
| 24 | 25 |
| 25 ACTION(ReturnNewDataTypeManager) { | 26 ACTION(ReturnNewDataTypeManager) { |
| 26 return new browser_sync::DataTypeManagerImpl(arg0, arg1); | 27 return new browser_sync::DataTypeManagerImpl(arg0, arg1); |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace browser_sync { | 30 namespace browser_sync { |
| 30 | 31 |
| 31 class SyncBackendHostForProfileSyncTest : public SyncBackendHost { | 32 class SyncBackendHostForProfileSyncTest : public SyncBackendHost { |
| 32 public: | 33 public: |
| 33 // |synchronous_init| causes initialization to block until the syncapi has | 34 // |synchronous_init| causes initialization to block until the syncapi has |
| 34 // completed setting itself up and called us back. | 35 // completed setting itself up and called us back. |
| 35 SyncBackendHostForProfileSyncTest( | 36 SyncBackendHostForProfileSyncTest( |
| 36 Profile* profile, | 37 Profile* profile, |
| 37 const base::WeakPtr<SyncPrefs>& sync_prefs, | 38 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 38 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, | 39 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, |
| 39 syncer::TestIdFactory& id_factory, | 40 syncer::TestIdFactory& id_factory, |
| 40 base::Closure& callback, | 41 base::Closure& callback, |
| 41 bool set_initial_sync_ended_on_init, | 42 bool set_initial_sync_ended_on_init, |
| 42 bool synchronous_init, | 43 bool synchronous_init, |
| 43 bool fail_initial_download, | 44 bool fail_initial_download, |
| 44 bool use_real_database); | 45 syncer::StorageOption storage_option); |
| 45 virtual ~SyncBackendHostForProfileSyncTest(); | 46 virtual ~SyncBackendHostForProfileSyncTest(); |
| 46 | 47 |
| 47 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); | 48 MOCK_METHOD1(RequestNudge, void(const tracked_objects::Location&)); |
| 48 | 49 |
| 49 virtual void RequestConfigureSyncer( | 50 virtual void RequestConfigureSyncer( |
| 50 syncer::ConfigureReason reason, | 51 syncer::ConfigureReason reason, |
| 51 syncer::ModelTypeSet types_to_config, | 52 syncer::ModelTypeSet types_to_config, |
| 52 const syncer::ModelSafeRoutingInfo& routing_info, | 53 const syncer::ModelSafeRoutingInfo& routing_info, |
| 53 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 54 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
| 54 const base::Closure& retry_callback) OVERRIDE; | 55 const base::Closure& retry_callback) OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 protected: | 66 protected: |
| 66 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE; | 67 virtual void InitCore(const DoInitializeOptions& options) OVERRIDE; |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 syncer::TestIdFactory& id_factory_; | 70 syncer::TestIdFactory& id_factory_; |
| 70 base::Closure& callback_; | 71 base::Closure& callback_; |
| 71 | 72 |
| 72 bool set_initial_sync_ended_on_init_; | 73 bool set_initial_sync_ended_on_init_; |
| 73 bool synchronous_init_; | 74 bool synchronous_init_; |
| 74 bool fail_initial_download_; | 75 bool fail_initial_download_; |
| 75 bool use_real_database_; | 76 syncer::StorageOption storage_option_; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace browser_sync | 79 } // namespace browser_sync |
| 79 | 80 |
| 80 class TestProfileSyncService : public ProfileSyncService { | 81 class TestProfileSyncService : public ProfileSyncService { |
| 81 public: | 82 public: |
| 82 // |callback| can be used to populate nodes before the OnBackendInitialized | 83 // |callback| can be used to populate nodes before the OnBackendInitialized |
| 83 // callback fires. | 84 // callback fires. |
| 84 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to | 85 // TODO(tim): Remove |synchronous_backend_initialization|, and add ability to |
| 85 // inject TokenService alongside SigninManager. | 86 // inject TokenService alongside SigninManager. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 // We implement our own version to avoid some DCHECKs. | 105 // We implement our own version to avoid some DCHECKs. |
| 105 virtual syncer::UserShare* GetUserShare() const OVERRIDE; | 106 virtual syncer::UserShare* GetUserShare() const OVERRIDE; |
| 106 | 107 |
| 107 // If this is called, configuring data types will require a syncer | 108 // If this is called, configuring data types will require a syncer |
| 108 // nudge. | 109 // nudge. |
| 109 void dont_set_initial_sync_ended_on_init(); | 110 void dont_set_initial_sync_ended_on_init(); |
| 110 void set_synchronous_sync_configuration(); | 111 void set_synchronous_sync_configuration(); |
| 111 | 112 |
| 112 void fail_initial_download(); | 113 void fail_initial_download(); |
| 113 void set_use_real_database(); | 114 void set_storage_option(syncer::StorageOption option); |
| 114 | 115 |
| 115 syncer::TestIdFactory* id_factory(); | 116 syncer::TestIdFactory* id_factory(); |
| 116 | 117 |
| 117 // Override of ProfileSyncService::GetBackendForTest() with a more | 118 // Override of ProfileSyncService::GetBackendForTest() with a more |
| 118 // specific return type (since C++ supports covariant return types) | 119 // specific return type (since C++ supports covariant return types) |
| 119 // that is made public. | 120 // that is made public. |
| 120 virtual browser_sync::SyncBackendHostForProfileSyncTest* | 121 virtual browser_sync::SyncBackendHostForProfileSyncTest* |
| 121 GetBackendForTest() OVERRIDE; | 122 GetBackendForTest() OVERRIDE; |
| 122 | 123 |
| 123 protected: | 124 protected: |
| 124 virtual void CreateBackend() OVERRIDE; | 125 virtual void CreateBackend() OVERRIDE; |
| 125 | 126 |
| 126 private: | 127 private: |
| 127 syncer::TestIdFactory id_factory_; | 128 syncer::TestIdFactory id_factory_; |
| 128 | 129 |
| 129 bool synchronous_backend_initialization_; | 130 bool synchronous_backend_initialization_; |
| 130 | 131 |
| 131 // Set to true when a mock data type manager is being used and the configure | 132 // Set to true when a mock data type manager is being used and the configure |
| 132 // step is performed synchronously. | 133 // step is performed synchronously. |
| 133 bool synchronous_sync_configuration_; | 134 bool synchronous_sync_configuration_; |
| 134 | 135 |
| 135 base::Closure callback_; | 136 base::Closure callback_; |
| 136 bool set_initial_sync_ended_on_init_; | 137 bool set_initial_sync_ended_on_init_; |
| 137 | 138 |
| 138 bool fail_initial_download_; | 139 bool fail_initial_download_; |
| 139 bool use_real_database_; | 140 syncer::StorageOption storage_option_; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ | 143 #endif // CHROME_BROWSER_SYNC_TEST_PROFILE_SYNC_SERVICE_H_ |
| OLD | NEW |