| 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 <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "content/public/browser/browser_main_runner.h" | 13 #include "content/public/browser/browser_main_runner.h" |
| 14 #include "content/shell/layout_test_controller_host.h" |
| 14 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
| 15 #include "content/shell/shell_browser_context.h" | 16 #include "content/shell/shell_browser_context.h" |
| 16 #include "content/shell/shell_content_browser_client.h" | 17 #include "content/shell/shell_content_browser_client.h" |
| 17 #include "content/shell/shell_switches.h" | 18 #include "content/shell/shell_switches.h" |
| 18 #include "webkit/support/webkit_support.h" | 19 #include "webkit/support/webkit_support.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 GURL GetURLForLayoutTest(const char* test_name) { | 23 GURL GetURLForLayoutTest(const char* test_name, |
| 24 std::string* expected_pixel_hash) { |
| 23 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
| 24 // DumpRenderTree is not currently supported for Android using the content | 26 // DumpRenderTree is not currently supported for Android using the content |
| 25 // shell. | 27 // shell. |
| 26 NOTIMPLEMENTED(); | 28 NOTIMPLEMENTED(); |
| 27 return GURL::EmptyGURL(); | 29 return GURL::EmptyGURL(); |
| 28 #else | 30 #else |
| 29 std::string path_or_url = test_name; | 31 std::string path_or_url = test_name; |
| 30 std::string pixel_hash; | 32 std::string pixel_hash; |
| 31 std::string timeout; | 33 std::string::size_type separator_position = path_or_url.find('\''); |
| 32 std::string::size_type separator_position = path_or_url.find(' '); | |
| 33 if (separator_position != std::string::npos) { | 34 if (separator_position != std::string::npos) { |
| 34 timeout = path_or_url.substr(separator_position + 1); | 35 pixel_hash = path_or_url.substr(separator_position + 1); |
| 35 path_or_url.erase(separator_position); | 36 path_or_url.erase(separator_position); |
| 36 separator_position = path_or_url.find(' '); | |
| 37 if (separator_position != std::string::npos) { | |
| 38 pixel_hash = timeout.substr(separator_position + 1); | |
| 39 timeout.erase(separator_position); | |
| 40 } | |
| 41 } | 37 } |
| 42 // TODO(jochen): use pixel_hash and timeout. | 38 if (expected_pixel_hash) |
| 39 *expected_pixel_hash = pixel_hash; |
| 43 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); | 40 GURL test_url = webkit_support::CreateURLForPathOrURL(path_or_url); |
| 44 { | 41 { |
| 45 // We're outside of the message loop here, and this is a test. | 42 // We're outside of the message loop here, and this is a test. |
| 46 base::ThreadRestrictions::ScopedAllowIO allow_io; | 43 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 47 webkit_support::SetCurrentDirectoryForFileURL(test_url); | 44 webkit_support::SetCurrentDirectoryForFileURL(test_url); |
| 48 } | 45 } |
| 49 return test_url; | 46 return test_url; |
| 50 #endif | 47 #endif |
| 51 } | 48 } |
| 52 | 49 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 79 while (fgets(test_string, sizeof(test_string), stdin)) { | 76 while (fgets(test_string, sizeof(test_string), stdin)) { |
| 80 char *new_line_position = strchr(test_string, '\n'); | 77 char *new_line_position = strchr(test_string, '\n'); |
| 81 if (new_line_position) | 78 if (new_line_position) |
| 82 *new_line_position = '\0'; | 79 *new_line_position = '\0'; |
| 83 if (test_string[0] == '\0') | 80 if (test_string[0] == '\0') |
| 84 continue; | 81 continue; |
| 85 | 82 |
| 86 // Test header. | 83 // Test header. |
| 87 std::cout << "Content-Type: text/plain\n"; | 84 std::cout << "Content-Type: text/plain\n"; |
| 88 | 85 |
| 89 content::Shell::CreateNewWindow(browser_context, | 86 std::string pixel_hash; |
| 90 GetURLForLayoutTest(test_string), | 87 content::Shell::CreateNewWindow( |
| 91 NULL, | 88 browser_context, |
| 92 MSG_ROUTING_NONE, | 89 GetURLForLayoutTest(test_string, &pixel_hash), |
| 93 NULL); | 90 NULL, |
| 91 MSG_ROUTING_NONE, |
| 92 NULL); |
| 93 content::LayoutTestControllerHost::Init(pixel_hash); |
| 94 |
| 94 main_runner_->Run(); | 95 main_runner_->Run(); |
| 95 | 96 |
| 96 content::Shell::CloseAllWindows(); | 97 content::Shell::CloseAllWindows(); |
| 97 | 98 |
| 98 // Test footer. | 99 // Test footer. |
| 99 std::cout << "#EOF\n"; | 100 std::cout << "#EOF\n"; |
| 100 std::cout.flush(); | 101 std::cout.flush(); |
| 101 | 102 |
| 102 } | 103 } |
| 103 exit_code = 0; | 104 exit_code = 0; |
| 104 } else { | 105 } else { |
| 105 exit_code = main_runner_->Run(); | 106 exit_code = main_runner_->Run(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 main_runner_->Shutdown(); | 109 main_runner_->Shutdown(); |
| 109 | 110 |
| 110 return exit_code; | 111 return exit_code; |
| 111 } | 112 } |
| OLD | NEW |