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/test/base/chrome_test_suite.h" | 5 #include "chrome/test/base/chrome_test_suite.h" |
6 | 6 |
7 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/metrics/stats_table.h" | 14 #include "base/metrics/stats_table.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_content_browser_client.h" | 20 #include "chrome/browser/chrome_content_browser_client.h" |
21 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 21 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_content_client.h" | 23 #include "chrome/common/chrome_content_client.h" |
24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 25 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
26 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | 26 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
| 29 #include "chrome/utility/chrome_content_utility_client.h" |
29 #include "content/public/test/test_launcher.h" | 30 #include "content/public/test/test_launcher.h" |
30 #include "extensions/common/extension_paths.h" | 31 #include "extensions/common/extension_paths.h" |
31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
32 #include "net/base/net_util.h" | 33 #include "net/base/net_util.h" |
33 #include "net/dns/mock_host_resolver.h" | 34 #include "net/dns/mock_host_resolver.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
35 #include "ui/base/resource/resource_bundle.h" | 36 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/base/resource/resource_handle.h" | 37 #include "ui/base/resource/resource_handle.h" |
37 | 38 |
38 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 138 |
138 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | 139 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { |
139 DCHECK(!g_browser_process); | 140 DCHECK(!g_browser_process); |
140 g_browser_process = new TestingBrowserProcess; | 141 g_browser_process = new TestingBrowserProcess; |
141 | 142 |
142 content_client_.reset(new chrome::ChromeContentClient); | 143 content_client_.reset(new chrome::ChromeContentClient); |
143 content::SetContentClient(content_client_.get()); | 144 content::SetContentClient(content_client_.get()); |
144 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. | 145 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
145 #if !defined(OS_IOS) | 146 #if !defined(OS_IOS) |
146 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); | 147 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
147 SetBrowserClientForTesting(browser_content_client_.get()); | 148 content::SetBrowserClientForTesting(browser_content_client_.get()); |
| 149 utility_content_client_.reset(new chrome::ChromeContentUtilityClient()); |
| 150 content::SetUtilityClientForTesting(utility_content_client_.get()); |
148 #endif | 151 #endif |
149 | 152 |
150 SetUpHostResolver(); | 153 SetUpHostResolver(); |
151 } | 154 } |
152 | 155 |
153 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | 156 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { |
154 if (g_browser_process) { | 157 if (g_browser_process) { |
155 delete g_browser_process; | 158 delete g_browser_process; |
156 g_browser_process = NULL; | 159 g_browser_process = NULL; |
157 } | 160 } |
158 | 161 |
159 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. | 162 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
160 #if !defined(OS_IOS) | 163 #if !defined(OS_IOS) |
161 browser_content_client_.reset(); | 164 browser_content_client_.reset(); |
| 165 utility_content_client_.reset(); |
162 #endif | 166 #endif |
163 content_client_.reset(); | 167 content_client_.reset(); |
164 content::SetContentClient(NULL); | 168 content::SetContentClient(NULL); |
165 | 169 |
166 TearDownHostResolver(); | 170 TearDownHostResolver(); |
167 } | 171 } |
168 | 172 |
169 private: | 173 private: |
170 void SetUpHostResolver() { | 174 void SetUpHostResolver() { |
171 host_resolver_proc_ = new LocalHostResolverProc; | 175 host_resolver_proc_ = new LocalHostResolverProc; |
172 scoped_host_resolver_proc_.reset( | 176 scoped_host_resolver_proc_.reset( |
173 new net::ScopedDefaultHostResolverProc(host_resolver_proc_.get())); | 177 new net::ScopedDefaultHostResolverProc(host_resolver_proc_.get())); |
174 } | 178 } |
175 | 179 |
176 void TearDownHostResolver() { | 180 void TearDownHostResolver() { |
177 scoped_host_resolver_proc_.reset(); | 181 scoped_host_resolver_proc_.reset(); |
178 host_resolver_proc_ = NULL; | 182 host_resolver_proc_ = NULL; |
179 } | 183 } |
180 | 184 |
181 scoped_ptr<chrome::ChromeContentClient> content_client_; | 185 scoped_ptr<chrome::ChromeContentClient> content_client_; |
182 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. | 186 // TODO(ios): Bring this back once ChromeContentBrowserClient is building. |
183 #if !defined(OS_IOS) | 187 #if !defined(OS_IOS) |
184 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; | 188 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; |
| 189 scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_; |
185 #endif | 190 #endif |
186 | 191 |
187 scoped_refptr<LocalHostResolverProc> host_resolver_proc_; | 192 scoped_refptr<LocalHostResolverProc> host_resolver_proc_; |
188 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; | 193 scoped_ptr<net::ScopedDefaultHostResolverProc> scoped_host_resolver_proc_; |
189 | 194 |
190 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); | 195 DISALLOW_COPY_AND_ASSIGN(ChromeTestSuiteInitializer); |
191 }; | 196 }; |
192 | 197 |
193 } // namespace | 198 } // namespace |
194 | 199 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 #if defined(OS_MACOSX) && !defined(OS_IOS) | 299 #if defined(OS_MACOSX) && !defined(OS_IOS) |
295 base::mac::SetOverrideFrameworkBundle(NULL); | 300 base::mac::SetOverrideFrameworkBundle(NULL); |
296 #endif | 301 #endif |
297 | 302 |
298 base::StatsTable::set_current(NULL); | 303 base::StatsTable::set_current(NULL); |
299 stats_table_.reset(); | 304 stats_table_.reset(); |
300 RemoveSharedMemoryFile(stats_filename_); | 305 RemoveSharedMemoryFile(stats_filename_); |
301 | 306 |
302 base::TestSuite::Shutdown(); | 307 base::TestSuite::Shutdown(); |
303 } | 308 } |
OLD | NEW |