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

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

Issue 3305003: New authorization framework for sync. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "chrome/browser/sessions/session_service.h" 13 #include "chrome/browser/sessions/session_service.h"
14 #include "chrome/browser/sessions/session_service_test_helper.h" 14 #include "chrome/browser/sessions/session_service_test_helper.h"
15 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 15 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
16 #include "chrome/browser/sync/engine/syncapi.h" 16 #include "chrome/browser/sync/engine/syncapi.h"
17 #include "chrome/browser/sync/glue/session_change_processor.h" 17 #include "chrome/browser/sync/glue/session_change_processor.h"
18 #include "chrome/browser/sync/glue/session_data_type_controller.h" 18 #include "chrome/browser/sync/glue/session_data_type_controller.h"
19 #include "chrome/browser/sync/glue/session_model_associator.h" 19 #include "chrome/browser/sync/glue/session_model_associator.h"
20 #include "chrome/browser/sync/glue/sync_backend_host.h" 20 #include "chrome/browser/sync/glue/sync_backend_host.h"
21 #include "chrome/browser/sync/profile_sync_test_util.h" 21 #include "chrome/browser/sync/profile_sync_test_util.h"
22 #include "chrome/browser/sync/profile_sync_factory_mock.h" 22 #include "chrome/browser/sync/profile_sync_factory_mock.h"
23 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 23 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
24 #include "chrome/browser/sync/protocol/sync.pb.h" 24 #include "chrome/browser/sync/protocol/sync.pb.h"
25 #include "chrome/browser/sync/syncable/directory_manager.h" 25 #include "chrome/browser/sync/syncable/directory_manager.h"
26 #include "chrome/browser/sync/syncable/model_type.h" 26 #include "chrome/browser/sync/syncable/model_type.h"
27 #include "chrome/browser/sync/syncable/syncable.h" 27 #include "chrome/browser/sync/syncable/syncable.h"
28 #include "chrome/browser/sync/test_profile_sync_service.h" 28 #include "chrome/browser/sync/test_profile_sync_service.h"
29 #include "chrome/common/net/gaia/gaia_constants.h"
29 #include "chrome/common/notification_observer.h" 30 #include "chrome/common/notification_observer.h"
30 #include "chrome/common/notification_registrar.h" 31 #include "chrome/common/notification_registrar.h"
31 #include "chrome/common/notification_service.h" 32 #include "chrome/common/notification_service.h"
32 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
33 #include "chrome/test/browser_with_test_window_test.h" 34 #include "chrome/test/browser_with_test_window_test.h"
34 #include "chrome/test/file_test_utils.h" 35 #include "chrome/test/file_test_utils.h"
35 #include "chrome/test/profile_mock.h" 36 #include "chrome/test/profile_mock.h"
36 #include "chrome/test/testing_profile.h" 37 #include "chrome/test/testing_profile.h"
37 #include "chrome/test/sync/engine/test_id_factory.h" 38 #include "chrome/test/sync/engine/test_id_factory.h"
38 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 helper_.set_service(NULL); 104 helper_.set_service(NULL);
104 profile()->set_session_service(NULL); 105 profile()->set_session_service(NULL);
105 sync_service_.reset(); 106 sync_service_.reset();
106 } 107 }
107 108
108 bool StartSyncService(Task* task, bool will_fail_association) { 109 bool StartSyncService(Task* task, bool will_fail_association) {
109 if (sync_service_.get()) 110 if (sync_service_.get())
110 return false; 111 return false;
111 112
112 sync_service_.reset(new TestProfileSyncService( 113 sync_service_.reset(new TestProfileSyncService(
113 &factory_, profile(), false, false, task)); 114 &factory_, profile(), "test user", false, task));
114 profile()->set_session_service(helper_.service()); 115 profile()->set_session_service(helper_.service());
115 116
116 // Register the session data type. 117 // Register the session data type.
117 model_associator_ = 118 model_associator_ =
118 new SessionModelAssociator(sync_service_.get()); 119 new SessionModelAssociator(sync_service_.get());
119 change_processor_ = new SessionChangeProcessor( 120 change_processor_ = new SessionChangeProcessor(
120 sync_service_.get(), model_associator_); 121 sync_service_.get(), model_associator_);
121 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). 122 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)).
122 WillOnce(Return(ProfileSyncFactory::SyncComponents( 123 WillOnce(Return(ProfileSyncFactory::SyncComponents(
123 model_associator_, change_processor_))); 124 model_associator_, change_processor_)));
124 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). 125 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)).
125 WillOnce(ReturnNewDataTypeManager()); 126 WillOnce(ReturnNewDataTypeManager());
126 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1); 127 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1);
127 sync_service_->RegisterDataTypeController( 128 sync_service_->RegisterDataTypeController(
128 new SessionDataTypeController(&factory_, sync_service_.get())); 129 new SessionDataTypeController(&factory_, sync_service_.get()));
130 profile()->GetTokenService()->IssueAuthTokenForTest(
131 GaiaConstants::kSyncService, "token");
129 sync_service_->Initialize(); 132 sync_service_->Initialize();
130 MessageLoop::current()->Run(); 133 MessageLoop::current()->Run();
131 return true; 134 return true;
132 } 135 }
133 136
134 SyncBackendHost* backend() { return sync_service_->backend(); } 137 SyncBackendHost* backend() { return sync_service_->backend(); }
135 138
136 // Path used in testing. 139 // Path used in testing.
137 ScopedTempDir temp_dir_; 140 ScopedTempDir temp_dir_;
138 SessionServiceTestHelper helper_; 141 SessionServiceTestHelper helper_;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 { 411 {
409 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); 412 sync_api::WriteTransaction trans(backend()->GetUserShareHandle());
410 change_processor_->ApplyChangesFromSyncModel(&trans, record.get(), 1); 413 change_processor_->ApplyChangesFromSyncModel(&trans, record.get(), 1);
411 } 414 }
412 ASSERT_EQ(notification_sync_id_, -1); 415 ASSERT_EQ(notification_sync_id_, -1);
413 ASSERT_TRUE(notified_of_update_); 416 ASSERT_TRUE(notified_of_update_);
414 } 417 }
415 418
416 } // namespace browser_sync 419 } // namespace browser_sync
417 420
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698