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

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

Issue 6614023: Convert ChromeDriver to use only the JSON automation interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Pawel's additional comments 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
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/webdriver_key_converter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/test/webdriver/session_manager.h" 5 #include "chrome/test/webdriver/session_manager.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 12 matching lines...) Expand all
23 #include "base/string_util.h" 23 #include "base/string_util.h"
24 #include "base/synchronization/waitable_event.h" 24 #include "base/synchronization/waitable_event.h"
25 #include "base/test/test_timeouts.h" 25 #include "base/test/test_timeouts.h"
26 #include "base/threading/platform_thread.h" 26 #include "base/threading/platform_thread.h"
27 #include "base/time.h" 27 #include "base/time.h"
28 #include "base/utf_string_conversions.h" 28 #include "base/utf_string_conversions.h"
29 #include "base/values.h" 29 #include "base/values.h"
30 #include "chrome/app/chrome_command_ids.h" 30 #include "chrome/app/chrome_command_ids.h"
31 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/test/automation/automation_json_requests.h"
33 #include "chrome/test/test_launcher_utils.h" 34 #include "chrome/test/test_launcher_utils.h"
34 #include "chrome/test/webdriver/session_manager.h" 35 #include "chrome/test/webdriver/session_manager.h"
35 #include "chrome/test/webdriver/utility_functions.h" 36 #include "chrome/test/webdriver/utility_functions.h"
36 #include "chrome/test/webdriver/webdriver_key_converter.h" 37 #include "chrome/test/webdriver/webdriver_key_converter.h"
37 #include "chrome/test/webdriver/web_element_id.h" 38 #include "chrome/test/webdriver/web_element_id.h"
38 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
39 #include "third_party/webdriver/atoms.h" 40 #include "third_party/webdriver/atoms.h"
40 #include "ui/gfx/point.h" 41 #include "ui/gfx/point.h"
41 42
42 namespace webdriver { 43 namespace webdriver {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 bool success = false; 253 bool success = false;
253 RunSessionTask(NewRunnableMethod( 254 RunSessionTask(NewRunnableMethod(
254 automation_.get(), 255 automation_.get(),
255 &Automation::GetTabTitle, 256 &Automation::GetTabTitle,
256 current_window_id_, 257 current_window_id_,
257 tab_title, 258 tab_title,
258 &success)); 259 &success));
259 return success; 260 return success;
260 } 261 }
261 262
262 void Session::MouseClick(const gfx::Point& click, int flags) { 263 void Session::MouseClick(const gfx::Point& click,
264 automation::MouseButton button) {
263 bool success = false; 265 bool success = false;
264 RunSessionTask(NewRunnableMethod( 266 RunSessionTask(NewRunnableMethod(
265 automation_.get(), 267 automation_.get(),
266 &Automation::MouseClick, 268 &Automation::MouseClick,
267 current_window_id_, 269 current_window_id_,
268 click, 270 click,
269 flags, 271 button,
270 &success)); 272 &success));
271 } 273 }
272 274
273 bool Session::MouseMove(const gfx::Point& location) { 275 bool Session::MouseMove(const gfx::Point& location) {
274 bool success = false; 276 bool success = false;
275 RunSessionTask(NewRunnableMethod( 277 RunSessionTask(NewRunnableMethod(
276 automation_.get(), 278 automation_.get(),
277 &Automation::MouseMove, 279 &Automation::MouseMove,
278 current_window_id_, 280 current_window_id_,
279 location, 281 location,
(...skipping 22 matching lines...) Expand all
302 current_window_id_, 304 current_window_id_,
303 url, 305 url,
304 cookies, 306 cookies,
305 &success)); 307 &success));
306 return success; 308 return success;
307 } 309 }
308 310
309 bool Session::GetCookieByName(const GURL& url, 311 bool Session::GetCookieByName(const GURL& url,
310 const std::string& cookie_name, 312 const std::string& cookie_name,
311 std::string* cookie) { 313 std::string* cookie) {
312 bool success = false; 314 std::string cookies;
313 RunSessionTask(NewRunnableMethod( 315 if (!GetCookies(url, &cookies))
314 automation_.get(), 316 return false;
315 &Automation::GetCookieByName, 317
316 current_window_id_, 318 std::string namestr = cookie_name + "=";
317 url, 319 std::string::size_type idx = cookies.find(namestr);
318 cookie_name, 320 if (idx != std::string::npos) {
319 cookie, 321 cookies.erase(0, idx + namestr.length());
320 &success)); 322 *cookie = cookies.substr(0, cookies.find(";"));
321 return success; 323 } else {
324 cookie->clear();
325 }
326
327 return true;
322 } 328 }
323 329
324 bool Session::DeleteCookie(const GURL& url, const std::string& cookie_name) { 330 bool Session::DeleteCookie(const GURL& url, const std::string& cookie_name) {
325 bool success = false; 331 bool success = false;
326 RunSessionTask(NewRunnableMethod( 332 RunSessionTask(NewRunnableMethod(
327 automation_.get(), 333 automation_.get(),
328 &Automation::DeleteCookie, 334 &Automation::DeleteCookie,
329 current_window_id_, 335 current_window_id_,
330 url, 336 url,
331 cookie_name, 337 cookie_name,
(...skipping 20 matching lines...) Expand all
352 &Automation::GetTabIds, 358 &Automation::GetTabIds,
353 window_ids, 359 window_ids,
354 &success)); 360 &success));
355 return success; 361 return success;
356 } 362 }
357 363
358 ErrorCode Session::SwitchToWindow(const std::string& name) { 364 ErrorCode Session::SwitchToWindow(const std::string& name) {
359 int switch_to_id = 0; 365 int switch_to_id = 0;
360 int name_no = 0; 366 int name_no = 0;
361 if (base::StringToInt(name, &name_no)) { 367 if (base::StringToInt(name, &name_no)) {
368 bool success = false;
362 bool does_exist = false; 369 bool does_exist = false;
363 RunSessionTask(NewRunnableMethod( 370 RunSessionTask(NewRunnableMethod(
364 automation_.get(), 371 automation_.get(),
365 &Automation::DoesTabExist, 372 &Automation::DoesTabExist,
366 name_no, 373 name_no,
367 &does_exist)); 374 &does_exist,
375 &success));
376 if (!success) {
377 LOG(ERROR) << "Unable to determine if window exists";
378 return kUnknownError;
379 }
368 if (does_exist) 380 if (does_exist)
369 switch_to_id = name_no; 381 switch_to_id = name_no;
370 } 382 }
371 383
372 if (!switch_to_id) { 384 if (!switch_to_id) {
373 std::vector<int> window_ids; 385 std::vector<int> window_ids;
374 GetWindowIds(&window_ids); 386 GetWindowIds(&window_ids);
375 // See if any of the window names match |name|. 387 // See if any of the window names match |name|.
376 for (size_t i = 0; i < window_ids.size(); ++i) { 388 for (size_t i = 0; i < window_ids.size(); ++i) {
377 ListValue empty_list; 389 ListValue empty_list;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 } 772 }
761 } else { 773 } else {
762 LOG(ERROR) << "Location atom returned non-dictionary type"; 774 LOG(ERROR) << "Location atom returned non-dictionary type";
763 code = kUnknownError; 775 code = kUnknownError;
764 } 776 }
765 } 777 }
766 return code; 778 return code;
767 } 779 }
768 780
769 } // namespace webdriver 781 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | chrome/test/webdriver/webdriver_key_converter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698