| 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/shell.h" | |
| 13 #include "content/shell/shell_browser_context.h" | |
| 14 #include "content/shell/shell_content_browser_client.h" | |
| 15 #include "content/shell/shell_switches.h" | 12 #include "content/shell/shell_switches.h" |
| 16 #include "content/shell/webkit_test_runner_host.h" | 13 #include "content/shell/webkit_test_runner_host.h" |
| 17 #include "webkit/support/webkit_support.h" | 14 #include "webkit/support/webkit_support.h" |
| 18 | 15 |
| 19 namespace { | 16 namespace { |
| 20 | 17 |
| 21 GURL GetURLForLayoutTest(const char* test_name, | 18 GURL GetURLForLayoutTest(const char* test_name, |
| 22 std::string* expected_pixel_hash) { | 19 std::string* expected_pixel_hash) { |
| 23 std::string path_or_url = test_name; | 20 std::string path_or_url = test_name; |
| 24 std::string pixel_hash; | 21 std::string pixel_hash; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 | 49 |
| 53 if (CommandLine::ForCurrentProcess()->HasSwitch( | 50 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 54 switches::kCheckLayoutTestSysDeps)) { | 51 switches::kCheckLayoutTestSysDeps)) { |
| 55 return 0; | 52 return 0; |
| 56 } | 53 } |
| 57 | 54 |
| 58 bool layout_test_mode = | 55 bool layout_test_mode = |
| 59 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree); | 56 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree); |
| 60 | 57 |
| 61 if (layout_test_mode) { | 58 if (layout_test_mode) { |
| 59 content::WebKitTestController test_controller; |
| 60 |
| 62 char test_string[2048]; | 61 char test_string[2048]; |
| 63 content::ShellBrowserContext* browser_context = | |
| 64 static_cast<content::ShellContentBrowserClient*>( | |
| 65 content::GetContentClient()->browser())->browser_context(); | |
| 66 | |
| 67 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 68 puts("#READY"); | 63 puts("#READY"); |
| 69 fflush(stdout); | 64 fflush(stdout); |
| 70 #endif | 65 #endif |
| 71 | 66 |
| 72 while (fgets(test_string, sizeof(test_string), stdin)) { | 67 while (fgets(test_string, sizeof(test_string), stdin)) { |
| 73 char *new_line_position = strchr(test_string, '\n'); | 68 char *new_line_position = strchr(test_string, '\n'); |
| 74 if (new_line_position) | 69 if (new_line_position) |
| 75 *new_line_position = '\0'; | 70 *new_line_position = '\0'; |
| 76 if (test_string[0] == '\0') | 71 if (test_string[0] == '\0') |
| 77 continue; | 72 continue; |
| 78 | 73 |
| 79 // Test header. | 74 // Test header. |
| 80 printf("Content-Type: text/plain\n"); | 75 printf("Content-Type: text/plain\n"); |
| 81 | 76 |
| 82 std::string pixel_hash; | 77 std::string pixel_hash; |
| 83 content::Shell::CreateNewWindow( | 78 GURL test_url = GetURLForLayoutTest(test_string, &pixel_hash); |
| 84 browser_context, | 79 content::WebKitTestController::Get()->PrepareForLayoutTest( |
| 85 GetURLForLayoutTest(test_string, &pixel_hash), | 80 test_url, pixel_hash); |
| 86 NULL, | |
| 87 MSG_ROUTING_NONE, | |
| 88 NULL); | |
| 89 content::WebKitTestRunnerHost::Init(pixel_hash); | |
| 90 | 81 |
| 91 main_runner_->Run(); | 82 main_runner_->Run(); |
| 92 | 83 |
| 93 content::Shell::CloseAllWindows(); | |
| 94 | |
| 95 // Test footer. | 84 // Test footer. |
| 96 printf("#EOF\n"); | 85 printf("#EOF\n"); |
| 97 fflush(stdout); | 86 fflush(stdout); |
| 98 fflush(stderr); | 87 fflush(stderr); |
| 88 |
| 89 if (!content::WebKitTestController::Get()->ResetAfterLayoutTest()) |
| 90 break; |
| 99 } | 91 } |
| 100 exit_code = 0; | 92 exit_code = 0; |
| 101 } else { | 93 } else { |
| 102 exit_code = main_runner_->Run(); | 94 exit_code = main_runner_->Run(); |
| 103 } | 95 } |
| 104 | 96 |
| 105 main_runner_->Shutdown(); | 97 main_runner_->Shutdown(); |
| 106 | 98 |
| 107 return exit_code; | 99 return exit_code; |
| 108 } | 100 } |
| OLD | NEW |