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

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

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: added tests which compare against a reference md5 hash Created 9 years, 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 19 matching lines...) Expand all
30 #include "chrome/test/webdriver/error_codes.h" 30 #include "chrome/test/webdriver/error_codes.h"
31 #include "chrome/test/webdriver/session_manager.h" 31 #include "chrome/test/webdriver/session_manager.h"
32 #include "chrome/test/webdriver/utility_functions.h" 32 #include "chrome/test/webdriver/utility_functions.h"
33 #include "chrome/test/webdriver/commands/cookie_commands.h" 33 #include "chrome/test/webdriver/commands/cookie_commands.h"
34 #include "chrome/test/webdriver/commands/create_session.h" 34 #include "chrome/test/webdriver/commands/create_session.h"
35 #include "chrome/test/webdriver/commands/execute_command.h" 35 #include "chrome/test/webdriver/commands/execute_command.h"
36 #include "chrome/test/webdriver/commands/find_element_commands.h" 36 #include "chrome/test/webdriver/commands/find_element_commands.h"
37 #include "chrome/test/webdriver/commands/implicit_wait_command.h" 37 #include "chrome/test/webdriver/commands/implicit_wait_command.h"
38 #include "chrome/test/webdriver/commands/navigate_commands.h" 38 #include "chrome/test/webdriver/commands/navigate_commands.h"
39 #include "chrome/test/webdriver/commands/mouse_commands.h" 39 #include "chrome/test/webdriver/commands/mouse_commands.h"
40 #include "chrome/test/webdriver/commands/screenshot_command.h"
40 #include "chrome/test/webdriver/commands/session_with_id.h" 41 #include "chrome/test/webdriver/commands/session_with_id.h"
41 #include "chrome/test/webdriver/commands/source_command.h" 42 #include "chrome/test/webdriver/commands/source_command.h"
42 #include "chrome/test/webdriver/commands/speed_command.h" 43 #include "chrome/test/webdriver/commands/speed_command.h"
43 #include "chrome/test/webdriver/commands/target_locator_commands.h" 44 #include "chrome/test/webdriver/commands/target_locator_commands.h"
44 #include "chrome/test/webdriver/commands/title_command.h" 45 #include "chrome/test/webdriver/commands/title_command.h"
45 #include "chrome/test/webdriver/commands/url_command.h" 46 #include "chrome/test/webdriver/commands/url_command.h"
46 #include "chrome/test/webdriver/commands/webelement_commands.h" 47 #include "chrome/test/webdriver/commands/webelement_commands.h"
47 #include "third_party/mongoose/mongoose.h" 48 #include "third_party/mongoose/mongoose.h"
48 49
49 #if defined(OS_WIN) 50 #if defined(OS_WIN)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 dispatcher->Add<ElementLocationInViewCommand>( 113 dispatcher->Add<ElementLocationInViewCommand>(
113 "/session/*/element/*/location_in_view"); 114 "/session/*/element/*/location_in_view");
114 dispatcher->Add<ElementNameCommand>( "/session/*/element/*/name"); 115 dispatcher->Add<ElementNameCommand>( "/session/*/element/*/name");
115 dispatcher->Add<ElementSelectedCommand>("/session/*/element/*/selected"); 116 dispatcher->Add<ElementSelectedCommand>("/session/*/element/*/selected");
116 dispatcher->Add<ElementSizeCommand>( "/session/*/element/*/size"); 117 dispatcher->Add<ElementSizeCommand>( "/session/*/element/*/size");
117 dispatcher->Add<ElementSubmitCommand>( "/session/*/element/*/submit"); 118 dispatcher->Add<ElementSubmitCommand>( "/session/*/element/*/submit");
118 dispatcher->Add<ElementTextCommand>( "/session/*/element/*/text"); 119 dispatcher->Add<ElementTextCommand>( "/session/*/element/*/text");
119 dispatcher->Add<ElementToggleCommand>( "/session/*/element/*/toggle"); 120 dispatcher->Add<ElementToggleCommand>( "/session/*/element/*/toggle");
120 dispatcher->Add<ElementValueCommand>( "/session/*/element/*/value"); 121 dispatcher->Add<ElementValueCommand>( "/session/*/element/*/value");
121 122
123 dispatcher->Add<ScreenshotCommand>("/session/*/screenshot");
124
122 // Mouse Commands 125 // Mouse Commands
123 dispatcher->Add<ClickCommand>("/session/*/element/*/click"); 126 dispatcher->Add<ClickCommand>("/session/*/element/*/click");
124 dispatcher->Add<DragCommand>( "/session/*/element/*/drag"); 127 dispatcher->Add<DragCommand>( "/session/*/element/*/drag");
125 dispatcher->Add<HoverCommand>("/session/*/element/*/hover"); 128 dispatcher->Add<HoverCommand>("/session/*/element/*/hover");
126 129
127 // Commands that have not been implemented yet. We list these out explicitly 130 // Commands that have not been implemented yet. We list these out explicitly
128 // so that tests that attempt to use them fail with a meaningful error. 131 // so that tests that attempt to use them fail with a meaningful error.
129 dispatcher->SetNotImplemented("/session/*/execute_async"); 132 dispatcher->SetNotImplemented("/session/*/execute_async");
130 dispatcher->SetNotImplemented("/session/*/timeouts/async_script"); 133 dispatcher->SetNotImplemented("/session/*/timeouts/async_script");
131 dispatcher->SetNotImplemented("/session/*/screenshot");
132 134
133 // Since the /session/* is a wild card that would match the above URIs, this 135 // Since the /session/* is a wild card that would match the above URIs, this
134 // line MUST be the last registered URI with the server. 136 // line MUST be the last registered URI with the server.
135 dispatcher->Add<SessionWithID>("/session/*"); 137 dispatcher->Add<SessionWithID>("/session/*");
136 } 138 }
137 139
138 } // namespace webdriver 140 } // namespace webdriver
139 141
140 // Configures mongoose according to the given command line flags. 142 // Configures mongoose according to the given command line flags.
141 // Returns true on success. 143 // Returns true on success.
142 bool SetMongooseOptions(struct mg_context* ctx, 144 bool SetMongooseOptions(struct mg_context* ctx,
143 const std::string& port, 145 const std::string& port,
144 const std::string& root) { 146 const std::string& root) {
145 if (!mg_set_option(ctx, "ports", port.c_str())) { 147 if (!mg_set_option(ctx, "ports", port.c_str())) {
146 std::cout << "ChromeDriver cannot bind to port (" 148 std::cout << "ChromeDriver cannot bind to port ("
147 << port.c_str() << ")" << std::endl; 149 << port.c_str() << ")" << std::endl;
148 return false; 150 return false;
149 } 151 }
150 if (root.length()) 152 if (root.length())
151 mg_set_option(ctx, "root", root.c_str()); 153 mg_set_option(ctx, "root", root.c_str());
152 // Lower the default idle time to 1 second. Idle time refers to how long a 154 // Lower the default idle time to 1 second. Idle time refers to how long a
153 // worker thread will wait for new connections before exiting. 155 // worker thread will wait for new connections before exiting.
154 // This is so mongoose quits in a reasonable amount of time. 156 // This is so mongoose quits in a reasonable amount of time.
155 mg_set_option(ctx, "idle_time", "1"); 157 mg_set_option(ctx, "idle_time", "1");
156 return true; 158 return true;
157 } 159 }
158 160
161
159 // Sets up and runs the Mongoose HTTP server for the JSON over HTTP 162 // Sets up and runs the Mongoose HTTP server for the JSON over HTTP
160 // protcol of webdriver. The spec is located at: 163 // protcol of webdriver. The spec is located at:
161 // http://code.google.com/p/selenium/wiki/JsonWireProtocol. 164 // http://code.google.com/p/selenium/wiki/JsonWireProtocol.
162 int main(int argc, char *argv[]) { 165 int main(int argc, char *argv[]) {
163 struct mg_context *ctx; 166 struct mg_context *ctx;
164 base::AtExitManager exit; 167 base::AtExitManager exit;
165 base::WaitableEvent shutdown_event(false, false); 168 base::WaitableEvent shutdown_event(false, false);
166 CommandLine::Init(argc, argv); 169 CommandLine::Init(argc, argv);
167 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 170 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
168 171
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 242
240 // Run until we receive command to shutdown. 243 // Run until we receive command to shutdown.
241 shutdown_event.Wait(); 244 shutdown_event.Wait();
242 245
243 // We should not reach here since the service should never quit. 246 // We should not reach here since the service should never quit.
244 // TODO(jmikhail): register a listener for SIGTERM and break the 247 // TODO(jmikhail): register a listener for SIGTERM and break the
245 // message loop gracefully. 248 // message loop gracefully.
246 mg_stop(ctx); 249 mg_stop(ctx);
247 return (EXIT_SUCCESS); 250 return (EXIT_SUCCESS);
248 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698