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

Side by Side Diff: chrome/test/webdriver/server.cc

Issue 6992015: Fix minor issues in ChromeDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <signal.h> 5 #include <signal.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #if defined(OS_WIN) 8 #if defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // Register Chrome's path provider so that the AutomationProxy will find our 225 // Register Chrome's path provider so that the AutomationProxy will find our
226 // built Chrome. 226 // built Chrome.
227 chrome::RegisterPathProvider(); 227 chrome::RegisterPathProvider();
228 TestTimeouts::Initialize(); 228 TestTimeouts::Initialize();
229 InitChromeDriverLogging(*cmd_line); 229 InitChromeDriverLogging(*cmd_line);
230 230
231 // Parse command line flags. 231 // Parse command line flags.
232 std::string port = "9515"; 232 std::string port = "9515";
233 std::string root; 233 std::string root;
234 FilePath chrome_dir;
235 std::string url_base; 234 std::string url_base;
236 if (cmd_line->HasSwitch("port")) 235 if (cmd_line->HasSwitch("port"))
237 port = cmd_line->GetSwitchValueASCII("port"); 236 port = cmd_line->GetSwitchValueASCII("port");
238 // The 'root' flag allows the user to specify a location to serve files from. 237 // The 'root' flag allows the user to specify a location to serve files from.
239 // If it is not given, a callback will be registered to forbid all file 238 // If it is not given, a callback will be registered to forbid all file
240 // requests. 239 // requests.
241 if (cmd_line->HasSwitch("root")) 240 if (cmd_line->HasSwitch("root"))
242 root = cmd_line->GetSwitchValueASCII("root"); 241 root = cmd_line->GetSwitchValueASCII("root");
243 if (cmd_line->HasSwitch("chrome-dir"))
244 chrome_dir = cmd_line->GetSwitchValuePath("chrome-dir");
245 if (cmd_line->HasSwitch("url-base")) 242 if (cmd_line->HasSwitch("url-base"))
246 url_base = cmd_line->GetSwitchValueASCII("url-base"); 243 url_base = cmd_line->GetSwitchValueASCII("url-base");
247 244
248 webdriver::SessionManager* manager = webdriver::SessionManager::GetInstance(); 245 webdriver::SessionManager* manager = webdriver::SessionManager::GetInstance();
249 manager->set_port(port); 246 manager->set_port(port);
250 manager->set_url_base(url_base); 247 manager->set_url_base(url_base);
251 if (!chrome_dir.empty()) {
252 if (!file_util::DirectoryExists(chrome_dir)) {
253 std::cout << "Given Chrome directory is inaccessible or does not exist: "
254 << chrome_dir.value() << std::endl;
255 #if defined(OS_WIN)
256 return ERROR_PATH_NOT_FOUND;
257 #else
258 return ENOENT;
259 #endif
260 }
261 manager->set_chrome_dir(chrome_dir);
262 }
263 248
264 // Initialize SHTTPD context. 249 // Initialize SHTTPD context.
265 // Listen on port 9515 or port specified on command line. 250 // Listen on port 9515 or port specified on command line.
266 // TODO(jmikhail) Maybe add port 9516 as a secure connection. 251 // TODO(jmikhail) Maybe add port 9516 as a secure connection.
267 ctx = mg_start(); 252 ctx = mg_start();
268 if (!SetMongooseOptions(ctx, port, root)) { 253 if (!SetMongooseOptions(ctx, port, root)) {
269 mg_stop(ctx); 254 mg_stop(ctx);
270 #if defined(OS_WIN) 255 #if defined(OS_WIN)
271 return WSAEADDRINUSE; 256 return WSAEADDRINUSE;
272 #else 257 #else
273 return EADDRINUSE; 258 return EADDRINUSE;
274 #endif 259 #endif
275 } 260 }
276 261
277 webdriver::Dispatcher dispatcher(ctx, url_base); 262 webdriver::Dispatcher dispatcher(ctx, url_base);
278 webdriver::InitCallbacks(ctx, &dispatcher, &shutdown_event, root.empty()); 263 webdriver::InitCallbacks(ctx, &dispatcher, &shutdown_event, root.empty());
279 264
280 // The tests depend on parsing the first line ChromeDriver outputs, 265 // The tests depend on parsing the first line ChromeDriver outputs,
281 // so all other logging should happen after this. 266 // so all other logging should happen after this.
282 std::cout << "Started ChromeDriver" << std::endl 267 std::cout << "Started ChromeDriver" << std::endl
283 << "port=" << port << std::endl; 268 << "port=" << port << std::endl;
284 269
285 if (root.length()) { 270 if (root.length()) {
286 VLOG(1) << "Serving files from the current working directory"; 271 VLOG(1) << "Serving files from the current working directory";
287 } 272 }
288 if (!chrome_dir.empty()) {
289 VLOG(1) << "Using Chrome inside directory: " << chrome_dir.value();
290 }
291 273
292 // Run until we receive command to shutdown. 274 // Run until we receive command to shutdown.
293 shutdown_event.Wait(); 275 shutdown_event.Wait();
294 276
295 // We should not reach here since the service should never quit. 277 // We should not reach here since the service should never quit.
296 // TODO(jmikhail): register a listener for SIGTERM and break the 278 // TODO(jmikhail): register a listener for SIGTERM and break the
297 // message loop gracefully. 279 // message loop gracefully.
298 mg_stop(ctx); 280 mg_stop(ctx);
299 return (EXIT_SUCCESS); 281 return (EXIT_SUCCESS);
300 } 282 }
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/session_with_id.cc ('k') | chrome/test/webdriver/session_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698