summaryrefslogtreecommitdiffstats
path: root/chrome/test/webdriver/server.cc
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 22:07:57 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-22 22:07:57 +0000
commit358dc4e529da6d995be5c714fc0c2dcf173a76fc (patch)
tree5f76ffb1075710f33c48da996b99f9bf14bb0862 /chrome/test/webdriver/server.cc
parent4d941abd32f11d20642ff3d00725ef576b7eb731 (diff)
downloadchromium_src-358dc4e529da6d995be5c714fc0c2dcf173a76fc.zip
chromium_src-358dc4e529da6d995be5c714fc0c2dcf173a76fc.tar.gz
chromium_src-358dc4e529da6d995be5c714fc0c2dcf173a76fc.tar.bz2
Add ChromeDriver support for finding the Chrome exe to launch.
Also add a ChromeDriver commandline argument for specifying a custom dir. Switch to using ProxyLauncher directly instead of inheriting from UITestBase. BUG=56865 TEST=none Review URL: http://codereview.chromium.org/6469085 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/webdriver/server.cc')
-rw-r--r--chrome/test/webdriver/server.cc46
1 files changed, 38 insertions, 8 deletions
diff --git a/chrome/test/webdriver/server.cc b/chrome/test/webdriver/server.cc
index b2213e3..ce68dd6 100644
--- a/chrome/test/webdriver/server.cc
+++ b/chrome/test/webdriver/server.cc
@@ -4,18 +4,18 @@
#include <signal.h>
#include <stdlib.h>
-#ifndef _WIN32
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#else
-#include <time.h>
+
+#if defined(OS_WIN)
+#include <windows.h>
#endif
+
#include <iostream>
#include <fstream>
#include "base/at_exit.h"
#include "base/command_line.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
@@ -48,6 +48,15 @@
#include "chrome/test/webdriver/commands/webelement_commands.h"
#include "third_party/mongoose/mongoose.h"
+#if defined(OS_WIN)
+#include <time.h>
+#elif defined(OS_POSIX)
+#include <errno.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#endif
+
// Make sure we have ho zombies from CGIs.
static void
signal_handler(int sig_num) {
@@ -214,16 +223,30 @@ int main(int argc, char *argv[]) {
// Parse command line flags.
std::string port = "9515";
std::string root;
+ FilePath chrome_dir;
if (cmd_line->HasSwitch("port"))
port = cmd_line->GetSwitchValueASCII("port");
// By default, mongoose serves files from the current working directory. The
// 'root' flag allows the user to specify a different location to serve from.
if (cmd_line->HasSwitch("root"))
root = cmd_line->GetSwitchValueASCII("root");
+ if (cmd_line->HasSwitch("chrome-dir"))
+ chrome_dir = cmd_line->GetSwitchValuePath("chrome-dir");
- VLOG(1) << "Using port: " << port;
webdriver::SessionManager* manager = webdriver::SessionManager::GetInstance();
manager->set_port(port);
+ if (!chrome_dir.empty()) {
+ if (!file_util::DirectoryExists(chrome_dir)) {
+ std::cout << "Given Chrome directory is inaccessible or does not exist: "
+ << chrome_dir.value() << std::endl;
+#if defined(OS_WIN)
+ return ERROR_PATH_NOT_FOUND;
+#else
+ return ENOENT;
+#endif
+ }
+ manager->set_chrome_dir(chrome_dir);
+ }
// Initialize SHTTPD context.
// Listen on port 9515 or port specified on command line.
@@ -231,7 +254,11 @@ int main(int argc, char *argv[]) {
ctx = mg_start();
if (!SetMongooseOptions(ctx, port, root)) {
mg_stop(ctx);
- return 1;
+#if defined(OS_WIN)
+ return WSAEADDRINUSE;
+#else
+ return EADDRINUSE;
+#endif
}
webdriver::InitCallbacks(ctx, &shutdown_event);
@@ -244,6 +271,9 @@ int main(int argc, char *argv[]) {
if (root.length()) {
VLOG(1) << "Serving files from the current working directory";
}
+ if (!chrome_dir.empty()) {
+ VLOG(1) << "Using Chrome inside directory: " << chrome_dir.value();
+ }
// Run until we receive command to shutdown.
shutdown_event.Wait();