OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync_driver/non_ui_data_type_controller.h" | 5 #include "components/sync_driver/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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 NonUIDataTypeControllerMock* mock_; | 173 NonUIDataTypeControllerMock* mock_; |
174 scoped_refptr<SharedChangeProcessor> change_processor_; | 174 scoped_refptr<SharedChangeProcessor> change_processor_; |
175 scoped_refptr<base::MessageLoopProxy> backend_loop_; | 175 scoped_refptr<base::MessageLoopProxy> backend_loop_; |
176 }; | 176 }; |
177 | 177 |
178 class SyncNonUIDataTypeControllerTest : public testing::Test { | 178 class SyncNonUIDataTypeControllerTest : public testing::Test { |
179 public: | 179 public: |
180 SyncNonUIDataTypeControllerTest() | 180 SyncNonUIDataTypeControllerTest() |
181 : backend_thread_("dbthread") {} | 181 : backend_thread_("dbthread") {} |
182 | 182 |
183 virtual void SetUp() override { | 183 void SetUp() override { |
184 backend_thread_.Start(); | 184 backend_thread_.Start(); |
185 change_processor_ = new SharedChangeProcessorMock(); | 185 change_processor_ = new SharedChangeProcessorMock(); |
186 // All of these are refcounted, so don't need to be released. | 186 // All of these are refcounted, so don't need to be released. |
187 dtc_mock_ = new StrictMock<NonUIDataTypeControllerMock>(); | 187 dtc_mock_ = new StrictMock<NonUIDataTypeControllerMock>(); |
188 non_ui_dtc_ = | 188 non_ui_dtc_ = |
189 new NonUIDataTypeControllerFake(NULL, | 189 new NonUIDataTypeControllerFake(NULL, |
190 dtc_mock_.get(), | 190 dtc_mock_.get(), |
191 change_processor_.get(), | 191 change_processor_.get(), |
192 backend_thread_.message_loop_proxy()); | 192 backend_thread_.message_loop_proxy()); |
193 } | 193 } |
194 | 194 |
195 virtual void TearDown() override { | 195 void TearDown() override { backend_thread_.Stop(); } |
196 backend_thread_.Stop(); | |
197 } | |
198 | 196 |
199 void WaitForDTC() { | 197 void WaitForDTC() { |
200 WaitableEvent done(true, false); | 198 WaitableEvent done(true, false); |
201 backend_thread_.message_loop_proxy()->PostTask( | 199 backend_thread_.message_loop_proxy()->PostTask( |
202 FROM_HERE, | 200 FROM_HERE, |
203 base::Bind(&SyncNonUIDataTypeControllerTest::SignalDone, | 201 base::Bind(&SyncNonUIDataTypeControllerTest::SignalDone, |
204 &done)); | 202 &done)); |
205 done.TimedWait(TestTimeouts::action_timeout()); | 203 done.TimedWait(TestTimeouts::action_timeout()); |
206 if (!done.IsSignaled()) { | 204 if (!done.IsSignaled()) { |
207 ADD_FAILURE() << "Timed out waiting for DB thread to finish."; | 205 ADD_FAILURE() << "Timed out waiting for DB thread to finish."; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 &NonUIDataTypeControllerFake:: | 484 &NonUIDataTypeControllerFake:: |
487 OnSingleDataTypeUnrecoverableError, | 485 OnSingleDataTypeUnrecoverableError, |
488 non_ui_dtc_.get(), | 486 non_ui_dtc_.get(), |
489 error)); | 487 error)); |
490 WaitForDTC(); | 488 WaitForDTC(); |
491 } | 489 } |
492 | 490 |
493 } // namespace | 491 } // namespace |
494 | 492 |
495 } // namespace sync_driver | 493 } // namespace sync_driver |
OLD | NEW |