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

Unified Diff: content/shell/shell_browser_main.cc

Issue 11184050: [content shell] add support for getting tests from the command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/command_line_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d8fabe959a96e30851a5337444cee82a8cd7d845 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h"
+#include "base/utf_string_conversions.h"
#include "content/public/browser/browser_main_runner.h"
#include "content/shell/shell_switches.h"
#include "content/shell/webkit_test_runner_host.h"
@@ -21,7 +22,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 +64,21 @@ GURL GetURLForLayoutTest(const char* test_name,
return test_url;
}
+bool GetNextTest(const CommandLine::StringVector& args,
+ size_t* position,
+ std::string* test) {
+ if (*position >= args.size())
+ return false;
+ if (args[*position] == FILE_PATH_LITERAL("-"))
+ return !!std::getline(std::cin, *test, '\n');
+#if defined(OS_WIN)
+ *test = WideToUTF8(args[(*position)++]);
+#else
+ *test = args[(*position)++];
+#endif
+ return true;
+}
+
} // namespace
// Main routine for running as the Browser process.
@@ -85,20 +101,20 @@ int ShellBrowserMain(const content::MainFunctionParams& parameters) {
if (layout_test_mode) {
content::WebKitTestController test_controller;
+ std::string test_string;
+ CommandLine::StringVector args =
+ CommandLine::ForCurrentProcess()->GetArgs();
+ size_t command_line_position = 0;
- 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, &command_line_position, &test_string)) {
+ if (test_string.empty())
continue;
- if (!strcmp(test_string, "QUIT"))
+ if (test_string == "QUIT")
break;
bool enable_pixel_dumps;
« no previous file with comments | « base/command_line_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698