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

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

Issue 649223004: Content Shell: Introduce LayoutTestBrowserMain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@LayoutTestURLRequestContextGetter
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
Index: content/shell/browser/layout_test/layout_test_browser_main.cc
diff --git a/content/shell/browser/shell_browser_main.cc b/content/shell/browser/layout_test/layout_test_browser_main.cc
similarity index 73%
copy from content/shell/browser/shell_browser_main.cc
copy to content/shell/browser/layout_test/layout_test_browser_main.cc
index 8881a2ee21253a948a72ac16b7f7d90362c7a68d..f258d37391fce551ac8e566d278f773993c2f896 100644
--- a/content/shell/browser/shell_browser_main.cc
+++ b/content/shell/browser/layout_test/layout_test_browser_main.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -66,13 +66,8 @@ GURL GetURLForLayoutTest(const std::string& test_name,
if (!(test_url.is_valid() && test_url.has_scheme())) {
// We're outside of the message loop here, and this is a test.
base::ThreadRestrictions::ScopedAllowIO allow_io;
-#if defined(OS_WIN)
- std::wstring wide_path_or_url =
- base::SysNativeMBToWide(path_or_url);
- base::FilePath local_file(wide_path_or_url);
-#else
- base::FilePath local_file(path_or_url);
-#endif
+ base::FilePath::StringType local_file_path(path_or_url);
+ base::FilePath local_file(local_file_path);
if (!base::PathExists(local_file)) {
local_file = content::GetWebKitRootDirFilePath()
.Append(FILE_PATH_LITERAL("LayoutTests")).Append(local_file);
@@ -149,28 +144,24 @@ bool RunOneTest(const std::string& test_string,
} // namespace
// Main routine for running as the Browser process.
-int ShellBrowserMain(
+int LayoutTestBrowserMain(
const content::MainFunctionParams& parameters,
const scoped_ptr<content::BrowserMainRunner>& main_runner) {
- bool layout_test_mode =
- CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree);
base::ScopedTempDir browser_context_path_for_layout_tests;
- if (layout_test_mode) {
- CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());
- CHECK(!browser_context_path_for_layout_tests.path().MaybeAsASCII().empty());
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kContentShellDataPath,
- browser_context_path_for_layout_tests.path().MaybeAsASCII());
+ CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());
+ CHECK(!browser_context_path_for_layout_tests.path().MaybeAsASCII().empty());
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kContentShellDataPath,
+ browser_context_path_for_layout_tests.path().MaybeAsASCII());
#if defined(OS_ANDROID)
- content::EnsureInitializeForAndroidLayoutTests();
+ content::EnsureInitializeForAndroidLayoutTests();
#endif
- }
int exit_code = main_runner->Initialize(parameters);
DCHECK_LT(exit_code, 0)
- << "BrowserMainRunner::Initialize failed in ShellBrowserMain";
+ << "BrowserMainRunner::Initialize failed in LayoutTestBrowserMain";
if (exit_code >= 0)
return exit_code;
@@ -185,46 +176,41 @@ int ShellBrowserMain(
return 0;
}
- if (layout_test_mode) {
- 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();
- }
+ 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();
+ // Android should only execute Shutdown() here when running layout tests.
+ main_runner->Shutdown();
#endif
- exit_code = 0;
- }
+ exit_code = 0;
#if !defined(OS_ANDROID)
- if (!layout_test_mode)
- exit_code = main_runner->Run();
-
main_runner->Shutdown();
#endif

Powered by Google App Engine
This is Rietveld 408576698