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

Side by Side Diff: chrome/test/webdriver/commands/webelement_commands.cc

Issue 7522024: Refactor chromedriver's script execution to reduce amount of custom Value parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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/commands/mouse_commands.cc ('k') | chrome/test/webdriver/dispatch.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/commands/webelement_commands.h" 5 #include "chrome/test/webdriver/commands/webelement_commands.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/third_party/icu/icu_utf.h" 12 #include "base/third_party/icu/icu_utf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/test/webdriver/commands/response.h" 14 #include "chrome/test/webdriver/commands/response.h"
15 #include "chrome/test/webdriver/session.h" 15 #include "chrome/test/webdriver/session.h"
16 #include "chrome/test/webdriver/webdriver_basic_types.h"
16 #include "chrome/test/webdriver/webdriver_error.h" 17 #include "chrome/test/webdriver/webdriver_error.h"
17 #include "third_party/webdriver/atoms.h" 18 #include "third_party/webdriver/atoms.h"
18 #include "ui/gfx/point.h"
19 #include "ui/gfx/size.h"
20 19
21 namespace webdriver { 20 namespace webdriver {
22 21
23 ///////////////////// WebElementCommand //////////////////// 22 ///////////////////// WebElementCommand ////////////////////
24 23
25 WebElementCommand::WebElementCommand( 24 WebElementCommand::WebElementCommand(
26 const std::vector<std::string>& path_segments, 25 const std::vector<std::string>& path_segments,
27 const DictionaryValue* const parameters) 26 const DictionaryValue* const parameters)
28 : WebDriverCommand(path_segments, parameters), 27 : WebDriverCommand(path_segments, parameters),
29 path_segments_(path_segments) {} 28 path_segments_(path_segments) {}
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 DictionaryValue* parameters) 272 DictionaryValue* parameters)
274 : WebElementCommand(path_segments, parameters) {} 273 : WebElementCommand(path_segments, parameters) {}
275 274
276 ElementLocationInViewCommand::~ElementLocationInViewCommand() {} 275 ElementLocationInViewCommand::~ElementLocationInViewCommand() {}
277 276
278 bool ElementLocationInViewCommand::DoesGet() { 277 bool ElementLocationInViewCommand::DoesGet() {
279 return true; 278 return true;
280 } 279 }
281 280
282 void ElementLocationInViewCommand::ExecuteGet(Response* const response) { 281 void ElementLocationInViewCommand::ExecuteGet(Response* const response) {
283 gfx::Point location; 282 Point location;
284 Error* error = session_->GetElementLocationInView(element, &location); 283 Error* error = session_->GetElementLocationInView(element, &location);
285 if (error) { 284 if (error) {
286 response->SetError(error); 285 response->SetError(error);
287 return; 286 return;
288 } 287 }
289 DictionaryValue* coord_dict = new DictionaryValue(); 288 DictionaryValue* coord_dict = new DictionaryValue();
290 coord_dict->SetInteger("x", location.x()); 289 coord_dict->SetInteger("x", location.x());
291 coord_dict->SetInteger("y", location.y()); 290 coord_dict->SetInteger("y", location.y());
292 response->SetValue(coord_dict); 291 response->SetValue(coord_dict);
293 } 292 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 DictionaryValue* parameters) 359 DictionaryValue* parameters)
361 : WebElementCommand(path_segments, parameters) {} 360 : WebElementCommand(path_segments, parameters) {}
362 361
363 ElementSizeCommand::~ElementSizeCommand() {} 362 ElementSizeCommand::~ElementSizeCommand() {}
364 363
365 bool ElementSizeCommand::DoesGet() { 364 bool ElementSizeCommand::DoesGet() {
366 return true; 365 return true;
367 } 366 }
368 367
369 void ElementSizeCommand::ExecuteGet(Response* const response) { 368 void ElementSizeCommand::ExecuteGet(Response* const response) {
370 gfx::Size size; 369 Size size;
371 Error* error = session_->GetElementSize( 370 Error* error = session_->GetElementSize(
372 session_->current_target(), element, &size); 371 session_->current_target(), element, &size);
373 if (error) { 372 if (error) {
374 response->SetError(error); 373 response->SetError(error);
375 return; 374 return;
376 } 375 }
377 DictionaryValue* dict = new DictionaryValue(); 376 DictionaryValue* dict = new DictionaryValue();
378 dict->SetInteger("width", size.width()); 377 dict->SetInteger("width", size.width());
379 dict->SetInteger("height", size.height()); 378 dict->SetInteger("height", size.height());
380 response->SetValue(dict); 379 response->SetValue(dict);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (!file_util::PathExists(FilePath(path))) { 557 if (!file_util::PathExists(FilePath(path))) {
559 return new Error( 558 return new Error(
560 kBadRequest, 559 kBadRequest,
561 base::StringPrintf("'%s' does not exist on the file system", 560 base::StringPrintf("'%s' does not exist on the file system",
562 path.c_str())); 561 path.c_str()));
563 } 562 }
564 563
565 paths.push_back(path); 564 paths.push_back(path);
566 } 565 }
567 566
568 gfx::Point location; 567 Point location;
569 error = session_->GetClickableLocation(element, &location); 568 error = session_->GetClickableLocation(element, &location);
570 if (error) { 569 if (error) {
571 return error; 570 return error;
572 } 571 }
573 572
574 return session_->DragAndDropFilePaths(location, paths); 573 return session_->DragAndDropFilePaths(location, paths);
575 } 574 }
576 575
577 Error* ElementValueCommand::SendKeys() const { 576 Error* ElementValueCommand::SendKeys() const {
578 ListValue* key_list; 577 ListValue* key_list;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return; 625 return;
627 } 626 }
628 if (!result->IsType(Value::TYPE_STRING)) { 627 if (!result->IsType(Value::TYPE_STRING)) {
629 response->SetError(new Error(kUnknownError, "Result is not string type")); 628 response->SetError(new Error(kUnknownError, "Result is not string type"));
630 return; 629 return;
631 } 630 }
632 response->SetValue(result.release()); 631 response->SetValue(result.release());
633 } 632 }
634 633
635 } // namespace webdriver 634 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/mouse_commands.cc ('k') | chrome/test/webdriver/dispatch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698