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