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/search_engines/template_url_service_test_util.h" | 5 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 }; | 114 }; |
115 | 115 |
116 void TemplateURLServiceTestingProfile::SetUp() { | 116 void TemplateURLServiceTestingProfile::SetUp() { |
117 db_thread_.Start(); | 117 db_thread_.Start(); |
118 | 118 |
119 // Make unique temp directory. | 119 // Make unique temp directory. |
120 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 120 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
121 | 121 |
122 base::FilePath path = temp_dir_.path().AppendASCII("TestDataService.db"); | 122 base::FilePath path = temp_dir_.path().AppendASCII("TestDataService.db"); |
123 service_ = new WebDataService; | 123 service_ = new WebDataService; |
124 ASSERT_TRUE(service_->InitWithPath(path)); | 124 service_->Init(path); |
125 } | 125 } |
126 | 126 |
127 void TemplateURLServiceTestingProfile::TearDown() { | 127 void TemplateURLServiceTestingProfile::TearDown() { |
128 // Clear the request context so it will get deleted. This should be done | 128 // Clear the request context so it will get deleted. This should be done |
129 // before shutting down the I/O thread to avoid memory leaks. | 129 // before shutting down the I/O thread to avoid memory leaks. |
130 ResetRequestContext(); | 130 ResetRequestContext(); |
131 | 131 |
132 // Wait for the delete of the request context to happen. | 132 // Wait for the delete of the request context to happen. |
133 if (io_thread_.IsRunning()) | 133 if (io_thread_.IsRunning()) |
134 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests(); | 134 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ResetObserverCount(); | 226 ResetObserverCount(); |
227 } | 227 } |
228 | 228 |
229 void TemplateURLServiceTestUtil::ChangeModelToLoadState() { | 229 void TemplateURLServiceTestUtil::ChangeModelToLoadState() { |
230 model()->ChangeToLoadedState(); | 230 model()->ChangeToLoadedState(); |
231 // Initialize the web data service so that the database gets updated with | 231 // Initialize the web data service so that the database gets updated with |
232 // any changes made. | 232 // any changes made. |
233 | 233 |
234 model()->service_ = WebDataServiceFactory::GetForProfile( | 234 model()->service_ = WebDataServiceFactory::GetForProfile( |
235 profile_.get(), Profile::EXPLICIT_ACCESS); | 235 profile_.get(), Profile::EXPLICIT_ACCESS); |
| 236 BlockTillServiceProcessesRequests(); |
236 } | 237 } |
237 | 238 |
238 void TemplateURLServiceTestUtil::ClearModel() { | 239 void TemplateURLServiceTestUtil::ClearModel() { |
239 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 240 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
240 profile_.get(), NULL); | 241 profile_.get(), NULL); |
241 } | 242 } |
242 | 243 |
243 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { | 244 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { |
244 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 245 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
245 profile_.get(), TestingTemplateURLService::Build); | 246 profile_.get(), TestingTemplateURLService::Build); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return profile_.get(); | 330 return profile_.get(); |
330 } | 331 } |
331 | 332 |
332 void TemplateURLServiceTestUtil::StartIOThread() { | 333 void TemplateURLServiceTestUtil::StartIOThread() { |
333 profile_->StartIOThread(); | 334 profile_->StartIOThread(); |
334 } | 335 } |
335 | 336 |
336 void TemplateURLServiceTestUtil::PumpLoop() { | 337 void TemplateURLServiceTestUtil::PumpLoop() { |
337 message_loop_.RunUntilIdle(); | 338 message_loop_.RunUntilIdle(); |
338 } | 339 } |
OLD | NEW |