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 #include "components/browser_sync/abstract_profile_sync_service_test.h" | 5 #include "components/browser_sync/abstract_profile_sync_service_test.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "components/browser_sync/test_http_bridge_factory.h" | 15 #include "components/browser_sync/test_http_bridge_factory.h" |
16 #include "components/browser_sync/test_profile_sync_service.h" | 16 #include "components/browser_sync/test_profile_sync_service.h" |
17 #include "components/sync/core/test/sync_manager_factory_for_profile_sync_test.h
" | 17 #include "components/sync/core/test/sync_manager_factory_for_profile_sync_test.h
" |
18 #include "components/sync/core/test/test_internal_components_factory.h" | 18 #include "components/sync/core/test/test_internal_components_factory.h" |
19 #include "components/sync/core/test/test_user_share.h" | 19 #include "components/sync/core/test/test_user_share.h" |
20 #include "components/sync/driver/glue/sync_backend_host_core.h" | 20 #include "components/sync/driver/glue/sync_backend_host_core.h" |
21 #include "components/sync/driver/sync_api_component_factory_mock.h" | 21 #include "components/sync/driver/sync_api_component_factory_mock.h" |
22 #include "components/sync/protocol/sync.pb.h" | 22 #include "components/sync/protocol/sync.pb.h" |
23 #include "google_apis/gaia/gaia_constants.h" | 23 #include "google_apis/gaia/gaia_constants.h" |
24 | 24 |
25 using syncer::ModelType; | 25 using syncer::ModelType; |
26 using testing::_; | 26 using testing::_; |
27 using testing::Return; | 27 using testing::Return; |
28 | 28 |
| 29 namespace browser_sync { |
| 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 class SyncBackendHostForProfileSyncTest | 33 class SyncBackendHostForProfileSyncTest : public SyncBackendHostImpl { |
32 : public browser_sync::SyncBackendHostImpl { | |
33 public: | 34 public: |
34 SyncBackendHostForProfileSyncTest( | 35 SyncBackendHostForProfileSyncTest( |
35 const base::FilePath& temp_dir, | 36 const base::FilePath& temp_dir, |
36 sync_driver::SyncClient* sync_client, | 37 sync_driver::SyncClient* sync_client, |
37 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 38 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
38 invalidation::InvalidationService* invalidator, | 39 invalidation::InvalidationService* invalidator, |
39 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 40 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
40 const base::Closure& callback); | 41 const base::Closure& callback); |
41 ~SyncBackendHostForProfileSyncTest() override; | 42 ~SyncBackendHostForProfileSyncTest() override; |
42 | 43 |
43 void RequestConfigureSyncer( | 44 void RequestConfigureSyncer( |
44 syncer::ConfigureReason reason, | 45 syncer::ConfigureReason reason, |
45 syncer::ModelTypeSet to_download, | 46 syncer::ModelTypeSet to_download, |
46 syncer::ModelTypeSet to_purge, | 47 syncer::ModelTypeSet to_purge, |
47 syncer::ModelTypeSet to_journal, | 48 syncer::ModelTypeSet to_journal, |
48 syncer::ModelTypeSet to_unapply, | 49 syncer::ModelTypeSet to_unapply, |
49 syncer::ModelTypeSet to_ignore, | 50 syncer::ModelTypeSet to_ignore, |
50 const syncer::ModelSafeRoutingInfo& routing_info, | 51 const syncer::ModelSafeRoutingInfo& routing_info, |
51 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& | 52 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& |
52 ready_task, | 53 ready_task, |
53 const base::Closure& retry_callback) override; | 54 const base::Closure& retry_callback) override; |
54 | 55 |
55 protected: | 56 protected: |
56 void InitCore( | 57 void InitCore(std::unique_ptr<DoInitializeOptions> options) override; |
57 std::unique_ptr<browser_sync::DoInitializeOptions> options) override; | |
58 | 58 |
59 private: | 59 private: |
60 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop. | 60 // Invoked at the start of HandleSyncManagerInitializationOnFrontendLoop. |
61 // Allows extra initialization work to be performed before the backend comes | 61 // Allows extra initialization work to be performed before the backend comes |
62 // up. | 62 // up. |
63 base::Closure callback_; | 63 base::Closure callback_; |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostForProfileSyncTest); | 65 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostForProfileSyncTest); |
66 }; | 66 }; |
67 | 67 |
68 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 68 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
69 const base::FilePath& temp_dir, | 69 const base::FilePath& temp_dir, |
70 sync_driver::SyncClient* sync_client, | 70 sync_driver::SyncClient* sync_client, |
71 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 71 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
72 invalidation::InvalidationService* invalidator, | 72 invalidation::InvalidationService* invalidator, |
73 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 73 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
74 const base::Closure& callback) | 74 const base::Closure& callback) |
75 : browser_sync::SyncBackendHostImpl( | 75 : SyncBackendHostImpl( |
76 "dummy_debug_name", | 76 "dummy_debug_name", |
77 sync_client, | 77 sync_client, |
78 ui_thread, | 78 ui_thread, |
79 invalidator, | 79 invalidator, |
80 sync_prefs, | 80 sync_prefs, |
81 temp_dir.Append(base::FilePath(FILE_PATH_LITERAL("test")))), | 81 temp_dir.Append(base::FilePath(FILE_PATH_LITERAL("test")))), |
82 callback_(callback) {} | 82 callback_(callback) {} |
83 | 83 |
84 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 84 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
85 | 85 |
86 void SyncBackendHostForProfileSyncTest::InitCore( | 86 void SyncBackendHostForProfileSyncTest::InitCore( |
87 std::unique_ptr<browser_sync::DoInitializeOptions> options) { | 87 std::unique_ptr<DoInitializeOptions> options) { |
88 options->http_bridge_factory = | 88 options->http_bridge_factory = |
89 std::unique_ptr<syncer::HttpPostProviderFactory>( | 89 std::unique_ptr<syncer::HttpPostProviderFactory>( |
90 new browser_sync::TestHttpBridgeFactory()); | 90 new TestHttpBridgeFactory()); |
91 options->sync_manager_factory.reset( | 91 options->sync_manager_factory.reset( |
92 new syncer::SyncManagerFactoryForProfileSyncTest(callback_)); | 92 new syncer::SyncManagerFactoryForProfileSyncTest(callback_)); |
93 options->credentials.email = "testuser@gmail.com"; | 93 options->credentials.email = "testuser@gmail.com"; |
94 options->credentials.sync_token = "token"; | 94 options->credentials.sync_token = "token"; |
95 options->credentials.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); | 95 options->credentials.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); |
96 options->restored_key_for_bootstrapping.clear(); | 96 options->restored_key_for_bootstrapping.clear(); |
97 | 97 |
98 // It'd be nice if we avoided creating the InternalComponentsFactory in the | 98 // It'd be nice if we avoided creating the InternalComponentsFactory in the |
99 // first place, but SyncBackendHost will have created one by now so we must | 99 // first place, but SyncBackendHost will have created one by now so we must |
100 // free it. Grab the switches to pass on first. | 100 // free it. Grab the switches to pass on first. |
101 syncer::InternalComponentsFactory::Switches factory_switches = | 101 syncer::InternalComponentsFactory::Switches factory_switches = |
102 options->internal_components_factory->GetSwitches(); | 102 options->internal_components_factory->GetSwitches(); |
103 options->internal_components_factory.reset( | 103 options->internal_components_factory.reset( |
104 new syncer::TestInternalComponentsFactory( | 104 new syncer::TestInternalComponentsFactory( |
105 factory_switches, | 105 factory_switches, |
106 syncer::InternalComponentsFactory::STORAGE_IN_MEMORY, nullptr)); | 106 syncer::InternalComponentsFactory::STORAGE_IN_MEMORY, nullptr)); |
107 | 107 |
108 browser_sync::SyncBackendHostImpl::InitCore(std::move(options)); | 108 SyncBackendHostImpl::InitCore(std::move(options)); |
109 } | 109 } |
110 | 110 |
111 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( | 111 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
112 syncer::ConfigureReason reason, | 112 syncer::ConfigureReason reason, |
113 syncer::ModelTypeSet to_download, | 113 syncer::ModelTypeSet to_download, |
114 syncer::ModelTypeSet to_purge, | 114 syncer::ModelTypeSet to_purge, |
115 syncer::ModelTypeSet to_journal, | 115 syncer::ModelTypeSet to_journal, |
116 syncer::ModelTypeSet to_unapply, | 116 syncer::ModelTypeSet to_unapply, |
117 syncer::ModelTypeSet to_ignore, | 117 syncer::ModelTypeSet to_ignore, |
118 const syncer::ModelSafeRoutingInfo& routing_info, | 118 const syncer::ModelSafeRoutingInfo& routing_info, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 return callback_; | 227 return callback_; |
228 } | 228 } |
229 | 229 |
230 bool CreateRootHelper::success() { | 230 bool CreateRootHelper::success() { |
231 return success_; | 231 return success_; |
232 } | 232 } |
233 | 233 |
234 void CreateRootHelper::CreateRootCallback() { | 234 void CreateRootHelper::CreateRootCallback() { |
235 success_ = test_->CreateRoot(model_type_); | 235 success_ = test_->CreateRoot(model_type_); |
236 } | 236 } |
| 237 |
| 238 } // namespace browser_sync |
OLD | NEW |