OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell_browser_main.h" | 5 #include "content/shell/shell_browser_main.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "content/public/browser/browser_main_runner.h" | 11 #include "content/public/browser/browser_main_runner.h" |
12 #include "content/shell/layout_test_controller_host.h" | 12 #include "content/shell/layout_test_controller_host.h" |
13 #include "content/shell/shell.h" | 13 #include "content/shell/shell.h" |
14 #include "content/shell/shell_browser_context.h" | 14 #include "content/shell/shell_browser_context.h" |
15 #include "content/shell/shell_content_browser_client.h" | 15 #include "content/shell/shell_content_browser_client.h" |
16 #include "content/shell/shell_switches.h" | 16 #include "content/shell/shell_switches.h" |
17 #include "webkit/support/webkit_support.h" | 17 #include "webkit/support/webkit_support.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 GURL GetURLForLayoutTest(const char* test_name, | 21 GURL GetURLForLayoutTest(const char* test_name, |
22 std::string* expected_pixel_hash) { | 22 std::string* expected_pixel_hash) { |
23 #if defined(OS_ANDROID) | |
24 // DumpRenderTree is not currently supported for Android using the content | |
25 // shell. | |
26 NOTIMPLEMENTED(); | |
27 return GURL::EmptyGURL(); | |
28 #else | |
29 std::string path_or_url = test_name; | 23 std::string path_or_url = test_name; |
30 std::string pixel_hash; | 24 std::string pixel_hash; |
31 std::string::size_type separator_position = path_or_url.find('\''); | 25 std::string::size_type separator_position = path_or_url.find('\''); |
32 if (separator_position != std::string::npos) { | 26 if (separator_position != std::string::npos) { |
33 pixel_hash = path_or_url.substr(separator_position + 1); | 27 pixel_hash = path_or_url.substr(separator_position + 1); |
34 path_or_url.erase(separator_position); | 28 path_or_url.erase(separator_position); |
35 } | 29 } |
36 if (expected_pixel_hash) | 30 if (expected_pixel_hash) |
37 *expected_pixel_hash = pixel_hash; | 31 *expected_pixel_hash = pixel_hash; |
38 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); | 32 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); |
39 { | 33 { |
40 // We're outside of the message loop here, and this is a test. | 34 // We're outside of the message loop here, and this is a test. |
41 base::ThreadRestrictions::ScopedAllowIO allow_io; | 35 base::ThreadRestrictions::ScopedAllowIO allow_io; |
42 webkit_support::SetCurrentDirectoryForFileURL(test_url); | 36 webkit_support::SetCurrentDirectoryForFileURL(test_url); |
43 } | 37 } |
44 return test_url; | 38 return test_url; |
45 #endif | |
46 } | 39 } |
47 | 40 |
48 } // namespace | 41 } // namespace |
49 | 42 |
50 // Main routine for running as the Browser process. | 43 // Main routine for running as the Browser process. |
51 int ShellBrowserMain(const content::MainFunctionParams& parameters) { | 44 int ShellBrowserMain(const content::MainFunctionParams& parameters) { |
52 scoped_ptr<content::BrowserMainRunner> main_runner_( | 45 scoped_ptr<content::BrowserMainRunner> main_runner_( |
53 content::BrowserMainRunner::Create()); | 46 content::BrowserMainRunner::Create()); |
54 | 47 |
55 int exit_code = main_runner_->Initialize(parameters); | 48 int exit_code = main_runner_->Initialize(parameters); |
56 | 49 |
57 if (exit_code >= 0) | 50 if (exit_code >= 0) |
58 return exit_code; | 51 return exit_code; |
59 | 52 |
60 if (CommandLine::ForCurrentProcess()->HasSwitch( | 53 if (CommandLine::ForCurrentProcess()->HasSwitch( |
61 switches::kCheckLayoutTestSysDeps)) { | 54 switches::kCheckLayoutTestSysDeps)) { |
62 return 0; | 55 return 0; |
63 } | 56 } |
64 | 57 |
65 bool layout_test_mode = | 58 bool layout_test_mode = |
66 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree); | 59 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree); |
67 | 60 |
68 if (layout_test_mode) { | 61 if (layout_test_mode) { |
69 char test_string[2048]; | 62 char test_string[2048]; |
70 content::ShellBrowserContext* browser_context = | 63 content::ShellBrowserContext* browser_context = |
71 static_cast<content::ShellContentBrowserClient*>( | 64 static_cast<content::ShellContentBrowserClient*>( |
72 content::GetContentClient()->browser())->browser_context(); | 65 content::GetContentClient()->browser())->browser_context(); |
73 | 66 |
| 67 #if defined(OS_ANDROID) |
| 68 puts("#READY"); |
| 69 fflush(stdout); |
| 70 #endif |
| 71 |
74 while (fgets(test_string, sizeof(test_string), stdin)) { | 72 while (fgets(test_string, sizeof(test_string), stdin)) { |
75 char *new_line_position = strchr(test_string, '\n'); | 73 char *new_line_position = strchr(test_string, '\n'); |
76 if (new_line_position) | 74 if (new_line_position) |
77 *new_line_position = '\0'; | 75 *new_line_position = '\0'; |
78 if (test_string[0] == '\0') | 76 if (test_string[0] == '\0') |
79 continue; | 77 continue; |
80 | 78 |
81 // Test header. | 79 // Test header. |
82 printf("Content-Type: text/plain\n"); | 80 printf("Content-Type: text/plain\n"); |
83 | 81 |
(...skipping 17 matching lines...) Expand all Loading... |
101 } | 99 } |
102 exit_code = 0; | 100 exit_code = 0; |
103 } else { | 101 } else { |
104 exit_code = main_runner_->Run(); | 102 exit_code = main_runner_->Run(); |
105 } | 103 } |
106 | 104 |
107 main_runner_->Shutdown(); | 105 main_runner_->Shutdown(); |
108 | 106 |
109 return exit_code; | 107 return exit_code; |
110 } | 108 } |
OLD | NEW |