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 "content/public/test/browser_test_base.h" | 5 #include "content/public/test/browser_test_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/stack_trace.h" | 11 #include "base/debug/stack_trace.h" |
| 12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/i18n/icu_util.h" | 13 #include "base/i18n/icu_util.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "base/test/scoped_command_line.h" | |
| 20 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
| 21 #include "base/threading/sequenced_worker_pool.h" | 22 #include "base/threading/sequenced_worker_pool.h" |
| 22 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "content/browser/renderer_host/render_process_host_impl.h" | 25 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 25 #include "content/browser/tracing/tracing_controller_impl.h" | 26 #include "content/browser/tracing/tracing_controller_impl.h" |
| 26 #include "content/public/app/content_main.h" | 27 #include "content/public/app/content_main.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/common/main_function_params.h" | 30 #include "content/public/common/main_function_params.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 "does not run and reports a false positive result."; | 145 "does not run and reports a false positive result."; |
| 145 } | 146 } |
| 146 | 147 |
| 147 void BrowserTestBase::SetUp() { | 148 void BrowserTestBase::SetUp() { |
| 148 set_up_called_ = true; | 149 set_up_called_ = true; |
| 149 // ContentTestSuiteBase might have already initialized | 150 // ContentTestSuiteBase might have already initialized |
| 150 // MaterialDesignController in browser_tests suite. | 151 // MaterialDesignController in browser_tests suite. |
| 151 // Uninitialize here to let the browser process do it. | 152 // Uninitialize here to let the browser process do it. |
| 152 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 153 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
| 153 | 154 |
| 154 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 155 base::test::ScopedCommandLine scoped_command_line; |
|
Ilya Sherman
2017/05/25 22:48:12
I don't think it should be necessary to use a Scop
| |
| 156 base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine(); | |
| 155 | 157 |
| 156 // Override the child process connection timeout since tests can exceed that | 158 // Override the child process connection timeout since tests can exceed that |
| 157 // when sharded. | 159 // when sharded. |
| 158 command_line->AppendSwitchASCII( | 160 command_line->AppendSwitchASCII( |
| 159 switches::kIPCConnectionTimeout, | 161 switches::kIPCConnectionTimeout, |
| 160 base::Int64ToString(TestTimeouts::action_max_timeout().InSeconds())); | 162 base::Int64ToString(TestTimeouts::action_max_timeout().InSeconds())); |
| 161 | 163 |
| 162 // The tests assume that file:// URIs can freely access other file:// URIs. | 164 // The tests assume that file:// URIs can freely access other file:// URIs. |
| 163 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 165 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
| 164 | 166 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 SetUpInProcessBrowserTestFixture(); | 236 SetUpInProcessBrowserTestFixture(); |
| 235 | 237 |
| 236 // At this point, copy features to the command line, since BrowserMain will | 238 // At this point, copy features to the command line, since BrowserMain will |
| 237 // wipe out the current feature list. | 239 // wipe out the current feature list. |
| 238 std::string enabled_features; | 240 std::string enabled_features; |
| 239 std::string disabled_features; | 241 std::string disabled_features; |
| 240 if (base::FeatureList::GetInstance()) | 242 if (base::FeatureList::GetInstance()) |
| 241 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, | 243 base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features, |
| 242 &disabled_features); | 244 &disabled_features); |
| 243 if (!enabled_features.empty()) | 245 if (!enabled_features.empty()) |
| 244 command_line->AppendSwitchASCII(switches::kEnableFeatures, | 246 command_line->ReplaceSwitchASCIIForTesting(switches::kEnableFeatures, |
| 245 enabled_features); | 247 enabled_features); |
|
Ilya Sherman
2017/05/25 22:48:12
I don't think that it's appropriate to just replac
chaopeng
2017/05/26 00:57:41
This is good to prevent teams using commandline to
| |
| 246 if (!disabled_features.empty()) | 248 if (!disabled_features.empty()) |
| 247 command_line->AppendSwitchASCII(switches::kDisableFeatures, | 249 command_line->ReplaceSwitchASCIIForTesting(switches::kDisableFeatures, |
| 248 disabled_features); | 250 disabled_features); |
| 249 | 251 |
| 250 // Need to wipe feature list clean, since BrowserMain calls | 252 // Need to wipe feature list clean, since BrowserMain calls |
| 251 // FeatureList::SetInstance, which expects no instance to exist. | 253 // FeatureList::SetInstance, which expects no instance to exist. |
| 252 base::FeatureList::ClearInstanceForTesting(); | 254 base::FeatureList::ClearInstanceForTesting(); |
| 253 | 255 |
| 254 base::Closure* ui_task = | 256 base::Closure* ui_task = |
| 255 new base::Closure( | 257 new base::Closure( |
| 256 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, | 258 base::Bind(&BrowserTestBase::ProxyRunTestOnMainThreadLoop, |
| 257 base::Unretained(this))); | 259 base::Unretained(this))); |
| 258 | 260 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 if (mojo_rules.empty()) | 410 if (mojo_rules.empty()) |
| 409 return; | 411 return; |
| 410 | 412 |
| 411 mojom::NetworkServiceTestPtr network_service_test; | 413 mojom::NetworkServiceTestPtr network_service_test; |
| 412 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( | 414 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( |
| 413 mojom::kNetworkServiceName, &network_service_test); | 415 mojom::kNetworkServiceName, &network_service_test); |
| 414 network_service_test->AddRules(std::move(mojo_rules)); | 416 network_service_test->AddRules(std::move(mojo_rules)); |
| 415 } | 417 } |
| 416 | 418 |
| 417 } // namespace content | 419 } // namespace content |
| OLD | NEW |