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

Side by Side Diff: chrome/browser/search_engines/template_url_service_test_util.cc

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload rebase Created 8 years, 8 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) 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/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
12 #include "chrome/browser/search_engines/search_terms_data.h" 12 #include "chrome/browser/search_engines/search_terms_data.h"
13 #include "chrome/browser/search_engines/template_url_service.h" 13 #include "chrome/browser/search_engines/template_url_service.h"
14 #include "chrome/browser/search_engines/template_url_service_factory.h" 14 #include "chrome/browser/search_engines/template_url_service_factory.h"
15 #include "chrome/browser/webdata/web_data_service_factory.h"
15 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/test/test_browser_thread.h" 19 #include "content/test/test_browser_thread.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using content::BrowserThread; 22 using content::BrowserThread;
22 23
23 namespace { 24 namespace {
24 25
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 // Wait for the delete of the request context to happen. 122 // Wait for the delete of the request context to happen.
122 if (io_thread_.IsRunning()) 123 if (io_thread_.IsRunning())
123 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests(); 124 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests();
124 125
125 // The I/O thread must be shutdown before the DB thread. 126 // The I/O thread must be shutdown before the DB thread.
126 io_thread_.Stop(); 127 io_thread_.Stop();
127 128
128 // Clean up the test directory. 129 // Clean up the test directory.
129 if (service_.get()) 130 if (service_.get())
130 service_->Shutdown(); 131 service_ = NULL;
131 // Note that we must ensure the DB thread is stopped after WDS 132 // Note that we must ensure the DB thread is stopped after WDS
132 // shutdown (so it can commit pending transactions) but before 133 // shutdown (so it can commit pending transactions) but before
133 // deleting the test profile directory, otherwise we may not be 134 // deleting the test profile directory, otherwise we may not be
134 // able to delete it due to an open transaction. 135 // able to delete it due to an open transaction.
135 db_thread_.Stop(); 136 db_thread_.Stop();
136 } 137 }
137 138
138 TemplateURLServiceTestUtil::TemplateURLServiceTestUtil() 139 TemplateURLServiceTestUtil::TemplateURLServiceTestUtil()
139 : ui_thread_(BrowserThread::UI, &message_loop_), 140 : ui_thread_(BrowserThread::UI, &message_loop_),
140 changed_count_(0) { 141 changed_count_(0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 model()->Load(); 189 model()->Load();
189 BlockTillServiceProcessesRequests(); 190 BlockTillServiceProcessesRequests();
190 EXPECT_EQ(1, GetObserverCount()); 191 EXPECT_EQ(1, GetObserverCount());
191 ResetObserverCount(); 192 ResetObserverCount();
192 } 193 }
193 194
194 void TemplateURLServiceTestUtil::ChangeModelToLoadState() { 195 void TemplateURLServiceTestUtil::ChangeModelToLoadState() {
195 model()->ChangeToLoadedState(); 196 model()->ChangeToLoadedState();
196 // Initialize the web data service so that the database gets updated with 197 // Initialize the web data service so that the database gets updated with
197 // any changes made. 198 // any changes made.
198 model()->service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); 199 model()->service_ = WebDataServiceFactory::GetForProfile(
200 profile_.get(), Profile::EXPLICIT_ACCESS);
199 } 201 }
200 202
201 void TemplateURLServiceTestUtil::ClearModel() { 203 void TemplateURLServiceTestUtil::ClearModel() {
202 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( 204 TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
203 profile_.get(), NULL); 205 profile_.get(), NULL);
204 } 206 }
205 207
206 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) { 208 void TemplateURLServiceTestUtil::ResetModel(bool verify_load) {
207 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 209 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
208 profile_.get(), TestingTemplateURLService::Build); 210 profile_.get(), TestingTemplateURLService::Build);
(...skipping 25 matching lines...) Expand all
234 return profile_.get(); 236 return profile_.get();
235 } 237 }
236 238
237 void TemplateURLServiceTestUtil::StartIOThread() { 239 void TemplateURLServiceTestUtil::StartIOThread() {
238 profile_->StartIOThread(); 240 profile_->StartIOThread();
239 } 241 }
240 242
241 void TemplateURLServiceTestUtil::PumpLoop() { 243 void TemplateURLServiceTestUtil::PumpLoop() {
242 message_loop_.RunAllPending(); 244 message_loop_.RunAllPending();
243 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698