| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/in_process_browser_test.h" | 5 #include "chrome/test/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/test/test_file_util.h" | 11 #include "base/test/test_file_util.h" |
| 12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
| 13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
| 16 #include "chrome/browser/browser_window.h" | 16 #include "chrome/browser/browser_window.h" |
| 17 #include "chrome/browser/chrome_thread.h" | 17 #include "chrome/browser/chrome_thread.h" |
| 18 #include "chrome/browser/intranet_redirect_detector.h" |
| 18 #include "chrome/browser/net/url_request_mock_util.h" | 19 #include "chrome/browser/net/url_request_mock_util.h" |
| 19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/profile_manager.h" | 21 #include "chrome/browser/profile_manager.h" |
| 21 #include "chrome/browser/renderer_host/render_process_host.h" | 22 #include "chrome/browser/renderer_host/render_process_host.h" |
| 22 #include "chrome/browser/tab_contents/tab_contents.h" | 23 #include "chrome/browser/tab_contents/tab_contents.h" |
| 23 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 24 #include "chrome/browser/views/frame/browser_view.h" | 25 #include "chrome/browser/views/frame/browser_view.h" |
| 25 #endif | 26 #endif |
| 26 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/main_function_params.h" | 30 #include "chrome/common/main_function_params.h" |
| 30 #include "chrome/common/notification_registrar.h" | 31 #include "chrome/common/notification_registrar.h" |
| 31 #include "chrome/common/notification_type.h" | 32 #include "chrome/common/notification_type.h" |
| 32 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 33 #include "chrome/test/testing_browser_process.h" | 34 #include "chrome/test/testing_browser_process.h" |
| 34 #include "chrome/test/ui_test_utils.h" | 35 #include "chrome/test/ui_test_utils.h" |
| 36 #include "net/base/mock_host_resolver.h" |
| 35 #include "sandbox/src/dep.h" | 37 #include "sandbox/src/dep.h" |
| 36 | 38 |
| 37 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) |
| 38 #include "base/singleton.h" | 40 #include "base/singleton.h" |
| 39 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" | 41 #include "chrome/browser/renderer_host/render_sandbox_host_linux.h" |
| 40 #include "chrome/browser/zygote_host_linux.h" | 42 #include "chrome/browser/zygote_host_linux.h" |
| 41 | 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 44 // A helper class to do Linux-only initialization only once per process. | 46 // A helper class to do Linux-only initialization only once per process. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 69 | 71 |
| 70 InProcessBrowserTest::InProcessBrowserTest() | 72 InProcessBrowserTest::InProcessBrowserTest() |
| 71 : browser_(NULL), | 73 : browser_(NULL), |
| 72 show_window_(false), | 74 show_window_(false), |
| 73 dom_automation_enabled_(false), | 75 dom_automation_enabled_(false), |
| 74 single_process_(false), | 76 single_process_(false), |
| 75 original_single_process_(false), | 77 original_single_process_(false), |
| 76 initial_timeout_(kInitialTimeoutInMS) { | 78 initial_timeout_(kInitialTimeoutInMS) { |
| 77 } | 79 } |
| 78 | 80 |
| 81 InProcessBrowserTest::~InProcessBrowserTest() { |
| 82 } |
| 83 |
| 79 void InProcessBrowserTest::SetUp() { | 84 void InProcessBrowserTest::SetUp() { |
| 80 // Cleanup the user data dir. | 85 // Cleanup the user data dir. |
| 81 FilePath user_data_dir; | 86 FilePath user_data_dir; |
| 82 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 87 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 83 ASSERT_LT(10, static_cast<int>(user_data_dir.value().size())) << | 88 ASSERT_LT(10, static_cast<int>(user_data_dir.value().size())) << |
| 84 "The user data directory name passed into this test was too " | 89 "The user data directory name passed into this test was too " |
| 85 "short to delete safely. Please check the user-data-dir " | 90 "short to delete safely. Please check the user-data-dir " |
| 86 "argument and try again."; | 91 "argument and try again."; |
| 87 if (ShouldDeleteProfile()) | 92 if (ShouldDeleteProfile()) |
| 88 ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true)); | 93 ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Enable warning level logging so that we can see when bad stuff happens. | 150 // Enable warning level logging so that we can see when bad stuff happens. |
| 146 command_line->AppendSwitch(switches::kEnableLogging); | 151 command_line->AppendSwitch(switches::kEnableLogging); |
| 147 command_line->AppendSwitchWithValue(switches::kLoggingLevel, | 152 command_line->AppendSwitchWithValue(switches::kLoggingLevel, |
| 148 IntToWString(1)); // warning | 153 IntToWString(1)); // warning |
| 149 | 154 |
| 150 SandboxInitWrapper sandbox_wrapper; | 155 SandboxInitWrapper sandbox_wrapper; |
| 151 MainFunctionParams params(*command_line, sandbox_wrapper, NULL); | 156 MainFunctionParams params(*command_line, sandbox_wrapper, NULL); |
| 152 params.ui_task = | 157 params.ui_task = |
| 153 NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop); | 158 NewRunnableMethod(this, &InProcessBrowserTest::RunTestOnMainThreadLoop); |
| 154 | 159 |
| 155 host_resolver_ = new net::RuleBasedHostResolverProc(NULL); | 160 host_resolver_ = new net::RuleBasedHostResolverProc( |
| 161 new IntranetRedirectHostResolverProc(NULL)); |
| 156 | 162 |
| 157 // Something inside the browser does this lookup implicitly. Make it fail | 163 // Something inside the browser does this lookup implicitly. Make it fail |
| 158 // to avoid external dependency. It won't break the tests. | 164 // to avoid external dependency. It won't break the tests. |
| 159 host_resolver_->AddSimulatedFailure("*.google.com"); | 165 host_resolver_->AddSimulatedFailure("*.google.com"); |
| 160 | 166 |
| 161 // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol | 167 // See http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol |
| 162 // We don't want the test code to use it. | 168 // We don't want the test code to use it. |
| 163 host_resolver_->AddSimulatedFailure("wpad"); | 169 host_resolver_->AddSimulatedFailure("wpad"); |
| 164 | 170 |
| 165 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc( | 171 net::ScopedDefaultHostResolverProc scoped_host_resolver_proc( |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), | 303 NewRunnableMethod(this, &InProcessBrowserTest::TimedOut), |
| 298 kSubsequentTimeoutInMS); | 304 kSubsequentTimeoutInMS); |
| 299 | 305 |
| 300 MessageLoopForUI::current()->Quit(); | 306 MessageLoopForUI::current()->Quit(); |
| 301 } | 307 } |
| 302 | 308 |
| 303 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { | 309 void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { |
| 304 DCHECK_GT(timeout_value, 0); | 310 DCHECK_GT(timeout_value, 0); |
| 305 initial_timeout_ = timeout_value; | 311 initial_timeout_ = timeout_value; |
| 306 } | 312 } |
| OLD | NEW |