Index: content/shell/shell_browser_main.cc |
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc |
index 499b9b3ddada2646fa48be79dbd18d1ae6a05d84..bb0baee899febb41f2f861fd32f5571a465af51c 100644 |
--- a/content/shell/shell_browser_main.cc |
+++ b/content/shell/shell_browser_main.cc |
@@ -21,7 +21,7 @@ |
namespace { |
-GURL GetURLForLayoutTest(const char* test_name, |
+GURL GetURLForLayoutTest(const std::string& test_name, |
bool* enable_pixel_dumping, |
std::string* expected_pixel_hash) { |
// A test name is formated like file:///path/to/test'--pixel-test'pixelhash |
@@ -63,6 +63,20 @@ GURL GetURLForLayoutTest(const char* test_name, |
return test_url; |
} |
+bool GetNextTest(const CommandLine::StringVector& args, std::string* test) { |
+ static size_t pos = 0; |
marja
2012/10/18 20:53:57
Uhh, can you make pos an in-out parameter instead.
jochen (gone - plz use gerrit)
2012/10/18 21:06:42
Done.
|
+ if (pos >= args.size()) |
+ return false; |
+ if (args[pos] == FILE_PATH_LITERAL("-")) |
+ return std::getline(std::cin, *test, '\n'); |
+#if defined(OS_WIN) |
+ *test = WideToUTF8(args[pos++]); |
+#else |
+ *test = args[pos++]; |
+#endif |
+ return true; |
+} |
+ |
} // namespace |
// Main routine for running as the Browser process. |
@@ -85,20 +99,19 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters) { |
if (layout_test_mode) { |
content::WebKitTestController test_controller; |
+ std::string test_string; |
+ CommandLine::StringVector args = |
+ CommandLine::ForCurrentProcess()->GetArgs(); |
- char test_string[2048]; |
#if defined(OS_ANDROID) |
std::cout << "#READY\n"; |
std::cout.flush(); |
#endif |
- while (fgets(test_string, sizeof(test_string), stdin)) { |
- char *new_line_position = strchr(test_string, '\n'); |
- if (new_line_position) |
- *new_line_position = '\0'; |
- if (test_string[0] == '\0') |
+ while (GetNextTest(args, &test_string)) { |
+ if (test_string.empty()) |
continue; |
- if (!strcmp(test_string, "QUIT")) |
+ if (test_string == "QUIT") |
break; |
bool enable_pixel_dumps; |