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" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "chrome/browser/google/google_url_tracker.h" | 13 #include "chrome/browser/google/google_url_tracker.h" |
14 #include "chrome/browser/search_engines/search_terms_data.h" | 14 #include "chrome/browser/search_engines/search_terms_data.h" |
15 #include "chrome/browser/search_engines/template_url_service.h" | 15 #include "chrome/browser/search_engines/template_url_service.h" |
16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
17 #include "chrome/browser/webdata/web_data_service_factory.h" | 17 #include "chrome/browser/webdata/web_data_service_factory.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/test/base/testing_pref_service.h" | 20 #include "chrome/test/base/testing_pref_service.h" |
21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 #if defined(OS_ANDROID) | |
27 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | |
28 #endif | |
29 | |
26 using content::BrowserThread; | 30 using content::BrowserThread; |
27 | 31 |
28 namespace { | 32 namespace { |
29 | 33 |
30 // A callback used to coordinate when the database has finished processing | 34 // A callback used to coordinate when the database has finished processing |
31 // requests. See note in BlockTillServiceProcessesRequests for details. | 35 // requests. See note in BlockTillServiceProcessesRequests for details. |
32 // | 36 // |
33 // Schedules a QuitClosure on the message loop it was created with. | 37 // Schedules a QuitClosure on the message loop it was created with. |
34 void QuitCallback(MessageLoop* message_loop) { | 38 void QuitCallback(MessageLoop* message_loop) { |
35 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 39 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 DISALLOW_COPY_AND_ASSIGN(TestingTemplateURLService); | 111 DISALLOW_COPY_AND_ASSIGN(TestingTemplateURLService); |
108 }; | 112 }; |
109 | 113 |
110 void TemplateURLServiceTestingProfile::SetUp() { | 114 void TemplateURLServiceTestingProfile::SetUp() { |
111 db_thread_.Start(); | 115 db_thread_.Start(); |
112 | 116 |
113 // Make unique temp directory. | 117 // Make unique temp directory. |
114 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 118 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
115 | 119 |
116 FilePath path = temp_dir_.path().AppendASCII("TestDataService.db"); | 120 FilePath path = temp_dir_.path().AppendASCII("TestDataService.db"); |
121 #if defined(OS_ANDROID) | |
122 TemplateURLPrepopulateData::InitCountryCode("US"); | |
sky
2012/11/19 22:50:01
This seems like a more fundamental problem. Should
michaelbai
2012/11/19 23:05:38
Did you mean TestingProfile?
On 2012/11/19 22:50:
Peter Kasting
2012/11/20 04:06:13
Yes, but really this is just wrong anyway. No tes
michaelbai
2012/11/20 19:03:33
It looks like the original author want to be warne
| |
123 #endif | |
117 service_ = new WebDataService; | 124 service_ = new WebDataService; |
118 ASSERT_TRUE(service_->InitWithPath(path)); | 125 ASSERT_TRUE(service_->InitWithPath(path)); |
119 } | 126 } |
120 | 127 |
121 void TemplateURLServiceTestingProfile::TearDown() { | 128 void TemplateURLServiceTestingProfile::TearDown() { |
122 // Clear the request context so it will get deleted. This should be done | 129 // Clear the request context so it will get deleted. This should be done |
123 // before shutting down the I/O thread to avoid memory leaks. | 130 // before shutting down the I/O thread to avoid memory leaks. |
124 ResetRequestContext(); | 131 ResetRequestContext(); |
125 | 132 |
126 // Wait for the delete of the request context to happen. | 133 // Wait for the delete of the request context to happen. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 return profile_.get(); | 314 return profile_.get(); |
308 } | 315 } |
309 | 316 |
310 void TemplateURLServiceTestUtil::StartIOThread() { | 317 void TemplateURLServiceTestUtil::StartIOThread() { |
311 profile_->StartIOThread(); | 318 profile_->StartIOThread(); |
312 } | 319 } |
313 | 320 |
314 void TemplateURLServiceTestUtil::PumpLoop() { | 321 void TemplateURLServiceTestUtil::PumpLoop() { |
315 message_loop_.RunUntilIdle(); | 322 message_loop_.RunUntilIdle(); |
316 } | 323 } |
OLD | NEW |