summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-19 06:19:59 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-19 06:19:59 +0000
commit21e342f0bb3e61df2f70ea7f1752ef7f73d015c2 (patch)
tree6b875159c2d96c7c80901af15e7d80343449ce6c /content/shell
parentcd44bd347cbd98c6ca274b09b4ed49eb5c30c28f (diff)
downloadchromium_src-21e342f0bb3e61df2f70ea7f1752ef7f73d015c2.zip
chromium_src-21e342f0bb3e61df2f70ea7f1752ef7f73d015c2.tar.gz
chromium_src-21e342f0bb3e61df2f70ea7f1752ef7f73d015c2.tar.bz2
[content shell] add support for getting tests from the command line.
Related to this, parse a single dash on the command line as argument, instead of a switch with no value and name BUG=111316 TEST=out/Debug/content_shell --dump-render-tree path/to/test.html works Review URL: https://chromiumcodereview.appspot.com/11184050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell_browser_main.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index 499b9b3..d8fabe9 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;