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/non_ui_data_type_controller.h" | 5 #include "chrome/browser/sync/glue/non_ui_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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 void WaitForDTC() { | 178 void WaitForDTC() { |
179 WaitableEvent done(true, false); | 179 WaitableEvent done(true, false); |
180 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 180 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
181 base::Bind(&SyncNonUIDataTypeControllerTest::SignalDone, | 181 base::Bind(&SyncNonUIDataTypeControllerTest::SignalDone, |
182 &done)); | 182 &done)); |
183 done.TimedWait(TestTimeouts::action_timeout()); | 183 done.TimedWait(TestTimeouts::action_timeout()); |
184 if (!done.IsSignaled()) { | 184 if (!done.IsSignaled()) { |
185 ADD_FAILURE() << "Timed out waiting for DB thread to finish."; | 185 ADD_FAILURE() << "Timed out waiting for DB thread to finish."; |
186 } | 186 } |
187 MessageLoop::current()->RunUntilIdle(); | 187 base::MessageLoop::current()->RunUntilIdle(); |
188 } | 188 } |
189 | 189 |
190 protected: | 190 protected: |
191 void SetStartExpectations() { | 191 void SetStartExpectations() { |
192 EXPECT_CALL(*dtc_mock_, StartModels()).WillOnce(Return(true)); | 192 EXPECT_CALL(*dtc_mock_, StartModels()).WillOnce(Return(true)); |
193 EXPECT_CALL(model_load_callback_, Run(_, _)); | 193 EXPECT_CALL(model_load_callback_, Run(_, _)); |
194 EXPECT_CALL(*profile_sync_factory_, | 194 EXPECT_CALL(*profile_sync_factory_, |
195 CreateSharedChangeProcessor()). | 195 CreateSharedChangeProcessor()). |
196 WillOnce(Return(change_processor_.get())); | 196 WillOnce(Return(change_processor_.get())); |
197 } | 197 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 base::Unretained(&model_load_callback_))); | 234 base::Unretained(&model_load_callback_))); |
235 non_ui_dtc_->StartAssociating( | 235 non_ui_dtc_->StartAssociating( |
236 base::Bind(&StartCallbackMock::Run, | 236 base::Bind(&StartCallbackMock::Run, |
237 base::Unretained(&start_callback_))); | 237 base::Unretained(&start_callback_))); |
238 } | 238 } |
239 | 239 |
240 static void SignalDone(WaitableEvent* done) { | 240 static void SignalDone(WaitableEvent* done) { |
241 done->Signal(); | 241 done->Signal(); |
242 } | 242 } |
243 | 243 |
244 MessageLoopForUI message_loop_; | 244 base::MessageLoopForUI message_loop_; |
245 content::TestBrowserThread ui_thread_; | 245 content::TestBrowserThread ui_thread_; |
246 content::TestBrowserThread db_thread_; | 246 content::TestBrowserThread db_thread_; |
247 ProfileMock profile_; | 247 ProfileMock profile_; |
248 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; | 248 scoped_ptr<ProfileSyncComponentsFactoryMock> profile_sync_factory_; |
249 StrictMock<ProfileSyncServiceMock> service_; | 249 StrictMock<ProfileSyncServiceMock> service_; |
250 StartCallbackMock start_callback_; | 250 StartCallbackMock start_callback_; |
251 ModelLoadCallbackMock model_load_callback_; | 251 ModelLoadCallbackMock model_load_callback_; |
252 // Must be destroyed after non_ui_dtc_. | 252 // Must be destroyed after non_ui_dtc_. |
253 syncer::FakeSyncableService syncable_service_; | 253 syncer::FakeSyncableService syncable_service_; |
254 scoped_refptr<NonUIDataTypeControllerFake> non_ui_dtc_; | 254 scoped_refptr<NonUIDataTypeControllerFake> non_ui_dtc_; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 non_ui_dtc_.get(), | 487 non_ui_dtc_.get(), |
488 FROM_HERE, | 488 FROM_HERE, |
489 std::string("Test"))); | 489 std::string("Test"))); |
490 WaitForDTC(); | 490 WaitForDTC(); |
491 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); | 491 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); |
492 } | 492 } |
493 | 493 |
494 } // namespace | 494 } // namespace |
495 | 495 |
496 } // namespace browser_sync | 496 } // namespace browser_sync |
OLD | NEW |