Chromium Code Reviews| Index: content/shell/browser/layout_test/layout_test_browser_main.cc |
| diff --git a/content/shell/browser/layout_test/layout_test_browser_main.cc b/content/shell/browser/layout_test/layout_test_browser_main.cc |
| index 8d0cc6316d407fbc8b4d66f32513506a385bc024..3f64233fe20a71a7939f0a62c0120bc0a91935aa 100644 |
| --- a/content/shell/browser/layout_test/layout_test_browser_main.cc |
| +++ b/content/shell/browser/layout_test/layout_test_browser_main.cc |
| @@ -149,7 +149,8 @@ bool RunOneTest(const std::string& test_string, |
| } // namespace |
| -// Main routine for running as the Browser process. |
| + |
| + |
|
Mike West
2014/10/17 10:44:35
Oops.
|
| int LayoutTestBrowserMain( |
| const content::MainFunctionParams& parameters, |
| const scoped_ptr<content::BrowserMainRunner>& main_runner) { |
| @@ -167,13 +168,13 @@ int LayoutTestBrowserMain( |
| int exit_code = main_runner->Initialize(parameters); |
| DCHECK_LT(exit_code, 0) |
| - << "BrowserMainRunner::Initialize failed in LayoutTestBrowserMain"; |
| + << "BrowserMainRunner::Initialize failed in ShellBrowserMain"; |
|
Mike West
2014/10/17 10:44:35
Oops.
|
| if (exit_code >= 0) |
| return exit_code; |
| if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kCheckLayoutTestSysDeps)) { |
| + switches::kCheckLayoutTestSysDeps)) { |
| base::MessageLoop::current()->PostTask(FROM_HERE, |
| base::MessageLoop::QuitClosure()); |
| main_runner->Run(); |
| @@ -182,38 +183,43 @@ int LayoutTestBrowserMain( |
| return 0; |
| } |
| - content::WebKitTestController test_controller; |
| + // Scope the test_controller to this block: We need to execute |
| + // 'main_runner->Shutdown()' before the test_controller destructs when running |
| + // on Android, and after it destructs when running anywhere else. |
| { |
|
Mike West
2014/10/17 10:44:35
Might make sense to move this to a separate functi
|
| - // We're outside of the message loop here, and this is a test. |
| - base::ThreadRestrictions::ScopedAllowIO allow_io; |
| - base::FilePath temp_path; |
| - base::GetTempDir(&temp_path); |
| - test_controller.SetTempPath(temp_path); |
| - } |
| - std::string test_string; |
| - CommandLine::StringVector args = CommandLine::ForCurrentProcess()->GetArgs(); |
| - size_t command_line_position = 0; |
| - bool ran_at_least_once = false; |
| - |
| - std::cout << "#READY\n"; |
| - std::cout.flush(); |
| - |
| - while (GetNextTest(args, &command_line_position, &test_string)) { |
| - if (!RunOneTest(test_string, &ran_at_least_once, main_runner)) |
| - break; |
| - } |
| - if (!ran_at_least_once) { |
| - base::MessageLoop::current()->PostTask(FROM_HERE, |
| - base::MessageLoop::QuitClosure()); |
| - main_runner->Run(); |
| - } |
| + content::WebKitTestController test_controller; |
| + { |
| + // We're outside of the message loop here, and this is a test. |
| + base::ThreadRestrictions::ScopedAllowIO allow_io; |
| + base::FilePath temp_path; |
| + base::GetTempDir(&temp_path); |
| + test_controller.SetTempPath(temp_path); |
| + } |
| + std::string test_string; |
| + CommandLine::StringVector args = |
| + CommandLine::ForCurrentProcess()->GetArgs(); |
| + size_t command_line_position = 0; |
| + bool ran_at_least_once = false; |
| + |
| + std::cout << "#READY\n"; |
| + std::cout.flush(); |
| + |
| + while (GetNextTest(args, &command_line_position, &test_string)) { |
| + if (!RunOneTest(test_string, &ran_at_least_once, main_runner)) |
| + break; |
| + } |
| + if (!ran_at_least_once) { |
| + base::MessageLoop::current()->PostTask(FROM_HERE, |
| + base::MessageLoop::QuitClosure()); |
| + main_runner->Run(); |
| + } |
| #if defined(OS_ANDROID) |
| - // Android should only execute Shutdown() here when running layout tests. |
| - main_runner->Shutdown(); |
| + main_runner->Shutdown(); |
| #endif |
| - exit_code = 0; |
| + exit_code = 0; |
| + } |
| #if !defined(OS_ANDROID) |
| main_runner->Shutdown(); |