| 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 "chrome/browser/sync/glue/bookmark_data_type_controller.h" | 5 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 void Start() { | 157 void Start() { |
| 158 bookmark_dtc_->LoadModels( | 158 bookmark_dtc_->LoadModels( |
| 159 base::Bind(&ModelLoadCallbackMock::Run, | 159 base::Bind(&ModelLoadCallbackMock::Run, |
| 160 base::Unretained(&model_load_callback_))); | 160 base::Unretained(&model_load_callback_))); |
| 161 bookmark_dtc_->StartAssociating( | 161 bookmark_dtc_->StartAssociating( |
| 162 base::Bind(&StartCallbackMock::Run, | 162 base::Bind(&StartCallbackMock::Run, |
| 163 base::Unretained(&start_callback_))); | 163 base::Unretained(&start_callback_))); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void NotifyHistoryServiceLoaded() { |
| 167 history_service_->NotifyHistoryServiceLoaded(); |
| 168 } |
| 169 |
| 166 content::TestBrowserThreadBundle thread_bundle_; | 170 content::TestBrowserThreadBundle thread_bundle_; |
| 167 scoped_refptr<BookmarkDataTypeController> bookmark_dtc_; | 171 scoped_refptr<BookmarkDataTypeController> bookmark_dtc_; |
| 168 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; | 172 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; |
| 169 ProfileMock profile_; | 173 ProfileMock profile_; |
| 170 BookmarkModel* bookmark_model_; | 174 BookmarkModel* bookmark_model_; |
| 171 HistoryMock* history_service_; | 175 HistoryMock* history_service_; |
| 172 ProfileSyncServiceMock service_; | 176 ProfileSyncServiceMock service_; |
| 173 ModelAssociatorMock* model_associator_; | 177 ModelAssociatorMock* model_associator_; |
| 174 ChangeProcessorMock* change_processor_; | 178 ChangeProcessorMock* change_processor_; |
| 175 StartCallbackMock start_callback_; | 179 StartCallbackMock start_callback_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 227 |
| 224 bookmark_dtc_->LoadModels( | 228 bookmark_dtc_->LoadModels( |
| 225 base::Bind(&ModelLoadCallbackMock::Run, | 229 base::Bind(&ModelLoadCallbackMock::Run, |
| 226 base::Unretained(&model_load_callback_))); | 230 base::Unretained(&model_load_callback_))); |
| 227 | 231 |
| 228 EXPECT_EQ(DataTypeController::MODEL_STARTING, bookmark_dtc_->state()); | 232 EXPECT_EQ(DataTypeController::MODEL_STARTING, bookmark_dtc_->state()); |
| 229 testing::Mock::VerifyAndClearExpectations(history_service_); | 233 testing::Mock::VerifyAndClearExpectations(history_service_); |
| 230 EXPECT_CALL(*history_service_, BackendLoaded()).WillRepeatedly(Return(true)); | 234 EXPECT_CALL(*history_service_, BackendLoaded()).WillRepeatedly(Return(true)); |
| 231 | 235 |
| 232 // Send the notification that the history service has finished loading the db. | 236 // Send the notification that the history service has finished loading the db. |
| 233 content::NotificationService::current()->Notify( | 237 NotifyHistoryServiceLoaded(); |
| 234 chrome::NOTIFICATION_HISTORY_LOADED, | |
| 235 content::Source<Profile>(&profile_), | |
| 236 content::NotificationService::NoDetails()); | |
| 237 EXPECT_EQ(DataTypeController::MODEL_LOADED, bookmark_dtc_->state()); | 238 EXPECT_EQ(DataTypeController::MODEL_LOADED, bookmark_dtc_->state()); |
| 238 } | 239 } |
| 239 | 240 |
| 240 TEST_F(SyncBookmarkDataTypeControllerTest, StartFirstRun) { | 241 TEST_F(SyncBookmarkDataTypeControllerTest, StartFirstRun) { |
| 241 CreateBookmarkModel(LOAD_MODEL); | 242 CreateBookmarkModel(LOAD_MODEL); |
| 242 SetStartExpectations(); | 243 SetStartExpectations(); |
| 243 SetAssociateExpectations(); | 244 SetAssociateExpectations(); |
| 244 EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). | 245 EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
| 245 WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true))); | 246 WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true))); |
| 246 EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN, _, _)); | 247 EXPECT_CALL(start_callback_, Run(DataTypeController::OK_FIRST_RUN, _, _)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 SetStopExpectations(); | 328 SetStopExpectations(); |
| 328 | 329 |
| 329 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); | 330 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); |
| 330 | 331 |
| 331 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _, _)); | 332 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _, _)); |
| 332 Start(); | 333 Start(); |
| 333 EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state()); | 334 EXPECT_EQ(DataTypeController::RUNNING, bookmark_dtc_->state()); |
| 334 bookmark_dtc_->Stop(); | 335 bookmark_dtc_->Stop(); |
| 335 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); | 336 EXPECT_EQ(DataTypeController::NOT_RUNNING, bookmark_dtc_->state()); |
| 336 } | 337 } |
| OLD | NEW |