OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/test_profile_sync_service.h" | 5 #include "chrome/browser/sync/test_profile_sync_service.h" |
6 | 6 |
7 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 7 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
8 #include "chrome/browser/sync/engine/syncapi.h" | 8 #include "chrome/browser/sync/engine/syncapi.h" |
9 #include "chrome/browser/sync/glue/data_type_controller.h" | 9 #include "chrome/browser/sync/glue/data_type_controller.h" |
10 #include "chrome/browser/sync/glue/sync_backend_host.h" | 10 #include "chrome/browser/sync/glue/sync_backend_host.h" |
11 #include "chrome/browser/sync/profile_sync_factory.h" | 11 #include "chrome/browser/sync/profile_sync_factory.h" |
12 #include "chrome/browser/sync/sessions/session_state.h" | 12 #include "chrome/browser/sync/sessions/session_state.h" |
13 #include "chrome/browser/sync/syncable/directory_manager.h" | 13 #include "chrome/browser/sync/syncable/directory_manager.h" |
14 #include "chrome/browser/sync/syncable/syncable.h" | 14 #include "chrome/browser/sync/syncable/syncable.h" |
15 #include "chrome/test/sync/test_http_bridge_factory.h" | 15 #include "chrome/test/sync/test_http_bridge_factory.h" |
16 | 16 |
17 using browser_sync::ModelSafeRoutingInfo; | 17 using browser_sync::ModelSafeRoutingInfo; |
18 using browser_sync::sessions::ErrorCounters; | 18 using browser_sync::sessions::ErrorCounters; |
19 using browser_sync::sessions::SyncSourceInfo; | 19 using browser_sync::sessions::SyncSourceInfo; |
20 using browser_sync::sessions::SyncerStatus; | 20 using browser_sync::sessions::SyncerStatus; |
21 using browser_sync::sessions::SyncSessionSnapshot; | 21 using browser_sync::sessions::SyncSessionSnapshot; |
22 using syncable::DirectoryManager; | 22 using syncable::DirectoryManager; |
23 using syncable::ModelType; | 23 using syncable::ModelType; |
24 using syncable::ScopedDirLookup; | 24 using syncable::ScopedDirLookup; |
25 using sync_api::UserShare; | 25 using sync_api::UserShare; |
26 | 26 |
27 ACTION_P(CallOnPaused, core) { | |
28 core->OnPaused(); | |
29 }; | |
30 | |
31 ACTION_P(CallOnResumed, core) { | |
32 core->OnResumed(); | |
33 } | |
34 | |
35 namespace browser_sync { | 27 namespace browser_sync { |
36 | 28 |
37 using ::testing::_; | 29 using ::testing::_; |
38 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 30 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
39 Profile* profile, | 31 Profile* profile, |
40 bool set_initial_sync_ended_on_init, | 32 bool set_initial_sync_ended_on_init, |
41 bool synchronous_init) | 33 bool synchronous_init) |
42 : browser_sync::SyncBackendHost(profile), | 34 : browser_sync::SyncBackendHost(profile), |
43 synchronous_init_(synchronous_init) { | 35 synchronous_init_(synchronous_init) { |
44 // By default, the RequestPause and RequestResume methods will | |
45 // send the confirmation notification and return true. | |
46 ON_CALL(*this, RequestPause()). | |
47 WillByDefault(testing::DoAll(CallOnPaused(core_), | |
48 testing::Return(true))); | |
49 ON_CALL(*this, RequestResume()). | |
50 WillByDefault(testing::DoAll(CallOnResumed(core_), | |
51 testing::Return(true))); | |
52 ON_CALL(*this, RequestNudge(_)).WillByDefault( | 36 ON_CALL(*this, RequestNudge(_)).WillByDefault( |
53 testing::Invoke(this, | 37 testing::Invoke(this, |
54 &SyncBackendHostForProfileSyncTest:: | 38 &SyncBackendHostForProfileSyncTest:: |
55 SimulateSyncCycleCompletedInitialSyncEnded)); | 39 SimulateSyncCycleCompletedInitialSyncEnded)); |
56 | |
57 EXPECT_CALL(*this, RequestPause()).Times(testing::AnyNumber()); | |
58 EXPECT_CALL(*this, RequestResume()).Times(testing::AnyNumber()); | |
59 EXPECT_CALL(*this, RequestNudge(_)).Times(testing::AnyNumber()); | 40 EXPECT_CALL(*this, RequestNudge(_)).Times(testing::AnyNumber()); |
60 } | 41 } |
61 | 42 |
62 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
63 | 44 |
64 void SyncBackendHostForProfileSyncTest::ConfigureDataTypes( | 45 void SyncBackendHostForProfileSyncTest::ConfigureDataTypes( |
65 const DataTypeController::TypeMap& data_type_controllers, | 46 const DataTypeController::TypeMap& data_type_controllers, |
66 const syncable::ModelTypeSet& types, | 47 const syncable::ModelTypeSet& types, |
67 CancelableTask* ready_task) { | 48 CancelableTask* ready_task) { |
68 SetAutofillMigrationState(syncable::MIGRATED); | 49 SetAutofillMigrationState(syncable::MIGRATED); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 void TestProfileSyncService::CreateBackend() { | 249 void TestProfileSyncService::CreateBackend() { |
269 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 250 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
270 profile(), | 251 profile(), |
271 set_initial_sync_ended_on_init_, | 252 set_initial_sync_ended_on_init_, |
272 synchronous_backend_initialization_)); | 253 synchronous_backend_initialization_)); |
273 } | 254 } |
274 | 255 |
275 std::string TestProfileSyncService::GetLsidForAuthBootstraping() { | 256 std::string TestProfileSyncService::GetLsidForAuthBootstraping() { |
276 return "foo"; | 257 return "foo"; |
277 } | 258 } |
OLD | NEW |