OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_frame/test/net/fake_external_tab.h" | 5 #include "chrome_frame/test/net/fake_external_tab.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlcom.h> | 8 #include <atlcom.h> |
9 #include <exdisp.h> | 9 #include <exdisp.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/debugger.h" | 13 #include "base/debug/debugger.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/file_version_info.h" | 15 #include "base/file_version_info.h" |
16 #include "base/i18n/icu_util.h" | 16 #include "base/i18n/icu_util.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/scoped_temp_dir.h" | 20 #include "base/scoped_temp_dir.h" |
21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
23 #include "base/system_monitor/system_monitor.h" | 23 #include "base/system_monitor/system_monitor.h" |
24 #include "base/test/test_timeouts.h" | 24 #include "base/test/test_timeouts.h" |
25 #include "base/threading/platform_thread.h" | 25 #include "base/threading/platform_thread.h" |
26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
27 #include "base/win/scoped_com_initializer.h" | 27 #include "base/win/scoped_com_initializer.h" |
28 #include "base/win/scoped_comptr.h" | 28 #include "base/win/scoped_comptr.h" |
29 #include "base/win/scoped_handle.h" | 29 #include "base/win/scoped_handle.h" |
30 #include "chrome/app/chrome_main_delegate.h" | |
30 #include "chrome/browser/automation/automation_provider_list.h" | 31 #include "chrome/browser/automation/automation_provider_list.h" |
31 #include "chrome/browser/browser_process_impl.h" // TODO(joi): Remove | |
32 #include "chrome/browser/chrome_content_browser_client.h" | 32 #include "chrome/browser/chrome_content_browser_client.h" |
33 #include "chrome/browser/prefs/browser_prefs.h" | 33 #include "chrome/browser/prefs/browser_prefs.h" |
34 #include "chrome/browser/prefs/pref_service.h" | 34 #include "chrome/browser/prefs/pref_service.h" |
35 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 35 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
36 #include "chrome/browser/process_singleton.h" | 36 #include "chrome/browser/process_singleton.h" |
37 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
38 #include "chrome/browser/renderer_host/web_cache_manager.h" | 38 #include "chrome/browser/renderer_host/web_cache_manager.h" |
39 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
40 #include "chrome/common/chrome_content_client.h" | 40 #include "chrome/common/chrome_content_client.h" |
41 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
42 #include "chrome/common/chrome_paths_internal.h" | 42 #include "chrome/common/chrome_paths_internal.h" |
43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
44 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
45 #include "chrome/renderer/chrome_content_renderer_client.h" | 45 #include "chrome/renderer/chrome_content_renderer_client.h" |
46 #include "chrome_frame/crash_server_init.h" | 46 #include "chrome_frame/crash_server_init.h" |
47 #include "chrome_frame/test/chrome_frame_test_utils.h" | 47 #include "chrome_frame/test/chrome_frame_test_utils.h" |
48 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" | 48 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" |
49 #include "chrome_frame/test/simulate_input.h" | 49 #include "chrome_frame/test/simulate_input.h" |
50 #include "chrome_frame/test/win_event_receiver.h" | 50 #include "chrome_frame/test/win_event_receiver.h" |
51 #include "chrome_frame/utils.h" | 51 #include "chrome_frame/utils.h" |
52 #include "content/app/content_main.h" | |
52 #include "content/browser/plugin_service.h" | 53 #include "content/browser/plugin_service.h" |
53 #include "content/browser/notification_service_impl.h" | 54 #include "content/browser/notification_service_impl.h" |
55 #include "content/public/app/startup_helper_win.h" | |
56 #include "content/public/browser/browser_thread.h" | |
54 #include "content/public/browser/render_process_host.h" | 57 #include "content/public/browser/render_process_host.h" |
55 #include "content/public/common/content_client.h" | 58 #include "content/public/common/content_client.h" |
56 #include "content/public/common/content_paths.h" | 59 #include "content/public/common/content_paths.h" |
57 #include "content/test/test_browser_thread.h" // TODO(joi): Remove | 60 #include "sandbox/src/sandbox_types.h" |
58 #include "testing/gtest/include/gtest/gtest.h" | 61 #include "testing/gtest/include/gtest/gtest.h" |
59 #include "ui/base/resource/resource_bundle.h" | 62 #include "ui/base/resource/resource_bundle.h" |
60 #include "ui/base/ui_base_paths.h" | 63 #include "ui/base/ui_base_paths.h" |
61 | 64 |
62 using content::BrowserThread; | 65 using content::BrowserThread; |
63 | 66 |
64 namespace { | 67 namespace { |
65 | 68 |
69 // We must store this globally so that our main delegate can set it. | |
70 static CFUrlRequestUnittestRunner* g_test_suite = NULL; | |
71 | |
72 // Copied here for access by CreateBrowserMainParts and InitGoogleTest. | |
73 static int g_argc = 0; | |
74 static char** g_argv = NULL; | |
75 | |
66 // A special command line switch to allow developers to manually launch the | 76 // A special command line switch to allow developers to manually launch the |
67 // browser and debug CF inside the browser. | 77 // browser and debug CF inside the browser. |
68 const char kManualBrowserLaunch[] = "manual-browser"; | 78 const char kManualBrowserLaunch[] = "manual-browser"; |
69 | 79 |
70 // Pops up a message box after the test environment has been set up | 80 // Pops up a message box after the test environment has been set up |
71 // and before tearing it down. Useful for when debugging tests and not | 81 // and before tearing it down. Useful for when debugging tests and not |
72 // the test environment that's been set up. | 82 // the test environment that's been set up. |
73 const char kPromptAfterSetup[] = "prompt-after-setup"; | 83 const char kPromptAfterSetup[] = "prompt-after-setup"; |
74 | 84 |
75 const int kTestServerPort = 4666; | 85 const int kTestServerPort = 4666; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 } | 124 } |
115 | 125 |
116 // Same as BrowserProcessImpl, but uses custom profile manager. | 126 // Same as BrowserProcessImpl, but uses custom profile manager. |
117 class FakeBrowserProcessImpl : public BrowserProcessImpl { | 127 class FakeBrowserProcessImpl : public BrowserProcessImpl { |
118 public: | 128 public: |
119 explicit FakeBrowserProcessImpl(const CommandLine& command_line) | 129 explicit FakeBrowserProcessImpl(const CommandLine& command_line) |
120 : BrowserProcessImpl(command_line) { | 130 : BrowserProcessImpl(command_line) { |
121 profiles_dir_.CreateUniqueTempDir(); | 131 profiles_dir_.CreateUniqueTempDir(); |
122 } | 132 } |
123 | 133 |
124 virtual ProfileManager* profile_manager() { | 134 virtual ~FakeBrowserProcessImpl() {} |
135 | |
136 // Return the g_browser_process global, which in this test gets set to | |
137 // a FakeBrowserProcessImpl, as a FakeBrowserProcessImpl so that non-interface | |
138 // methods can be accessed. | |
139 static FakeBrowserProcessImpl* Global() { | |
140 return reinterpret_cast<FakeBrowserProcessImpl*>(g_browser_process); | |
141 } | |
robertshield
2011/12/12 16:09:40
Slightly cleaner might be to expose FakeExternalTa
| |
142 | |
143 virtual ProfileManager* profile_manager() OVERRIDE { | |
125 if (!profile_manager_.get()) { | 144 if (!profile_manager_.get()) { |
126 profile_manager_.reset( | 145 profile_manager_.reset( |
127 new ProfileManagerWithoutInit(profiles_dir_.path())); | 146 new ProfileManagerWithoutInit(profiles_dir_.path())); |
128 } | 147 } |
129 return profile_manager_.get(); | 148 return profile_manager_.get(); |
130 } | 149 } |
131 | 150 |
132 virtual MetricsService* metrics_service() { | 151 virtual MetricsService* metrics_service() OVERRIDE { |
133 return NULL; | 152 return NULL; |
134 } | 153 } |
135 | 154 |
155 void DestroyProfileManager() { | |
156 profile_manager_.reset(); | |
157 } | |
158 | |
136 private: | 159 private: |
137 ScopedTempDir profiles_dir_; | 160 ScopedTempDir profiles_dir_; |
138 scoped_ptr<ProfileManager> profile_manager_; | 161 scoped_ptr<ProfileManager> profile_manager_; |
139 }; | 162 }; |
140 | 163 |
164 class FakeContentBrowserClient : public chrome::ChromeContentBrowserClient { | |
165 public: | |
166 virtual ~FakeContentBrowserClient() {} | |
167 | |
168 virtual content::BrowserMainParts* CreateBrowserMainParts( | |
169 const content::MainFunctionParams& parameters) OVERRIDE; | |
170 }; | |
171 | |
141 base::LazyInstance<chrome::ChromeContentClient> | 172 base::LazyInstance<chrome::ChromeContentClient> |
142 g_chrome_content_client = LAZY_INSTANCE_INITIALIZER; | 173 g_chrome_content_client = LAZY_INSTANCE_INITIALIZER; |
143 | 174 |
144 // Override the default ContentBrowserClient to let Chrome participate in | 175 // Override the default ContentBrowserClient to let Chrome participate in |
145 // content logic. Must be done before any tabs are created. | 176 // content logic. Must be done before any tabs are created. |
146 base::LazyInstance<chrome::ChromeContentBrowserClient> | 177 base::LazyInstance<FakeContentBrowserClient> |
147 g_browser_client = LAZY_INSTANCE_INITIALIZER; | 178 g_browser_client = LAZY_INSTANCE_INITIALIZER; |
148 | 179 |
149 base::LazyInstance<chrome::ChromeContentRendererClient> | 180 base::LazyInstance<chrome::ChromeContentRendererClient> |
150 g_renderer_client = LAZY_INSTANCE_INITIALIZER; | 181 g_renderer_client = LAZY_INSTANCE_INITIALIZER; |
151 | 182 |
183 class FakeMainDelegate : public content::ContentMainDelegate { | |
184 public: | |
185 virtual ~FakeMainDelegate() {} | |
186 | |
187 virtual bool BasicStartupComplete(int* exit_code) OVERRIDE { | |
188 return false; | |
189 } | |
190 | |
191 virtual void PreSandboxStartup() OVERRIDE { | |
192 // Initialize the content client. | |
193 content::SetContentClient(&g_chrome_content_client.Get()); | |
194 | |
195 // Override the default ContentBrowserClient to let Chrome participate in | |
196 // content logic. We use a subclass of Chrome's implementation, | |
197 // FakeContentBrowserClient, to override CreateBrowserMainParts. Must | |
198 // be done before any tabs are created. | |
199 content::GetContentClient()->set_browser(&g_browser_client.Get()); | |
200 | |
201 content::GetContentClient()->set_renderer(&g_renderer_client.Get()); | |
202 } | |
203 | |
204 virtual void SandboxInitialized(const std::string& process_type) OVERRIDE {} | |
205 | |
206 virtual int RunProcess( | |
207 const std::string& process_type, | |
208 const content::MainFunctionParams& main_function_params) OVERRIDE { | |
209 return -1; | |
210 } | |
211 virtual void ProcessExiting(const std::string& process_type) OVERRIDE {} | |
212 }; | |
213 | |
214 void FilterDisabledTests() { | |
215 if (::testing::FLAGS_gtest_filter.length() && | |
216 ::testing::FLAGS_gtest_filter.Compare("*") != 0) { | |
217 // Don't override user specified filters. | |
218 return; | |
219 } | |
220 | |
221 const char* disabled_tests[] = { | |
222 // Tests disabled since they're testing the same functionality used | |
223 // by the TestAutomationProvider. | |
224 "URLRequestTest.Intercept", | |
225 "URLRequestTest.InterceptNetworkError", | |
226 "URLRequestTest.InterceptRestartRequired", | |
227 "URLRequestTest.InterceptRespectsCancelMain", | |
228 "URLRequestTest.InterceptRespectsCancelRedirect", | |
229 "URLRequestTest.InterceptRespectsCancelFinal", | |
230 "URLRequestTest.InterceptRespectsCancelInRestart", | |
231 "URLRequestTest.InterceptRedirect", | |
232 "URLRequestTest.InterceptServerError", | |
233 "URLRequestTestFTP.*", | |
234 | |
235 // Tests that are currently not working: | |
236 | |
237 // Temporarily disabled because they needs user input (login dialog). | |
238 "URLRequestTestHTTP.BasicAuth", | |
239 "URLRequestTestHTTP.BasicAuthWithCookies", | |
240 | |
241 // HTTPS tests temporarily disabled due to the certificate error dialog. | |
242 // TODO(tommi): The tests currently fail though, so need to fix. | |
243 "HTTPSRequestTest.HTTPSMismatchedTest", | |
244 "HTTPSRequestTest.HTTPSExpiredTest", | |
245 "HTTPSRequestTest.ClientAuthTest", | |
246 | |
247 // Tests chrome's network stack's cache (might not apply to CF). | |
248 "URLRequestTestHTTP.VaryHeader", | |
249 "URLRequestTestHTTP.GetZippedTest", | |
250 | |
251 // I suspect we can only get this one to work (if at all) on IE8 and | |
252 // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags | |
253 // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx | |
254 "URLRequestTest.DoNotSaveCookies", | |
255 "URLRequestTest.DelayedCookieCallback", | |
256 | |
257 // TODO(ananta): This test has been consistently failing. Disabling it for | |
258 // now. | |
259 "URLRequestTestHTTP.GetTest_NoCache", | |
260 | |
261 // These tests have been disabled as the Chrome cookie policies don't make | |
262 // sense or have not been implemented for the host network stack. | |
263 "URLRequestTest.DoNotSaveCookies_ViaPolicy", | |
264 "URLRequestTest.DoNotSendCookies_ViaPolicy", | |
265 "URLRequestTest.DoNotSaveCookies_ViaPolicy_Async", | |
266 "URLRequestTest.CookiePolicy_ForceSession", | |
267 "URLRequestTest.DoNotSendCookies", | |
268 "URLRequestTest.DoNotSendCookies_ViaPolicy_Async", | |
269 "URLRequestTest.CancelTest_During_OnGetCookies", | |
270 "URLRequestTest.CancelTest_During_OnSetCookie", | |
271 | |
272 // These tests are disabled as the rely on functionality provided by | |
273 // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. | |
274 "URLRequestTestHTTP.ProxyTunnelRedirectTest", | |
275 "URLRequestTestHTTP.UnexpectedServerAuthTest", | |
276 | |
277 // This test is disabled as it expects an empty UA to be echoed back from | |
278 // the server which is not the case in ChromeFrame. | |
279 "URLRequestTestHTTP.DefaultUserAgent", | |
280 // This test modifies the UploadData object after it has been marshaled to | |
281 // ChromeFrame. We don't support this. | |
282 "URLRequestTestHTTP.TestPostChunkedDataAfterStart", | |
283 | |
284 // Do not work in CF, it may well be that IE is unconditionally | |
285 // adding Accept-Encoding header by default to outgoing requests. | |
286 "URLRequestTestHTTP.DefaultAcceptEncoding", | |
287 "URLRequestTestHTTP.OverrideAcceptEncoding", | |
288 | |
289 // Not supported in ChromeFrame as we use IE's network stack. | |
290 "URLRequestTest.NetworkDelegateProxyError", | |
291 | |
292 // URLRequestAutomationJob needs to support NeedsAuth. | |
293 // http://crbug.com/98446 | |
294 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", | |
295 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", | |
296 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", | |
297 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", | |
298 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", | |
299 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", | |
300 | |
301 // Flaky on the tryservers, http://crbug.com/103097 | |
302 "URLRequestTestHTTP.MultipleRedirectTest", | |
303 "URLRequestTestHTTP.NetworkDelegateRedirectRequest", | |
304 | |
305 // These don't work on Joi's box with IE9, http://crbug.com/105435. | |
306 // | |
307 // Note that URLRequestTestHTTP.CancelTest2 and | |
308 // URLRequestTestHTTP.CancelTest3 also frequently hang. | |
309 "URLRequestTestHTTP.NetworkDelegateRedirectRequestPost", | |
310 "URLRequestTestHTTP.GetTest", | |
311 "HTTPSRequestTest.HTTPSPreloadedHSTSTest", | |
312 }; | |
313 | |
314 std::string filter("-"); // All following filters will be negative. | |
315 for (int i = 0; i < arraysize(disabled_tests); ++i) { | |
316 if (i > 0) | |
317 filter += ":"; | |
318 filter += disabled_tests[i]; | |
319 } | |
320 | |
321 ::testing::FLAGS_gtest_filter = filter; | |
322 } | |
323 | |
152 } // namespace | 324 } // namespace |
153 | 325 |
154 | 326 |
155 class SupplyProxyCredentials : public WindowObserver { | 327 class SupplyProxyCredentials : public WindowObserver { |
156 public: | 328 public: |
157 SupplyProxyCredentials(const char* username, const char* password); | 329 SupplyProxyCredentials(const char* username, const char* password); |
158 | 330 |
159 protected: | 331 protected: |
160 struct DialogProps { | 332 struct DialogProps { |
161 HWND username_; | 333 HWND username_; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 | 403 |
232 FakeExternalTab::~FakeExternalTab() { | 404 FakeExternalTab::~FakeExternalTab() { |
233 if (!overridden_user_dir_.empty()) { | 405 if (!overridden_user_dir_.empty()) { |
234 PathService::Override(chrome::DIR_USER_DATA, overridden_user_dir_); | 406 PathService::Override(chrome::DIR_USER_DATA, overridden_user_dir_); |
235 } | 407 } |
236 } | 408 } |
237 | 409 |
238 void FakeExternalTab::Initialize() { | 410 void FakeExternalTab::Initialize() { |
239 DCHECK(g_browser_process == NULL); | 411 DCHECK(g_browser_process == NULL); |
240 | 412 |
241 notificaton_service_.reset(new NotificationServiceImpl); | |
242 | |
243 base::SystemMonitor system_monitor; | |
244 | |
245 icu_util::Initialize(); | |
246 TestTimeouts::Initialize(); | 413 TestTimeouts::Initialize(); |
247 | 414 |
248 // Do not call chrome::RegisterPathProvider() since it is also called by our | |
249 // test runner, CFUrlRequestUnittestRunner, and calling it twice unfortunately | |
250 // causes a DCHECK(). | |
251 content::RegisterPathProvider(); | |
252 ui::RegisterPathProvider(); | |
253 | |
254 // Load Chrome.dll as our resource dll. | 415 // Load Chrome.dll as our resource dll. |
255 FilePath dll; | 416 FilePath dll; |
256 PathService::Get(base::DIR_MODULE, &dll); | 417 PathService::Get(base::DIR_MODULE, &dll); |
257 dll = dll.Append(chrome::kBrowserResourcesDll); | 418 dll = dll.Append(chrome::kBrowserResourcesDll); |
258 HMODULE res_mod = ::LoadLibraryExW(dll.value().c_str(), | 419 HMODULE res_mod = ::LoadLibraryExW(dll.value().c_str(), |
259 NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); | 420 NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE); |
260 DCHECK(res_mod); | 421 DCHECK(res_mod); |
261 _AtlBaseModule.SetResourceInstance(res_mod); | 422 _AtlBaseModule.SetResourceInstance(res_mod); |
262 | 423 |
263 ResourceBundle::InitSharedInstance("en-US"); | 424 ResourceBundle::InitSharedInstance("en-US"); |
264 | 425 |
265 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 426 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
266 cmd->AppendSwitch(switches::kDisableWebResources); | 427 cmd->AppendSwitch(switches::kDisableWebResources); |
267 cmd->AppendSwitch(switches::kSingleProcess); | 428 cmd->AppendSwitch(switches::kSingleProcess); |
268 | 429 |
269 browser_process_.reset(new FakeBrowserProcessImpl(*cmd)); | 430 browser_process_.reset(new FakeBrowserProcessImpl(*cmd)); |
270 // BrowserProcessImpl's constructor should set g_browser_process. | 431 // BrowserProcessImpl's constructor should set g_browser_process. |
271 DCHECK(g_browser_process); | 432 DCHECK(g_browser_process); |
272 g_browser_process->SetApplicationLocale("en-US"); | 433 g_browser_process->SetApplicationLocale("en-US"); |
273 | 434 |
274 content::RenderProcessHost::set_run_renderer_in_process(true); | 435 content::RenderProcessHost::set_run_renderer_in_process(true); |
275 | 436 |
276 browser_process_->local_state()->RegisterBooleanPref( | 437 browser_process_->local_state()->RegisterBooleanPref( |
277 prefs::kMetricsReportingEnabled, false); | 438 prefs::kMetricsReportingEnabled, false); |
278 | |
279 // Initialize the content client which that code uses to talk to Chrome. | |
280 content::SetContentClient(&g_chrome_content_client.Get()); | |
281 | |
282 // Override the default ContentBrowserClient to let Chrome participate in | |
283 // content logic. Must be done before any tabs are created. | |
284 content::GetContentClient()->set_browser(&g_browser_client.Get()); | |
285 | |
286 content::GetContentClient()->set_renderer(&g_renderer_client.Get()); | |
287 } | 439 } |
288 | 440 |
289 void FakeExternalTab::InitializePostThreadsCreated() { | 441 void FakeExternalTab::InitializePostThreadsCreated() { |
290 FilePath profile_path(ProfileManager::GetDefaultProfileDir(user_data())); | 442 FilePath profile_path(ProfileManager::GetDefaultProfileDir(user_data())); |
291 Profile* profile = | 443 Profile* profile = |
292 g_browser_process->profile_manager()->GetProfile(profile_path); | 444 g_browser_process->profile_manager()->GetProfile(profile_path); |
293 } | 445 } |
294 | 446 |
295 void FakeExternalTab::Shutdown() { | 447 void FakeExternalTab::Shutdown() { |
296 browser_process_.reset(); | 448 browser_process_.reset(); |
297 g_browser_process = NULL; | 449 g_browser_process = NULL; |
298 process_singleton_.reset(); | 450 process_singleton_.reset(); |
299 | 451 |
300 ResourceBundle::CleanupSharedInstance(); | 452 ResourceBundle::CleanupSharedInstance(); |
301 } | 453 } |
302 | 454 |
303 // TODO(joi): Remove! | |
304 class ChromeFrameFriendOfBrowserProcessImpl { | |
305 public: | |
306 static void CreateIOThreadState() { | |
307 reinterpret_cast<BrowserProcessImpl*>( | |
308 g_browser_process)->CreateIOThreadState(); | |
309 } | |
310 }; | |
311 | |
312 CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) | 455 CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) |
313 : NetTestSuite(argc, argv), | 456 : NetTestSuite(argc, argv), |
314 chrome_frame_html_("/chrome_frame", kChromeFrameHtml), | 457 chrome_frame_html_("/chrome_frame", kChromeFrameHtml), |
315 registrar_(chrome_frame_test::GetTestBedType()), | 458 registrar_(chrome_frame_test::GetTestBedType()), |
316 test_result_(0) { | 459 test_result_(0) { |
317 // Register the main thread by instantiating it, but don't call any methods. | |
318 main_thread_.reset(new content::TestBrowserThread( | |
319 BrowserThread::UI, MessageLoop::current())); | |
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
321 fake_chrome_.Initialize(); | |
322 | |
323 db_thread_.reset(new content::TestBrowserThread(BrowserThread::DB)); | |
324 db_thread_->Start(); | |
325 | |
326 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE)); | |
327 file_thread_->Start(); | |
328 | |
329 ChromeFrameFriendOfBrowserProcessImpl::CreateIOThreadState(); | |
330 | |
331 io_thread_.reset(new content::TestBrowserThread(BrowserThread::IO)); | |
332 io_thread_->StartIOThread(); | |
333 | |
334 fake_chrome_.InitializePostThreadsCreated(); | |
335 | |
336 pss_subclass_.reset(new ProcessSingletonSubclass(this)); | |
337 EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_.user_data())); | |
338 StartChromeFrameInHostBrowser(); | |
339 } | 460 } |
340 | 461 |
341 CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { | 462 CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { |
342 fake_chrome_.Shutdown(); | |
343 } | 463 } |
344 | 464 |
345 void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { | 465 void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { |
346 if (!ShouldLaunchBrowser()) | 466 if (!ShouldLaunchBrowser()) |
347 return; | 467 return; |
348 | 468 |
349 base::win::ScopedCOMInitializer com; | 469 base::win::ScopedCOMInitializer com; |
350 chrome_frame_test::CloseAllIEWindows(); | 470 chrome_frame_test::CloseAllIEWindows(); |
351 | 471 |
352 test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort)); | 472 test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort)); |
(...skipping 22 matching lines...) Expand all Loading... | |
375 | 495 |
376 // Override virtual void Initialize to not call icu initialize | 496 // Override virtual void Initialize to not call icu initialize |
377 void CFUrlRequestUnittestRunner::Initialize() { | 497 void CFUrlRequestUnittestRunner::Initialize() { |
378 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 498 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
379 | 499 |
380 // Start by replicating some of the steps that would otherwise be | 500 // Start by replicating some of the steps that would otherwise be |
381 // done by TestSuite::Initialize. We can't call the base class | 501 // done by TestSuite::Initialize. We can't call the base class |
382 // directly because it will attempt to initialize some things such as | 502 // directly because it will attempt to initialize some things such as |
383 // ICU that have already been initialized for this process. | 503 // ICU that have already been initialized for this process. |
384 CFUrlRequestUnittestRunner::InitializeLogging(); | 504 CFUrlRequestUnittestRunner::InitializeLogging(); |
385 base::Time::EnableHighResolutionTimer(true); | |
386 | 505 |
387 SuppressErrorDialogs(); | 506 SuppressErrorDialogs(); |
388 base::debug::SetSuppressDebugUI(true); | 507 base::debug::SetSuppressDebugUI(true); |
389 logging::SetLogAssertHandler(UnitTestAssertHandler); | 508 logging::SetLogAssertHandler(UnitTestAssertHandler); |
390 | 509 |
391 // Next, do some initialization for NetTestSuite. | 510 // Next, do some initialization for NetTestSuite. |
392 NetTestSuite::InitializeTestThread(); | 511 NetTestSuite::InitializeTestThread(); |
393 } | 512 } |
394 | 513 |
395 void CFUrlRequestUnittestRunner::Shutdown() { | 514 void CFUrlRequestUnittestRunner::Shutdown() { |
396 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 515 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
397 NetTestSuite::Shutdown(); | 516 NetTestSuite::Shutdown(); |
398 OleUninitialize(); | 517 OleUninitialize(); |
399 } | 518 } |
400 | 519 |
401 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( | 520 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( |
402 const std::string& channel_id) { | 521 const std::string& channel_id) { |
403 Profile* profile = g_browser_process->profile_manager()-> | 522 Profile* profile = g_browser_process->profile_manager()-> |
404 GetDefaultProfile(fake_chrome_.user_data()); | 523 GetDefaultProfile(fake_chrome_->user_data()); |
405 | 524 |
406 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); | 525 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); |
407 DCHECK(list); | 526 DCHECK(list); |
408 list->AddProvider( | 527 list->AddProvider( |
409 TestAutomationProvider::NewAutomationProvider(profile, channel_id, this)); | 528 TestAutomationProvider::NewAutomationProvider(profile, channel_id, this)); |
410 } | 529 } |
411 | 530 |
412 void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { | 531 void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { |
413 test_http_server_.reset(); | 532 test_http_server_.reset(); |
414 StartTests(); | 533 StartTests(); |
415 } | 534 } |
416 | 535 |
417 void CFUrlRequestUnittestRunner::RunMainUIThread() { | |
418 DCHECK(MessageLoop::current()); | |
419 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); | |
420 MessageLoop::current()->Run(); | |
421 } | |
422 | |
423 void CFUrlRequestUnittestRunner::StartTests() { | 536 void CFUrlRequestUnittestRunner::StartTests() { |
424 if (PromptAfterSetup()) | 537 if (PromptAfterSetup()) |
425 MessageBoxA(NULL, "click ok to run", "", MB_OK); | 538 MessageBoxA(NULL, "click ok to run", "", MB_OK); |
426 | 539 |
427 DCHECK_EQ(test_thread_.IsValid(), false); | 540 DCHECK_EQ(test_thread_.IsValid(), false); |
428 test_thread_.Set(::CreateThread(NULL, 0, RunAllUnittests, this, 0, | 541 test_thread_.Set(::CreateThread(NULL, 0, RunAllUnittests, this, 0, |
429 &test_thread_id_)); | 542 &test_thread_id_)); |
430 DCHECK(test_thread_.IsValid()); | 543 DCHECK(test_thread_.IsValid()); |
431 } | 544 } |
432 | 545 |
433 // static | 546 // static |
434 DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { | 547 DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { |
435 base::PlatformThread::SetName("CFUrlRequestUnittestRunner"); | 548 base::PlatformThread::SetName("CFUrlRequestUnittestRunner"); |
436 // Needed for some url request tests like the intercept job tests, etc. | |
437 NotificationServiceImpl service; | |
438 CFUrlRequestUnittestRunner* me = | 549 CFUrlRequestUnittestRunner* me = |
439 reinterpret_cast<CFUrlRequestUnittestRunner*>(param); | 550 reinterpret_cast<CFUrlRequestUnittestRunner*>(param); |
440 me->test_result_ = me->Run(); | 551 me->test_result_ = me->Run(); |
441 me->fake_chrome_.ui_loop()->PostTask(FROM_HERE, | 552 BrowserThread::PostTask(BrowserThread::UI, |
442 base::Bind(TakeDownBrowser, me)); | 553 FROM_HERE, |
554 base::Bind(TakeDownBrowser, me)); | |
443 return 0; | 555 return 0; |
444 } | 556 } |
445 | 557 |
446 // static | 558 // static |
447 void CFUrlRequestUnittestRunner::TakeDownBrowser( | 559 void CFUrlRequestUnittestRunner::TakeDownBrowser( |
448 CFUrlRequestUnittestRunner* me) { | 560 CFUrlRequestUnittestRunner* me) { |
449 if (PromptAfterSetup()) | 561 if (PromptAfterSetup()) |
450 MessageBoxA(NULL, "click ok to exit", "", MB_OK); | 562 MessageBoxA(NULL, "click ok to exit", "", MB_OK); |
451 | 563 |
452 me->ShutDownHostBrowser(); | 564 me->ShutDownHostBrowser(); |
453 me->fake_chrome_.ui_loop()->PostDelayedTask(FROM_HERE, | 565 BrowserThread::PostDelayedTask(BrowserThread::UI, |
454 new MessageLoop::QuitTask, | 566 FROM_HERE, |
455 TestTimeouts::tiny_timeout_ms()); | 567 new MessageLoop::QuitTask, |
568 TestTimeouts::tiny_timeout_ms()); | |
456 } | 569 } |
457 | 570 |
458 void CFUrlRequestUnittestRunner::InitializeLogging() { | 571 void CFUrlRequestUnittestRunner::InitializeLogging() { |
459 FilePath exe; | 572 FilePath exe; |
460 PathService::Get(base::FILE_EXE, &exe); | 573 PathService::Get(base::FILE_EXE, &exe); |
461 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); | 574 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); |
462 logging::InitLogging( | 575 logging::InitLogging( |
463 log_filename.value().c_str(), | 576 log_filename.value().c_str(), |
464 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 577 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
465 logging::LOCK_LOG_FILE, | 578 logging::LOCK_LOG_FILE, |
466 logging::DELETE_OLD_LOG_FILE, | 579 logging::DELETE_OLD_LOG_FILE, |
467 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 580 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
468 // We want process and thread IDs because we may have multiple processes. | 581 // We want process and thread IDs because we may have multiple processes. |
469 // Note: temporarily enabled timestamps in an effort to catch bug 6361. | 582 // Note: temporarily enabled timestamps in an effort to catch bug 6361. |
470 logging::SetLogItems(true, true, true, true); | 583 logging::SetLogItems(true, true, true, true); |
471 } | 584 } |
472 | 585 |
473 void FilterDisabledTests() { | 586 void CFUrlRequestUnittestRunner::PreEarlyInitialization() { |
474 if (::testing::FLAGS_gtest_filter.length() && | 587 testing::InitGoogleTest(&g_argc, g_argv); |
475 ::testing::FLAGS_gtest_filter.Compare("*") != 0) { | 588 FilterDisabledTests(); |
476 // Don't override user specified filters. | 589 } |
477 return; | |
478 } | |
479 | 590 |
480 const char* disabled_tests[] = { | 591 void CFUrlRequestUnittestRunner::PreCreateThreads() { |
481 // Tests disabled since they're testing the same functionality used | 592 fake_chrome_.reset(new FakeExternalTab()); |
482 // by the TestAutomationProvider. | 593 fake_chrome_->Initialize(); |
483 "URLRequestTest.Intercept", | |
484 "URLRequestTest.InterceptNetworkError", | |
485 "URLRequestTest.InterceptRestartRequired", | |
486 "URLRequestTest.InterceptRespectsCancelMain", | |
487 "URLRequestTest.InterceptRespectsCancelRedirect", | |
488 "URLRequestTest.InterceptRespectsCancelFinal", | |
489 "URLRequestTest.InterceptRespectsCancelInRestart", | |
490 "URLRequestTest.InterceptRedirect", | |
491 "URLRequestTest.InterceptServerError", | |
492 "URLRequestTestFTP.*", | |
493 | 594 |
494 // Tests that are currently not working: | 595 pss_subclass_.reset(new ProcessSingletonSubclass(this)); |
596 EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_->user_data())); | |
597 StartChromeFrameInHostBrowser(); | |
598 } | |
495 | 599 |
496 // Temporarily disabled because they needs user input (login dialog). | 600 void CFUrlRequestUnittestRunner::PreStartThread(BrowserThread::ID identifier) { |
497 "URLRequestTestHTTP.BasicAuth", | 601 FakeBrowserProcessImpl::Global()->PreStartThread(identifier); |
498 "URLRequestTestHTTP.BasicAuthWithCookies", | 602 } |
499 | 603 |
500 // HTTPS tests temporarily disabled due to the certificate error dialog. | 604 void CFUrlRequestUnittestRunner::PostStartThread(BrowserThread::ID identifier) { |
501 // TODO(tommi): The tests currently fail though, so need to fix. | 605 FakeBrowserProcessImpl::Global()->PostStartThread(identifier); |
502 "HTTPSRequestTest.HTTPSMismatchedTest", | 606 } |
503 "HTTPSRequestTest.HTTPSExpiredTest", | |
504 "HTTPSRequestTest.ClientAuthTest", | |
505 | 607 |
506 // Tests chrome's network stack's cache (might not apply to CF). | 608 void CFUrlRequestUnittestRunner::PreMainMessageLoopRun() { |
507 "URLRequestTestHTTP.VaryHeader", | 609 fake_chrome_->InitializePostThreadsCreated(); |
508 "URLRequestTestHTTP.GetZippedTest", | 610 } |
509 | 611 |
510 // I suspect we can only get this one to work (if at all) on IE8 and | 612 bool CFUrlRequestUnittestRunner::MainMessageLoopRun(int* result_code) { |
511 // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags | 613 DCHECK(MessageLoop::current()); |
512 // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx | 614 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
513 "URLRequestTest.DoNotSaveCookies", | |
514 "URLRequestTest.DelayedCookieCallback", | |
515 | 615 |
516 // TODO(ananta): This test has been consistently failing. Disabling it for | 616 // We need to allow IO on the main thread for these tests. |
517 // now. | 617 base::ThreadRestrictions::SetIOAllowed(true); |
518 "URLRequestTestHTTP.GetTest_NoCache", | |
519 | 618 |
520 // These tests have been disabled as the Chrome cookie policies don't make | 619 return false; |
521 // sense or have not been implemented for the host network stack. | 620 } |
522 "URLRequestTest.DoNotSaveCookies_ViaPolicy", | |
523 "URLRequestTest.DoNotSendCookies_ViaPolicy", | |
524 "URLRequestTest.DoNotSaveCookies_ViaPolicy_Async", | |
525 "URLRequestTest.CookiePolicy_ForceSession", | |
526 "URLRequestTest.DoNotSendCookies", | |
527 "URLRequestTest.DoNotSendCookies_ViaPolicy_Async", | |
528 "URLRequestTest.CancelTest_During_OnGetCookies", | |
529 "URLRequestTest.CancelTest_During_OnSetCookie", | |
530 | 621 |
531 // These tests are disabled as the rely on functionality provided by | 622 void CFUrlRequestUnittestRunner::PostMainMessageLoopRun() { |
532 // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. | 623 FakeBrowserProcessImpl::Global()->StartTearDown(); |
533 "URLRequestTestHTTP.ProxyTunnelRedirectTest", | |
534 "URLRequestTestHTTP.UnexpectedServerAuthTest", | |
535 | 624 |
536 // This test is disabled as it expects an empty UA to be echoed back from | 625 // Must do this separately as the mock profile_manager_ is not the |
537 // the server which is not the case in ChromeFrame. | 626 // same member as BrowserProcessImpl::StartTearDown resets. |
538 "URLRequestTestHTTP.DefaultUserAgent", | 627 FakeBrowserProcessImpl::Global()->DestroyProfileManager(); |
539 // This test modifies the UploadData object after it has been marshaled to | |
540 // ChromeFrame. We don't support this. | |
541 "URLRequestTestHTTP.TestPostChunkedDataAfterStart", | |
542 | 628 |
543 // Do not work in CF, it may well be that IE is unconditionally | 629 if (crash_service_) |
544 // adding Accept-Encoding header by default to outgoing requests. | 630 base::KillProcess(crash_service_, 0, false); |
545 "URLRequestTestHTTP.DefaultAcceptEncoding", | |
546 "URLRequestTestHTTP.OverrideAcceptEncoding", | |
547 | 631 |
548 // Not supported in ChromeFrame as we use IE's network stack. | 632 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); |
549 "URLRequestTest.NetworkDelegateProxyError", | 633 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); |
634 } | |
550 | 635 |
551 // URLRequestAutomationJob needs to support NeedsAuth. | 636 void CFUrlRequestUnittestRunner::PreStopThread( |
552 // http://crbug.com/98446 | 637 content::BrowserThread::ID identifier) { |
553 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", | 638 FakeBrowserProcessImpl::Global()->PreStopThread(identifier); |
554 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", | 639 } |
555 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", | |
556 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", | |
557 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", | |
558 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", | |
559 | 640 |
560 // Flaky on the tryservers, http://crbug.com/103097 | 641 void CFUrlRequestUnittestRunner::PostStopThread( |
561 "URLRequestTestHTTP.MultipleRedirectTest", | 642 content::BrowserThread::ID identifier) { |
562 "URLRequestTestHTTP.NetworkDelegateRedirectRequest", | 643 FakeBrowserProcessImpl::Global()->PostStopThread(identifier); |
563 }; | 644 } |
564 | 645 |
565 std::string filter("-"); // All following filters will be negative. | 646 void CFUrlRequestUnittestRunner::PostDestroyThreads() { |
566 for (int i = 0; i < arraysize(disabled_tests); ++i) { | 647 fake_chrome_->Shutdown(); |
567 if (i > 0) | 648 fake_chrome_.reset(); |
568 filter += ":"; | |
569 filter += disabled_tests[i]; | |
570 } | |
571 | 649 |
572 ::testing::FLAGS_gtest_filter = filter; | 650 #ifndef NDEBUG |
651 // Avoid CRT cleanup in debug test runs to ensure that webkit ASSERTs which | |
652 // check if globals are created and destroyed on the same thread don't fire. | |
653 // Webkit global objects are created on the inproc renderer thread. | |
654 ExitProcess(test_result()); | |
655 #endif | |
573 } | 656 } |
574 | 657 |
575 // We need a module since some of the accessibility code that gets pulled | 658 // We need a module since some of the accessibility code that gets pulled |
576 // in here uses ATL. | 659 // in here uses ATL. |
577 class ObligatoryModule: public CAtlExeModuleT<ObligatoryModule> { | 660 class ObligatoryModule: public CAtlExeModuleT<ObligatoryModule> { |
578 public: | 661 public: |
579 static HRESULT InitializeCom() { | 662 static HRESULT InitializeCom() { |
580 return OleInitialize(NULL); | 663 return OleInitialize(NULL); |
581 } | 664 } |
582 | 665 |
(...skipping 18 matching lines...) Expand all Loading... | |
601 return "IE10"; | 684 return "IE10"; |
602 case IE_UNSUPPORTED: | 685 case IE_UNSUPPORTED: |
603 return "Unknown IE Version"; | 686 return "Unknown IE Version"; |
604 case NON_IE: | 687 case NON_IE: |
605 return "Could not find IE"; | 688 return "Could not find IE"; |
606 default: | 689 default: |
607 return "Error."; | 690 return "Error."; |
608 } | 691 } |
609 } | 692 } |
610 | 693 |
694 content::BrowserMainParts* FakeContentBrowserClient::CreateBrowserMainParts( | |
695 const content::MainFunctionParams& parameters) { | |
696 // We never delete this, as the content module takes ownership. | |
697 // | |
698 // We must not construct this earlier, or we will have out-of-order | |
699 // AtExitManager creation/destruction. | |
700 g_test_suite = new CFUrlRequestUnittestRunner(g_argc, g_argv); | |
701 g_test_suite->set_crash_service(chrome_frame_test::StartCrashService()); | |
702 return g_test_suite; | |
703 } | |
704 | |
611 int main(int argc, char** argv) { | 705 int main(int argc, char** argv) { |
612 // TODO(joi): Remove the "true" part here and fix the log statement below. | 706 g_argc = argc; |
613 if (true || chrome_frame_test::GetInstalledIEVersion() >= IE_9) { | 707 g_argv = argv; |
708 | |
709 if (false && chrome_frame_test::GetInstalledIEVersion() >= IE_9) { | |
614 // Adding this here as the command line and the logging stuff gets | 710 // Adding this here as the command line and the logging stuff gets |
615 // initialized in the NetTestSuite constructor. Did not want to break that. | 711 // initialized in the NetTestSuite constructor. Did not want to break that. |
616 base::AtExitManager at_exit_manager; | 712 base::AtExitManager at_exit_manager; |
617 CommandLine::Init(argc, argv); | 713 CommandLine::Init(argc, argv); |
618 CFUrlRequestUnittestRunner::InitializeLogging(); | 714 CFUrlRequestUnittestRunner::InitializeLogging(); |
619 LOG(INFO) << "Temporarily not running any ChromeFrame " | 715 LOG(INFO) << "Not running ChromeFrame net tests on IE9+"; |
620 << "net tests (http://crbug.com/105435)"; | |
621 return 0; | 716 return 0; |
622 } | 717 } |
623 | 718 |
719 // DO NOT SUBMIT | |
624 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | 720 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
625 InitializeCrashReporting(HEADLESS)); | 721 InitializeCrashReporting(HEADLESS)); |
626 | 722 |
627 // TODO(tommi): Stuff be broke. Needs a fixin'. | |
628 // This is awkward: the TestSuite derived CFUrlRequestUnittestRunner contains | |
629 // the instance of the AtExitManager that RegisterPathProvider() and others | |
630 // below require. So we have to instantiate this first. | |
631 CFUrlRequestUnittestRunner test_suite(argc, argv); | |
632 | |
633 // Display the IE version we run with. This must be done after | 723 // Display the IE version we run with. This must be done after |
634 // CFUrlRequestUnittestRunner is constructed since that initializes logging. | 724 // CFUrlRequestUnittestRunner is constructed since that initializes logging. |
635 IEVersion ie_version = chrome_frame_test::GetInstalledIEVersion(); | 725 IEVersion ie_version = chrome_frame_test::GetInstalledIEVersion(); |
636 LOG(INFO) << "Running CF net tests with IE version: " | 726 LOG(INFO) << "Running CF net tests with IE version: " |
637 << IEVersionToString(ie_version); | 727 << IEVersionToString(ie_version); |
638 | 728 |
639 base::ProcessHandle crash_service = chrome_frame_test::StartCrashService(); | |
640 | |
641 WindowWatchdog watchdog; | |
642 // See url_request_unittest.cc for these credentials. | 729 // See url_request_unittest.cc for these credentials. |
643 SupplyProxyCredentials credentials("user", "secret"); | 730 SupplyProxyCredentials credentials("user", "secret"); |
731 WindowWatchdog watchdog; | |
644 watchdog.AddObserver(&credentials, "Windows Security", ""); | 732 watchdog.AddObserver(&credentials, "Windows Security", ""); |
645 testing::InitGoogleTest(&argc, argv); | |
646 FilterDisabledTests(); | |
647 test_suite.RunMainUIThread(); | |
648 | 733 |
649 if (crash_service) | 734 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
650 base::KillProcess(crash_service, 0, false); | 735 // This would normally be done, but is probably not needed for these tests. |
736 // content::InitializeSandboxInfo(&sandbox_info); | |
737 FakeMainDelegate delegate; | |
738 content::ContentMain( | |
739 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), | |
740 &sandbox_info, | |
741 &delegate); | |
651 | 742 |
652 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); | 743 // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
653 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); | 744 return g_test_suite->test_result(); |
654 // Avoid CRT cleanup in debug test runs to ensure that webkit ASSERTs which | |
655 // check if globals are created and destroyed on the same thread don't fire. | |
656 // Webkit global objects are created on the inproc renderer thread. | |
657 #if !defined(NDEBUG) | |
658 ExitProcess(test_suite.test_result()); | |
659 #endif // NDEBUG | |
660 return test_suite.test_result(); | |
661 } | 745 } |
OLD | NEW |