Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2695)

Unified Diff: content/shell/browser/layout_test/layout_test_browser_main.cc

Issue 661943002: Content Shell: Fix broken test controller lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698