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

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: Fixing nits. 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..e0c2fdbfc4ff26ef050f2a30d6554f405ba33672 100644
--- a/content/shell/browser/layout_test/layout_test_browser_main.cc
+++ b/content/shell/browser/layout_test/layout_test_browser_main.cc
@@ -147,6 +147,43 @@ bool RunOneTest(const std::string& test_string,
return true;
}
+int RunTests(const scoped_ptr<content::BrowserMainRunner>& main_runner) {
+ 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)
+ // We need to execute 'main_runner->Shutdown()' before the test_controller
+ // destructs when running on Android, and after it destructs when running
+ // anywhere else.
+ main_runner->Shutdown();
+#endif
+
+ return 0;
+}
+
} // namespace
// Main routine for running as the Browser process.
@@ -182,38 +219,7 @@ int LayoutTestBrowserMain(
return 0;
}
- 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();
-#endif
-
- exit_code = 0;
+ exit_code = RunTests(main_runner);
Peter Beverloo 2014/10/18 09:17:58 Hmm. RunTests never returns anything that's non-ze
#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