Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/sync/test_profile_sync_service.cc

Issue 6380004: [Sync] Tidy up SyncBackendHost interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows compile Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 namespace browser_sync { 9 namespace browser_sync {
10 10
11 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( 11 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest(
12 TestProfileSyncService* service, 12 TestProfileSyncService* service,
13 Profile* profile, 13 Profile* profile,
14 const FilePath& profile_path,
15 const DataTypeController::TypeMap& data_type_controllers,
16 Task* initial_condition_setup_task, 14 Task* initial_condition_setup_task,
17 int num_expected_resumes, 15 int num_expected_resumes,
18 int num_expected_pauses, 16 int num_expected_pauses,
19 bool set_initial_sync_ended_on_init, 17 bool set_initial_sync_ended_on_init,
20 bool synchronous_init) 18 bool synchronous_init)
21 : browser_sync::SyncBackendHost(service, profile, profile_path, 19 : browser_sync::SyncBackendHost(service, profile),
22 data_type_controllers),
23 initial_condition_setup_task_(initial_condition_setup_task), 20 initial_condition_setup_task_(initial_condition_setup_task),
24 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), 21 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init),
25 synchronous_init_(synchronous_init), 22 synchronous_init_(synchronous_init),
26 test_service_(service) { 23 test_service_(service) {
27 // By default, the RequestPause and RequestResume methods will 24 // By default, the RequestPause and RequestResume methods will
28 // send the confirmation notification and return true. 25 // send the confirmation notification and return true.
29 ON_CALL(*this, RequestPause()). 26 ON_CALL(*this, RequestPause()).
30 WillByDefault(testing::DoAll(CallOnPaused(core_), 27 WillByDefault(testing::DoAll(CallOnPaused(core_),
31 testing::Return(true))); 28 testing::Return(true)));
32 ON_CALL(*this, RequestResume()). 29 ON_CALL(*this, RequestResume()).
33 WillByDefault(testing::DoAll(CallOnResumed(core_), 30 WillByDefault(testing::DoAll(CallOnResumed(core_),
34 testing::Return(true))); 31 testing::Return(true)));
35 ON_CALL(*this, RequestNudge()).WillByDefault( 32 ON_CALL(*this, RequestNudge()).WillByDefault(
36 testing::Invoke(this, 33 testing::Invoke(this,
37 &SyncBackendHostForProfileSyncTest:: 34 &SyncBackendHostForProfileSyncTest::
38 SimulateSyncCycleCompletedInitialSyncEnded)); 35 SimulateSyncCycleCompletedInitialSyncEnded));
39 36
40 EXPECT_CALL(*this, RequestPause()).Times(num_expected_pauses); 37 EXPECT_CALL(*this, RequestPause()).Times(num_expected_pauses);
41 EXPECT_CALL(*this, RequestResume()).Times(num_expected_resumes); 38 EXPECT_CALL(*this, RequestResume()).Times(num_expected_resumes);
42 EXPECT_CALL(*this, 39 EXPECT_CALL(*this,
43 RequestNudge()).Times(set_initial_sync_ended_on_init ? 0 : 1); 40 RequestNudge()).Times(set_initial_sync_ended_on_init ? 0 : 1);
44 } 41 }
45 42
46 void 43 void
47 SyncBackendHostForProfileSyncTest::HandleInitializationCompletedOnFrontendLoop() { 44 SyncBackendHostForProfileSyncTest::
48 set_syncapi_initialized(); // Need to do this asap so task below works. 45 HandleInitializationCompletedOnFrontendLoop() {
tim (not reviewing) 2011/01/19 20:42:53 hmm.. I thought the consensus for this was to not
46 set_syncapi_initialized(); // Need to do this asap so task below works.
49 47
50 // Set up any nodes the test wants around before model association. 48 // Set up any nodes the test wants around before model association.
51 if (initial_condition_setup_task_) { 49 if (initial_condition_setup_task_) {
52 initial_condition_setup_task_->Run(); 50 initial_condition_setup_task_->Run();
51 }
52
53 // Pretend we downloaded initial updates and set initial sync ended bits
54 // if we were asked to.
55 if (set_initial_sync_ended_on_init_) {
56 UserShare* user_share = core_->syncapi()->GetUserShare();
57 DirectoryManager* dir_manager = user_share->dir_manager.get();
58
59 ScopedDirLookup dir(dir_manager, user_share->name);
60 if (!dir.good())
61 FAIL();
62
63 if (!dir->initial_sync_ended_for_type(syncable::NIGORI)) {
64 ProfileSyncServiceTestHelper::CreateRoot(
65 syncable::NIGORI, test_service_, test_service_->id_factory());
53 } 66 }
54 67
55 // Pretend we downloaded initial updates and set initial sync ended bits 68 SetInitialSyncEndedForEnabledTypes();
56 // if we were asked to.
57 if (set_initial_sync_ended_on_init_) {
58 UserShare* user_share = core_->syncapi()->GetUserShare();
59 DirectoryManager* dir_manager = user_share->dir_manager.get();
60
61 ScopedDirLookup dir(dir_manager, user_share->name);
62 if (!dir.good())
63 FAIL();
64
65 if (!dir->initial_sync_ended_for_type(syncable::NIGORI)) {
66 ProfileSyncServiceTestHelper::CreateRoot(
67 syncable::NIGORI, test_service_, test_service_->id_factory());
68 }
69
70 SetInitialSyncEndedForEnabledTypes();
71 }
72
73 SyncBackendHost::HandleInitializationCompletedOnFrontendLoop();
74 } 69 }
75 70
71 SyncBackendHost::HandleInitializationCompletedOnFrontendLoop();
72 }
76 73
74 } // namespace browser_sync
77 75
78 } // namespace 76 void TestProfileSyncService::CreateBackend() {
77 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest(
78 this, profile(),
79 initial_condition_setup_task_.release(),
80 num_expected_resumes_, num_expected_pauses_,
81 set_initial_sync_ended_on_init_,
82 synchronous_backend_initialization_));
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698