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

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: ugh. 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..a1d78151908e2c2e4f9e03e7751eee824ffc8357 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.
@@ -67,7 +67,7 @@ GURL GetURLForLayoutTest(const std::string& test_name,
// 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::FilePath::StringType wide_path_or_url =
base::SysNativeMBToWide(path_or_url);
base::FilePath local_file(wide_path_or_url);
#else
@@ -75,7 +75,8 @@ GURL GetURLForLayoutTest(const std::string& test_name,
#endif
if (!base::PathExists(local_file)) {
local_file = content::GetWebKitRootDirFilePath()
- .Append(FILE_PATH_LITERAL("LayoutTests")).Append(local_file);
+ .Append(FILE_PATH_LITERAL("LayoutTests"))
+ .Append(local_file);
}
test_url = net::FilePathToFileURL(base::MakeAbsoluteFilePath(local_file));
}
@@ -117,8 +118,8 @@ bool RunOneTest(const std::string& test_string,
bool enable_pixel_dumps;
std::string pixel_hash;
base::FilePath cwd;
- GURL test_url = GetURLForLayoutTest(
- test_string, &cwd, &enable_pixel_dumps, &pixel_hash);
+ GURL test_url =
+ GetURLForLayoutTest(test_string, &cwd, &enable_pixel_dumps, &pixel_hash);
if (!content::WebKitTestController::Get()->PrepareForLayoutTest(
test_url, cwd, enable_pixel_dumps, pixel_hash)) {
return false;
@@ -149,34 +150,30 @@ 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;
if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kCheckLayoutTestSysDeps)) {
+ switches::kCheckLayoutTestSysDeps)) {
base::MessageLoop::current()->PostTask(FROM_HERE,
base::MessageLoop::QuitClosure());
main_runner->Run();
@@ -185,46 +182,40 @@ 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
« no previous file with comments | « content/shell/browser/layout_test/layout_test_browser_main.h ('k') | content/shell/browser/shell_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698