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 30 matching lines...) Expand all Loading... |
106 AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible, | 116 AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible, |
107 reinterpret_cast<void**>(acc.Receive())); | 117 reinterpret_cast<void**>(acc.Receive())); |
108 if (acc) { | 118 if (acc) { |
109 VARIANT self = { VT_I4 }; | 119 VARIANT self = { VT_I4 }; |
110 self.lVal = CHILDID_SELF; | 120 self.lVal = CHILDID_SELF; |
111 ret = SUCCEEDED(acc->accSelect(SELFLAG_TAKEFOCUS, self)); | 121 ret = SUCCEEDED(acc->accSelect(SELFLAG_TAKEFOCUS, self)); |
112 } | 122 } |
113 return ret; | 123 return ret; |
114 } | 124 } |
115 | 125 |
| 126 class FakeContentBrowserClient : public chrome::ChromeContentBrowserClient { |
| 127 public: |
| 128 virtual ~FakeContentBrowserClient() {} |
| 129 |
| 130 virtual content::BrowserMainParts* CreateBrowserMainParts( |
| 131 const content::MainFunctionParams& parameters) OVERRIDE; |
| 132 }; |
| 133 |
| 134 base::LazyInstance<chrome::ChromeContentClient> |
| 135 g_chrome_content_client = LAZY_INSTANCE_INITIALIZER; |
| 136 |
| 137 // Override the default ContentBrowserClient to let Chrome participate in |
| 138 // content logic. Must be done before any tabs are created. |
| 139 base::LazyInstance<FakeContentBrowserClient> |
| 140 g_browser_client = LAZY_INSTANCE_INITIALIZER; |
| 141 |
| 142 base::LazyInstance<chrome::ChromeContentRendererClient> |
| 143 g_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| 144 |
| 145 class FakeMainDelegate : public content::ContentMainDelegate { |
| 146 public: |
| 147 virtual ~FakeMainDelegate() {} |
| 148 |
| 149 virtual bool BasicStartupComplete(int* exit_code) OVERRIDE { |
| 150 return false; |
| 151 } |
| 152 |
| 153 virtual void PreSandboxStartup() OVERRIDE { |
| 154 // Initialize the content client. |
| 155 content::SetContentClient(&g_chrome_content_client.Get()); |
| 156 |
| 157 // Override the default ContentBrowserClient to let Chrome participate in |
| 158 // content logic. We use a subclass of Chrome's implementation, |
| 159 // FakeContentBrowserClient, to override CreateBrowserMainParts. Must |
| 160 // be done before any tabs are created. |
| 161 content::GetContentClient()->set_browser(&g_browser_client.Get()); |
| 162 |
| 163 content::GetContentClient()->set_renderer(&g_renderer_client.Get()); |
| 164 } |
| 165 |
| 166 virtual void SandboxInitialized(const std::string& process_type) OVERRIDE {} |
| 167 |
| 168 virtual int RunProcess( |
| 169 const std::string& process_type, |
| 170 const content::MainFunctionParams& main_function_params) OVERRIDE { |
| 171 return -1; |
| 172 } |
| 173 virtual void ProcessExiting(const std::string& process_type) OVERRIDE {} |
| 174 }; |
| 175 |
| 176 void FilterDisabledTests() { |
| 177 if (::testing::FLAGS_gtest_filter.length() && |
| 178 ::testing::FLAGS_gtest_filter.Compare("*") != 0) { |
| 179 // Don't override user specified filters. |
| 180 return; |
| 181 } |
| 182 |
| 183 const char* disabled_tests[] = { |
| 184 // Tests disabled since they're testing the same functionality used |
| 185 // by the TestAutomationProvider. |
| 186 "URLRequestTest.Intercept", |
| 187 "URLRequestTest.InterceptNetworkError", |
| 188 "URLRequestTest.InterceptRestartRequired", |
| 189 "URLRequestTest.InterceptRespectsCancelMain", |
| 190 "URLRequestTest.InterceptRespectsCancelRedirect", |
| 191 "URLRequestTest.InterceptRespectsCancelFinal", |
| 192 "URLRequestTest.InterceptRespectsCancelInRestart", |
| 193 "URLRequestTest.InterceptRedirect", |
| 194 "URLRequestTest.InterceptServerError", |
| 195 "URLRequestTestFTP.*", |
| 196 |
| 197 // Tests that are currently not working: |
| 198 |
| 199 // Temporarily disabled because they needs user input (login dialog). |
| 200 "URLRequestTestHTTP.BasicAuth", |
| 201 "URLRequestTestHTTP.BasicAuthWithCookies", |
| 202 |
| 203 // HTTPS tests temporarily disabled due to the certificate error dialog. |
| 204 // TODO(tommi): The tests currently fail though, so need to fix. |
| 205 "HTTPSRequestTest.HTTPSMismatchedTest", |
| 206 "HTTPSRequestTest.HTTPSExpiredTest", |
| 207 "HTTPSRequestTest.ClientAuthTest", |
| 208 |
| 209 // Tests chrome's network stack's cache (might not apply to CF). |
| 210 "URLRequestTestHTTP.VaryHeader", |
| 211 "URLRequestTestHTTP.GetZippedTest", |
| 212 |
| 213 // I suspect we can only get this one to work (if at all) on IE8 and |
| 214 // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags |
| 215 // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx |
| 216 "URLRequestTest.DoNotSaveCookies", |
| 217 "URLRequestTest.DelayedCookieCallback", |
| 218 |
| 219 // TODO(ananta): This test has been consistently failing. Disabling it for |
| 220 // now. |
| 221 "URLRequestTestHTTP.GetTest_NoCache", |
| 222 |
| 223 // These tests have been disabled as the Chrome cookie policies don't make |
| 224 // sense or have not been implemented for the host network stack. |
| 225 "URLRequestTest.DoNotSaveCookies_ViaPolicy", |
| 226 "URLRequestTest.DoNotSendCookies_ViaPolicy", |
| 227 "URLRequestTest.DoNotSaveCookies_ViaPolicy_Async", |
| 228 "URLRequestTest.CookiePolicy_ForceSession", |
| 229 "URLRequestTest.DoNotSendCookies", |
| 230 "URLRequestTest.DoNotSendCookies_ViaPolicy_Async", |
| 231 "URLRequestTest.CancelTest_During_OnGetCookies", |
| 232 "URLRequestTest.CancelTest_During_OnSetCookie", |
| 233 |
| 234 // These tests are disabled as the rely on functionality provided by |
| 235 // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. |
| 236 "URLRequestTestHTTP.ProxyTunnelRedirectTest", |
| 237 "URLRequestTestHTTP.UnexpectedServerAuthTest", |
| 238 |
| 239 // This test is disabled as it expects an empty UA to be echoed back from |
| 240 // the server which is not the case in ChromeFrame. |
| 241 "URLRequestTestHTTP.DefaultUserAgent", |
| 242 // This test modifies the UploadData object after it has been marshaled to |
| 243 // ChromeFrame. We don't support this. |
| 244 "URLRequestTestHTTP.TestPostChunkedDataAfterStart", |
| 245 |
| 246 // Do not work in CF, it may well be that IE is unconditionally |
| 247 // adding Accept-Encoding header by default to outgoing requests. |
| 248 "URLRequestTestHTTP.DefaultAcceptEncoding", |
| 249 "URLRequestTestHTTP.OverrideAcceptEncoding", |
| 250 |
| 251 // Not supported in ChromeFrame as we use IE's network stack. |
| 252 "URLRequestTest.NetworkDelegateProxyError", |
| 253 |
| 254 // URLRequestAutomationJob needs to support NeedsAuth. |
| 255 // http://crbug.com/98446 |
| 256 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", |
| 257 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", |
| 258 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", |
| 259 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", |
| 260 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", |
| 261 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", |
| 262 |
| 263 // Flaky on the tryservers, http://crbug.com/103097 |
| 264 "URLRequestTestHTTP.MultipleRedirectTest", |
| 265 "URLRequestTestHTTP.NetworkDelegateRedirectRequest", |
| 266 }; |
| 267 |
| 268 const char* ie9_disabled_tests[] = { |
| 269 // These always hang on Joi's box with IE9, http://crbug.com/105435. |
| 270 // Several other tests, e.g. URLRequestTestHTTP.CancelTest2, 3 and |
| 271 // 5, often hang but not always. |
| 272 "URLRequestTestHTTP.NetworkDelegateRedirectRequestPost", |
| 273 "URLRequestTestHTTP.GetTest", |
| 274 "HTTPSRequestTest.HTTPSPreloadedHSTSTest", |
| 275 }; |
| 276 |
| 277 std::string filter("-"); // All following filters will be negative. |
| 278 for (int i = 0; i < arraysize(disabled_tests); ++i) { |
| 279 if (i > 0) |
| 280 filter += ":"; |
| 281 filter += disabled_tests[i]; |
| 282 } |
| 283 |
| 284 if (chrome_frame_test::GetInstalledIEVersion() >= IE_9) { |
| 285 for (int i = 0; i < arraysize(ie9_disabled_tests); ++i) { |
| 286 filter += ":"; |
| 287 filter += ie9_disabled_tests[i]; |
| 288 } |
| 289 } |
| 290 |
| 291 ::testing::FLAGS_gtest_filter = filter; |
| 292 } |
| 293 |
| 294 } // namespace |
| 295 |
116 // Same as BrowserProcessImpl, but uses custom profile manager. | 296 // Same as BrowserProcessImpl, but uses custom profile manager. |
117 class FakeBrowserProcessImpl : public BrowserProcessImpl { | 297 class FakeBrowserProcessImpl : public BrowserProcessImpl { |
118 public: | 298 public: |
119 explicit FakeBrowserProcessImpl(const CommandLine& command_line) | 299 explicit FakeBrowserProcessImpl(const CommandLine& command_line) |
120 : BrowserProcessImpl(command_line) { | 300 : BrowserProcessImpl(command_line) { |
121 profiles_dir_.CreateUniqueTempDir(); | 301 profiles_dir_.CreateUniqueTempDir(); |
122 } | 302 } |
123 | 303 |
124 virtual ProfileManager* profile_manager() { | 304 virtual ~FakeBrowserProcessImpl() {} |
| 305 |
| 306 virtual ProfileManager* profile_manager() OVERRIDE { |
125 if (!profile_manager_.get()) { | 307 if (!profile_manager_.get()) { |
126 profile_manager_.reset( | 308 profile_manager_.reset( |
127 new ProfileManagerWithoutInit(profiles_dir_.path())); | 309 new ProfileManagerWithoutInit(profiles_dir_.path())); |
128 } | 310 } |
129 return profile_manager_.get(); | 311 return profile_manager_.get(); |
130 } | 312 } |
131 | 313 |
132 virtual MetricsService* metrics_service() { | 314 virtual MetricsService* metrics_service() OVERRIDE { |
133 return NULL; | 315 return NULL; |
134 } | 316 } |
135 | 317 |
| 318 void DestroyProfileManager() { |
| 319 profile_manager_.reset(); |
| 320 } |
| 321 |
136 private: | 322 private: |
137 ScopedTempDir profiles_dir_; | 323 ScopedTempDir profiles_dir_; |
138 scoped_ptr<ProfileManager> profile_manager_; | 324 scoped_ptr<ProfileManager> profile_manager_; |
139 }; | 325 }; |
140 | 326 |
141 base::LazyInstance<chrome::ChromeContentClient> | |
142 g_chrome_content_client = LAZY_INSTANCE_INITIALIZER; | |
143 | |
144 // Override the default ContentBrowserClient to let Chrome participate in | |
145 // content logic. Must be done before any tabs are created. | |
146 base::LazyInstance<chrome::ChromeContentBrowserClient> | |
147 g_browser_client = LAZY_INSTANCE_INITIALIZER; | |
148 | |
149 base::LazyInstance<chrome::ChromeContentRendererClient> | |
150 g_renderer_client = LAZY_INSTANCE_INITIALIZER; | |
151 | |
152 } // namespace | |
153 | |
154 | |
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_; |
162 HWND password_; | 334 HWND password_; |
163 }; | 335 }; |
164 | 336 |
(...skipping 66 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! | 455 FakeBrowserProcessImpl* FakeExternalTab::browser_process() const { |
304 class ChromeFrameFriendOfBrowserProcessImpl { | 456 return browser_process_.get(); |
305 public: | 457 } |
306 static void CreateIOThreadState() { | |
307 reinterpret_cast<BrowserProcessImpl*>( | |
308 g_browser_process)->CreateIOThreadState(); | |
309 } | |
310 }; | |
311 | 458 |
312 CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) | 459 CFUrlRequestUnittestRunner::CFUrlRequestUnittestRunner(int argc, char** argv) |
313 : NetTestSuite(argc, argv), | 460 : NetTestSuite(argc, argv), |
314 chrome_frame_html_("/chrome_frame", kChromeFrameHtml), | 461 chrome_frame_html_("/chrome_frame", kChromeFrameHtml), |
315 registrar_(chrome_frame_test::GetTestBedType()), | 462 registrar_(chrome_frame_test::GetTestBedType()), |
316 test_result_(0) { | 463 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 } | 464 } |
340 | 465 |
341 CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { | 466 CFUrlRequestUnittestRunner::~CFUrlRequestUnittestRunner() { |
342 fake_chrome_.Shutdown(); | |
343 } | 467 } |
344 | 468 |
345 void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { | 469 void CFUrlRequestUnittestRunner::StartChromeFrameInHostBrowser() { |
346 if (!ShouldLaunchBrowser()) | 470 if (!ShouldLaunchBrowser()) |
347 return; | 471 return; |
348 | 472 |
349 base::win::ScopedCOMInitializer com; | 473 base::win::ScopedCOMInitializer com; |
350 chrome_frame_test::CloseAllIEWindows(); | 474 chrome_frame_test::CloseAllIEWindows(); |
351 | 475 |
352 test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort)); | 476 test_http_server_.reset(new test_server::SimpleWebServer(kTestServerPort)); |
(...skipping 22 matching lines...) Expand all Loading... |
375 | 499 |
376 // Override virtual void Initialize to not call icu initialize | 500 // Override virtual void Initialize to not call icu initialize |
377 void CFUrlRequestUnittestRunner::Initialize() { | 501 void CFUrlRequestUnittestRunner::Initialize() { |
378 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 502 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
379 | 503 |
380 // Start by replicating some of the steps that would otherwise be | 504 // Start by replicating some of the steps that would otherwise be |
381 // done by TestSuite::Initialize. We can't call the base class | 505 // done by TestSuite::Initialize. We can't call the base class |
382 // directly because it will attempt to initialize some things such as | 506 // directly because it will attempt to initialize some things such as |
383 // ICU that have already been initialized for this process. | 507 // ICU that have already been initialized for this process. |
384 CFUrlRequestUnittestRunner::InitializeLogging(); | 508 CFUrlRequestUnittestRunner::InitializeLogging(); |
385 base::Time::EnableHighResolutionTimer(true); | |
386 | 509 |
387 SuppressErrorDialogs(); | 510 SuppressErrorDialogs(); |
388 base::debug::SetSuppressDebugUI(true); | 511 base::debug::SetSuppressDebugUI(true); |
389 logging::SetLogAssertHandler(UnitTestAssertHandler); | 512 logging::SetLogAssertHandler(UnitTestAssertHandler); |
390 | 513 |
391 // Next, do some initialization for NetTestSuite. | 514 // Next, do some initialization for NetTestSuite. |
392 NetTestSuite::InitializeTestThread(); | 515 NetTestSuite::InitializeTestThreadNoNetworkChangeNotifier(); |
393 } | 516 } |
394 | 517 |
395 void CFUrlRequestUnittestRunner::Shutdown() { | 518 void CFUrlRequestUnittestRunner::Shutdown() { |
396 DCHECK(::GetCurrentThreadId() == test_thread_id_); | 519 DCHECK(::GetCurrentThreadId() == test_thread_id_); |
397 NetTestSuite::Shutdown(); | 520 NetTestSuite::Shutdown(); |
398 OleUninitialize(); | 521 OleUninitialize(); |
399 } | 522 } |
400 | 523 |
401 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( | 524 void CFUrlRequestUnittestRunner::OnConnectAutomationProviderToChannel( |
402 const std::string& channel_id) { | 525 const std::string& channel_id) { |
403 Profile* profile = g_browser_process->profile_manager()-> | 526 Profile* profile = g_browser_process->profile_manager()-> |
404 GetDefaultProfile(fake_chrome_.user_data()); | 527 GetDefaultProfile(fake_chrome_->user_data()); |
405 | 528 |
406 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); | 529 AutomationProviderList* list = g_browser_process->GetAutomationProviderList(); |
407 DCHECK(list); | 530 DCHECK(list); |
408 list->AddProvider( | 531 list->AddProvider( |
409 TestAutomationProvider::NewAutomationProvider(profile, channel_id, this)); | 532 TestAutomationProvider::NewAutomationProvider(profile, channel_id, this)); |
410 } | 533 } |
411 | 534 |
412 void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { | 535 void CFUrlRequestUnittestRunner::OnInitialTabLoaded() { |
413 test_http_server_.reset(); | 536 test_http_server_.reset(); |
414 StartTests(); | 537 StartTests(); |
415 } | 538 } |
416 | 539 |
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() { | 540 void CFUrlRequestUnittestRunner::StartTests() { |
424 if (PromptAfterSetup()) | 541 if (PromptAfterSetup()) |
425 MessageBoxA(NULL, "click ok to run", "", MB_OK); | 542 MessageBoxA(NULL, "click ok to run", "", MB_OK); |
426 | 543 |
427 DCHECK_EQ(test_thread_.IsValid(), false); | 544 DCHECK_EQ(test_thread_.IsValid(), false); |
428 test_thread_.Set(::CreateThread(NULL, 0, RunAllUnittests, this, 0, | 545 test_thread_.Set(::CreateThread(NULL, 0, RunAllUnittests, this, 0, |
429 &test_thread_id_)); | 546 &test_thread_id_)); |
430 DCHECK(test_thread_.IsValid()); | 547 DCHECK(test_thread_.IsValid()); |
431 } | 548 } |
432 | 549 |
433 // static | 550 // static |
434 DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { | 551 DWORD CFUrlRequestUnittestRunner::RunAllUnittests(void* param) { |
435 base::PlatformThread::SetName("CFUrlRequestUnittestRunner"); | 552 base::PlatformThread::SetName("CFUrlRequestUnittestRunner"); |
436 // Needed for some url request tests like the intercept job tests, etc. | |
437 NotificationServiceImpl service; | |
438 CFUrlRequestUnittestRunner* me = | 553 CFUrlRequestUnittestRunner* me = |
439 reinterpret_cast<CFUrlRequestUnittestRunner*>(param); | 554 reinterpret_cast<CFUrlRequestUnittestRunner*>(param); |
440 me->test_result_ = me->Run(); | 555 me->test_result_ = me->Run(); |
441 me->fake_chrome_.ui_loop()->PostTask(FROM_HERE, | 556 BrowserThread::PostTask(BrowserThread::UI, |
442 base::Bind(TakeDownBrowser, me)); | 557 FROM_HERE, |
| 558 base::Bind(TakeDownBrowser, me)); |
443 return 0; | 559 return 0; |
444 } | 560 } |
445 | 561 |
446 // static | 562 // static |
447 void CFUrlRequestUnittestRunner::TakeDownBrowser( | 563 void CFUrlRequestUnittestRunner::TakeDownBrowser( |
448 CFUrlRequestUnittestRunner* me) { | 564 CFUrlRequestUnittestRunner* me) { |
449 if (PromptAfterSetup()) | 565 if (PromptAfterSetup()) |
450 MessageBoxA(NULL, "click ok to exit", "", MB_OK); | 566 MessageBoxA(NULL, "click ok to exit", "", MB_OK); |
451 | 567 |
452 me->ShutDownHostBrowser(); | 568 me->ShutDownHostBrowser(); |
453 me->fake_chrome_.ui_loop()->PostDelayedTask(FROM_HERE, | 569 BrowserThread::PostDelayedTask(BrowserThread::UI, |
454 MessageLoop::QuitClosure(), | 570 FROM_HERE, |
455 TestTimeouts::tiny_timeout_ms()); | 571 MessageLoop::QuitClosure(), |
| 572 TestTimeouts::tiny_timeout_ms()); |
456 } | 573 } |
457 | 574 |
458 void CFUrlRequestUnittestRunner::InitializeLogging() { | 575 void CFUrlRequestUnittestRunner::InitializeLogging() { |
459 FilePath exe; | 576 FilePath exe; |
460 PathService::Get(base::FILE_EXE, &exe); | 577 PathService::Get(base::FILE_EXE, &exe); |
461 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); | 578 FilePath log_filename = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); |
462 logging::InitLogging( | 579 logging::InitLogging( |
463 log_filename.value().c_str(), | 580 log_filename.value().c_str(), |
464 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 581 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
465 logging::LOCK_LOG_FILE, | 582 logging::LOCK_LOG_FILE, |
466 logging::DELETE_OLD_LOG_FILE, | 583 logging::DELETE_OLD_LOG_FILE, |
467 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); | 584 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); |
468 // We want process and thread IDs because we may have multiple processes. | 585 // We want process and thread IDs because we may have multiple processes. |
469 // Note: temporarily enabled timestamps in an effort to catch bug 6361. | 586 // Note: temporarily enabled timestamps in an effort to catch bug 6361. |
470 logging::SetLogItems(true, true, true, true); | 587 logging::SetLogItems(true, true, true, true); |
471 } | 588 } |
472 | 589 |
473 void FilterDisabledTests() { | 590 void CFUrlRequestUnittestRunner::PreEarlyInitialization() { |
474 if (::testing::FLAGS_gtest_filter.length() && | 591 testing::InitGoogleTest(&g_argc, g_argv); |
475 ::testing::FLAGS_gtest_filter.Compare("*") != 0) { | 592 FilterDisabledTests(); |
476 // Don't override user specified filters. | 593 } |
477 return; | |
478 } | |
479 | 594 |
480 const char* disabled_tests[] = { | 595 void CFUrlRequestUnittestRunner::PreCreateThreads() { |
481 // Tests disabled since they're testing the same functionality used | 596 fake_chrome_.reset(new FakeExternalTab()); |
482 // by the TestAutomationProvider. | 597 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 | 598 |
494 // Tests that are currently not working: | 599 pss_subclass_.reset(new ProcessSingletonSubclass(this)); |
| 600 EXPECT_TRUE(pss_subclass_->Subclass(fake_chrome_->user_data())); |
| 601 StartChromeFrameInHostBrowser(); |
| 602 } |
495 | 603 |
496 // Temporarily disabled because they needs user input (login dialog). | 604 void CFUrlRequestUnittestRunner::PreStartThread(BrowserThread::ID identifier) { |
497 "URLRequestTestHTTP.BasicAuth", | 605 fake_chrome_->browser_process()->PreStartThread(identifier); |
498 "URLRequestTestHTTP.BasicAuthWithCookies", | 606 } |
499 | 607 |
500 // HTTPS tests temporarily disabled due to the certificate error dialog. | 608 void CFUrlRequestUnittestRunner::PostStartThread(BrowserThread::ID identifier) { |
501 // TODO(tommi): The tests currently fail though, so need to fix. | 609 fake_chrome_->browser_process()->PostStartThread(identifier); |
502 "HTTPSRequestTest.HTTPSMismatchedTest", | 610 } |
503 "HTTPSRequestTest.HTTPSExpiredTest", | |
504 "HTTPSRequestTest.ClientAuthTest", | |
505 | 611 |
506 // Tests chrome's network stack's cache (might not apply to CF). | 612 void CFUrlRequestUnittestRunner::PreMainMessageLoopRun() { |
507 "URLRequestTestHTTP.VaryHeader", | 613 fake_chrome_->InitializePostThreadsCreated(); |
508 "URLRequestTestHTTP.GetZippedTest", | 614 } |
509 | 615 |
510 // I suspect we can only get this one to work (if at all) on IE8 and | 616 bool CFUrlRequestUnittestRunner::MainMessageLoopRun(int* result_code) { |
511 // later by using the new INTERNET_OPTION_SUPPRESS_BEHAVIOR flags | 617 DCHECK(MessageLoop::current()); |
512 // See http://msdn.microsoft.com/en-us/library/aa385328(VS.85).aspx | 618 DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_UI); |
513 "URLRequestTest.DoNotSaveCookies", | |
514 "URLRequestTest.DelayedCookieCallback", | |
515 | 619 |
516 // TODO(ananta): This test has been consistently failing. Disabling it for | 620 // We need to allow IO on the main thread for these tests. |
517 // now. | 621 base::ThreadRestrictions::SetIOAllowed(true); |
518 "URLRequestTestHTTP.GetTest_NoCache", | |
519 | 622 |
520 // These tests have been disabled as the Chrome cookie policies don't make | 623 return false; |
521 // sense or have not been implemented for the host network stack. | 624 } |
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 | 625 |
531 // These tests are disabled as the rely on functionality provided by | 626 void CFUrlRequestUnittestRunner::PostMainMessageLoopRun() { |
532 // Chrome's HTTP stack like the ability to set the proxy for a URL, etc. | 627 fake_chrome_->browser_process()->StartTearDown(); |
533 "URLRequestTestHTTP.ProxyTunnelRedirectTest", | |
534 "URLRequestTestHTTP.UnexpectedServerAuthTest", | |
535 | 628 |
536 // This test is disabled as it expects an empty UA to be echoed back from | 629 // Must do this separately as the mock profile_manager_ is not the |
537 // the server which is not the case in ChromeFrame. | 630 // same member as BrowserProcessImpl::StartTearDown resets. |
538 "URLRequestTestHTTP.DefaultUserAgent", | 631 fake_chrome_->browser_process()->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 | 632 |
543 // Do not work in CF, it may well be that IE is unconditionally | 633 if (crash_service_) |
544 // adding Accept-Encoding header by default to outgoing requests. | 634 base::KillProcess(crash_service_, 0, false); |
545 "URLRequestTestHTTP.DefaultAcceptEncoding", | |
546 "URLRequestTestHTTP.OverrideAcceptEncoding", | |
547 | 635 |
548 // Not supported in ChromeFrame as we use IE's network stack. | 636 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); |
549 "URLRequestTest.NetworkDelegateProxyError", | 637 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); |
| 638 } |
550 | 639 |
551 // URLRequestAutomationJob needs to support NeedsAuth. | 640 void CFUrlRequestUnittestRunner::PreStopThread( |
552 // http://crbug.com/98446 | 641 content::BrowserThread::ID identifier) { |
553 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncNoAction", | 642 fake_chrome_->browser_process()->PreStopThread(identifier); |
554 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncSetAuth", | 643 } |
555 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredSyncCancel", | |
556 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncNoAction", | |
557 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncSetAuth", | |
558 "URLRequestTestHTTP.NetworkDelegateOnAuthRequiredAsyncCancel", | |
559 | 644 |
560 // Flaky on the tryservers, http://crbug.com/103097 | 645 void CFUrlRequestUnittestRunner::PostStopThread( |
561 "URLRequestTestHTTP.MultipleRedirectTest", | 646 content::BrowserThread::ID identifier) { |
562 "URLRequestTestHTTP.NetworkDelegateRedirectRequest", | 647 fake_chrome_->browser_process()->PostStopThread(identifier); |
563 }; | 648 } |
564 | 649 |
565 std::string filter("-"); // All following filters will be negative. | 650 void CFUrlRequestUnittestRunner::PostDestroyThreads() { |
566 for (int i = 0; i < arraysize(disabled_tests); ++i) { | 651 fake_chrome_->Shutdown(); |
567 if (i > 0) | 652 fake_chrome_.reset(); |
568 filter += ":"; | |
569 filter += disabled_tests[i]; | |
570 } | |
571 | 653 |
572 ::testing::FLAGS_gtest_filter = filter; | 654 #ifndef NDEBUG |
| 655 // Avoid CRT cleanup in debug test runs to ensure that webkit ASSERTs which |
| 656 // check if globals are created and destroyed on the same thread don't fire. |
| 657 // Webkit global objects are created on the inproc renderer thread. |
| 658 ExitProcess(test_result()); |
| 659 #endif |
573 } | 660 } |
574 | 661 |
575 // We need a module since some of the accessibility code that gets pulled | 662 // We need a module since some of the accessibility code that gets pulled |
576 // in here uses ATL. | 663 // in here uses ATL. |
577 class ObligatoryModule: public CAtlExeModuleT<ObligatoryModule> { | 664 class ObligatoryModule: public CAtlExeModuleT<ObligatoryModule> { |
578 public: | 665 public: |
579 static HRESULT InitializeCom() { | 666 static HRESULT InitializeCom() { |
580 return OleInitialize(NULL); | 667 return OleInitialize(NULL); |
581 } | 668 } |
582 | 669 |
(...skipping 18 matching lines...) Expand all Loading... |
601 return "IE10"; | 688 return "IE10"; |
602 case IE_UNSUPPORTED: | 689 case IE_UNSUPPORTED: |
603 return "Unknown IE Version"; | 690 return "Unknown IE Version"; |
604 case NON_IE: | 691 case NON_IE: |
605 return "Could not find IE"; | 692 return "Could not find IE"; |
606 default: | 693 default: |
607 return "Error."; | 694 return "Error."; |
608 } | 695 } |
609 } | 696 } |
610 | 697 |
| 698 content::BrowserMainParts* FakeContentBrowserClient::CreateBrowserMainParts( |
| 699 const content::MainFunctionParams& parameters) { |
| 700 // We never delete this, as the content module takes ownership. |
| 701 // |
| 702 // We must not construct this earlier, or we will have out-of-order |
| 703 // AtExitManager creation/destruction. |
| 704 g_test_suite = new CFUrlRequestUnittestRunner(g_argc, g_argv); |
| 705 g_test_suite->set_crash_service(chrome_frame_test::StartCrashService()); |
| 706 return g_test_suite; |
| 707 } |
| 708 |
| 709 // We must provide a few functions content/ expects to link with. They |
| 710 // are never called for this executable. |
| 711 int PluginMain(const content::MainFunctionParams& parameters) { |
| 712 NOTREACHED(); |
| 713 return 0; |
| 714 } |
| 715 |
| 716 int PpapiBrokerMain(const content::MainFunctionParams& parameters) { |
| 717 return PluginMain(parameters); |
| 718 } |
| 719 |
| 720 int PpapiPluginMain(const content::MainFunctionParams& parameters) { |
| 721 return PluginMain(parameters); |
| 722 } |
| 723 |
| 724 int WorkerMain(const content::MainFunctionParams& parameters) { |
| 725 return PluginMain(parameters); |
| 726 } |
| 727 |
611 int main(int argc, char** argv) { | 728 int main(int argc, char** argv) { |
612 // TODO(joi): Remove the "true" part here and fix the log statement below. | 729 g_argc = argc; |
| 730 g_argv = argv; |
| 731 |
| 732 // Temporarily disabled, http://crbug.com/105435. |
613 if (true || chrome_frame_test::GetInstalledIEVersion() >= IE_9) { | 733 if (true || chrome_frame_test::GetInstalledIEVersion() >= IE_9) { |
614 // Adding this here as the command line and the logging stuff gets | 734 // Adding this here as the command line and the logging stuff gets |
615 // initialized in the NetTestSuite constructor. Did not want to break that. | 735 // initialized in the NetTestSuite constructor. Did not want to break that. |
616 base::AtExitManager at_exit_manager; | 736 base::AtExitManager at_exit_manager; |
617 CommandLine::Init(argc, argv); | 737 CommandLine::Init(argc, argv); |
618 CFUrlRequestUnittestRunner::InitializeLogging(); | 738 CFUrlRequestUnittestRunner::InitializeLogging(); |
619 LOG(INFO) << "Temporarily not running any ChromeFrame " | 739 LOG(INFO) << "Temporarily not running ChromeFrame net tests."; |
620 << "net tests (http://crbug.com/105435)"; | 740 //LOG(INFO) << "Not running ChromeFrame net tests on IE9+"; |
621 return 0; | 741 return 0; |
622 } | 742 } |
623 | 743 |
624 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | 744 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
625 InitializeCrashReporting(HEADLESS)); | 745 InitializeCrashReporting(HEADLESS)); |
626 | 746 |
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 | 747 // Display the IE version we run with. This must be done after |
634 // CFUrlRequestUnittestRunner is constructed since that initializes logging. | 748 // CFUrlRequestUnittestRunner is constructed since that initializes logging. |
635 IEVersion ie_version = chrome_frame_test::GetInstalledIEVersion(); | 749 IEVersion ie_version = chrome_frame_test::GetInstalledIEVersion(); |
636 LOG(INFO) << "Running CF net tests with IE version: " | 750 LOG(INFO) << "Running CF net tests with IE version: " |
637 << IEVersionToString(ie_version); | 751 << IEVersionToString(ie_version); |
638 | 752 |
639 base::ProcessHandle crash_service = chrome_frame_test::StartCrashService(); | |
640 | |
641 WindowWatchdog watchdog; | |
642 // See url_request_unittest.cc for these credentials. | 753 // See url_request_unittest.cc for these credentials. |
643 SupplyProxyCredentials credentials("user", "secret"); | 754 SupplyProxyCredentials credentials("user", "secret"); |
| 755 WindowWatchdog watchdog; |
644 watchdog.AddObserver(&credentials, "Windows Security", ""); | 756 watchdog.AddObserver(&credentials, "Windows Security", ""); |
645 testing::InitGoogleTest(&argc, argv); | |
646 FilterDisabledTests(); | |
647 test_suite.RunMainUIThread(); | |
648 | 757 |
649 if (crash_service) | 758 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
650 base::KillProcess(crash_service, 0, false); | 759 // This would normally be done, but is probably not needed for these tests. |
| 760 // content::InitializeSandboxInfo(&sandbox_info); |
| 761 FakeMainDelegate delegate; |
| 762 content::ContentMain( |
| 763 reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)), |
| 764 &sandbox_info, |
| 765 &delegate); |
651 | 766 |
652 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); | 767 // Note: In debug builds, we ExitProcess during PostDestroyThreads. |
653 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); | 768 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 } | 769 } |
OLD | NEW |