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

Side by Side Diff: content/shell/browser/layout_test/layout_test_browser_main.cc

Issue 2540603004: [Android] Redirect std{in,out,err} to sockets for layout tests. (Closed)
Patch Set: rebase Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/layout_test/layout_test_browser_main.h" 5 #include "content/shell/browser/layout_test/layout_test_browser_main.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/shell/browser/layout_test/blink_test_controller.h" 25 #include "content/shell/browser/layout_test/blink_test_controller.h"
26 #include "content/shell/browser/layout_test/test_info_extractor.h" 26 #include "content/shell/browser/layout_test/test_info_extractor.h"
27 #include "content/shell/browser/shell.h" 27 #include "content/shell/browser/shell.h"
28 #include "content/shell/common/layout_test/layout_test_switches.h" 28 #include "content/shell/common/layout_test/layout_test_switches.h"
29 #include "content/shell/common/shell_switches.h" 29 #include "content/shell/common/shell_switches.h"
30 #include "content/shell/renderer/layout_test/blink_test_helpers.h" 30 #include "content/shell/renderer/layout_test/blink_test_helpers.h"
31 #include "net/base/filename_util.h" 31 #include "net/base/filename_util.h"
32 32
33 #if defined(OS_ANDROID) 33 #if defined(OS_ANDROID)
34 #include "base/run_loop.h" 34 #include "base/run_loop.h"
35 #include "content/shell/browser/layout_test/layout_test_android.h" 35 #include "content/shell/browser/layout_test/scoped_android_configuration.h"
36 #endif 36 #endif
37 37
38 namespace { 38 namespace {
39 39
40 bool RunOneTest( 40 bool RunOneTest(
41 const content::TestInfo& test_info, 41 const content::TestInfo& test_info,
42 bool* ran_at_least_once, 42 bool* ran_at_least_once,
43 const std::unique_ptr<content::BrowserMainRunner>& main_runner) { 43 const std::unique_ptr<content::BrowserMainRunner>& main_runner) {
44 if (!content::BlinkTestController::Get()->PrepareForLayoutTest( 44 if (!content::BlinkTestController::Get()->PrepareForLayoutTest(
45 test_info.url, test_info.current_working_directory, 45 test_info.url, test_info.current_working_directory,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 base::ScopedTempDir browser_context_path_for_layout_tests; 116 base::ScopedTempDir browser_context_path_for_layout_tests;
117 117
118 CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir()); 118 CHECK(browser_context_path_for_layout_tests.CreateUniqueTempDir());
119 CHECK( 119 CHECK(
120 !browser_context_path_for_layout_tests.GetPath().MaybeAsASCII().empty()); 120 !browser_context_path_for_layout_tests.GetPath().MaybeAsASCII().empty());
121 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 121 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
122 switches::kContentShellDataPath, 122 switches::kContentShellDataPath,
123 browser_context_path_for_layout_tests.GetPath().MaybeAsASCII()); 123 browser_context_path_for_layout_tests.GetPath().MaybeAsASCII());
124 124
125 #if defined(OS_ANDROID) 125 #if defined(OS_ANDROID)
126 content::EnsureInitializeForAndroidLayoutTests(); 126 content::ScopedAndroidConfiguration android_configuration;
127 #endif 127 #endif
128 128
129 int exit_code = main_runner->Initialize(parameters); 129 int exit_code = main_runner->Initialize(parameters);
130 DCHECK_LT(exit_code, 0) 130 DCHECK_LT(exit_code, 0)
131 << "BrowserMainRunner::Initialize failed in LayoutTestBrowserMain"; 131 << "BrowserMainRunner::Initialize failed in LayoutTestBrowserMain";
132 132
133 if (exit_code >= 0) 133 if (exit_code >= 0)
134 return exit_code; 134 return exit_code;
135 135
136 #if defined(OS_ANDROID)
137 android_configuration.RedirectStreams();
138 #endif
139
136 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 140 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
137 switches::kCheckLayoutTestSysDeps)) { 141 switches::kCheckLayoutTestSysDeps)) {
138 base::ThreadTaskRunnerHandle::Get()->PostTask( 142 base::ThreadTaskRunnerHandle::Get()->PostTask(
139 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 143 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
140 main_runner->Run(); 144 main_runner->Run();
141 content::Shell::CloseAllWindows(); 145 content::Shell::CloseAllWindows();
142 main_runner->Shutdown(); 146 main_runner->Shutdown();
143 return 0; 147 return 0;
144 } 148 }
145 149
146 exit_code = RunTests(main_runner); 150 exit_code = RunTests(main_runner);
147 base::RunLoop().RunUntilIdle(); 151 base::RunLoop().RunUntilIdle();
148 152
149 content::Shell::CloseAllWindows(); 153 content::Shell::CloseAllWindows();
150 #if !defined(OS_ANDROID) 154 #if !defined(OS_ANDROID)
151 main_runner->Shutdown(); 155 main_runner->Shutdown();
152 #endif 156 #endif
153 157
154 return exit_code; 158 return exit_code;
155 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698