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

Unified Diff: chrome/test/webdriver/commands/mouse_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/webdriver/automation.cc ('k') | chrome/test/webdriver/commands/webelement_commands.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/commands/mouse_commands.cc
diff --git a/chrome/test/webdriver/commands/mouse_commands.cc b/chrome/test/webdriver/commands/mouse_commands.cc
index 70339b8e1420d80e9de58c6ca594cba749631abf..288ebcbb6e96bc224d59f147e1f5b036704fba19 100644
--- a/chrome/test/webdriver/commands/mouse_commands.cc
+++ b/chrome/test/webdriver/commands/mouse_commands.cc
@@ -6,13 +6,13 @@
#include "base/values.h"
#include "chrome/common/automation_constants.h"
+#include "chrome/test/automation/value_conversion_util.h"
#include "chrome/test/webdriver/commands/response.h"
#include "chrome/test/webdriver/session.h"
-#include "chrome/test/webdriver/utility_functions.h"
#include "chrome/test/webdriver/web_element_id.h"
+#include "chrome/test/webdriver/webdriver_basic_types.h"
#include "chrome/test/webdriver/webdriver_error.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/size.h"
+#include "chrome/test/webdriver/webdriver_util.h"
namespace {
@@ -46,29 +46,23 @@ void MoveAndClickCommand::ExecutePost(Response* response) {
if (tag_name == "option") {
const char* kCanOptionBeToggledScript =
- "return (function(option) {"
+ "function(option) {"
" var select = option.parentElement;"
" if (!select || select.tagName.toLowerCase() != 'select')"
" throw new Error('Option element is not in a select');"
" return select.multiple;"
- "}).apply(null, arguments);";
- ListValue args;
- args.Append(element.ToValue());
- Value* value = NULL;
- error = session_->ExecuteScript(
- session_->current_target(), kCanOptionBeToggledScript, &args, &value);
+ "}";
+ bool can_be_toggled;
+ error = session_->ExecuteScriptAndParse(
+ session_->current_target(),
+ kCanOptionBeToggledScript,
+ "canOptionBeToggled",
+ CreateListValueFrom(element),
+ CreateDirectValueParser(&can_be_toggled));
if (error) {
response->SetError(error);
return;
}
- scoped_ptr<Value> scoped_value(value);
- bool can_be_toggled;
- if (!value->GetAsBoolean(&can_be_toggled)) {
- response->SetError(
- new Error(kUnknownError, "canOptionBeToggled returned non-boolean: " +
- JsonStringify(value)));
- return;
- }
if (can_be_toggled) {
error = session_->ToggleOptionElement(
@@ -78,7 +72,7 @@ void MoveAndClickCommand::ExecutePost(Response* response) {
session_->current_target(), element, true);
}
} else {
- gfx::Point location;
+ Point location;
error = session_->GetClickableLocation(element, &location);
if (!error)
error = session_->MouseMoveAndClick(location, automation::kLeftButton);
@@ -101,7 +95,7 @@ bool HoverCommand::DoesPost() {
void HoverCommand::ExecutePost(Response* response) {
Error* error = NULL;
- gfx::Point location;
+ Point location;
error = session_->GetClickableLocation(element, &location);
if (!error)
error = session_->MouseMove(location);
@@ -136,14 +130,14 @@ bool DragCommand::DoesPost() {
void DragCommand::ExecutePost(Response* response) {
Error* error = NULL;
- gfx::Point drag_from;
+ Point drag_from;
error = session_->GetClickableLocation(element, &drag_from);
if (error) {
response->SetError(error);
return;
}
- gfx::Point drag_to(drag_from);
+ Point drag_to(drag_from);
drag_to.Offset(drag_x_, drag_y_);
if (drag_to.x() < 0 || drag_to.y() < 0)
error = new Error(kBadRequest, "Invalid (x,y) coordinates");
@@ -199,7 +193,7 @@ bool MoveToCommand::Init(Response* const response) {
}
void MoveToCommand::ExecutePost(Response* const response) {
- gfx::Point location;
+ Point location;
Error* error;
if (has_element_) {
@@ -221,7 +215,7 @@ void MoveToCommand::ExecutePost(Response* const response) {
DCHECK(has_element_);
// If not, calculate the half of the element size and translate by it.
- gfx::Size size;
+ Size size;
error = session_->GetElementSize(session_->current_target(),
element_, &size);
if (error) {
« no previous file with comments | « chrome/test/webdriver/automation.cc ('k') | chrome/test/webdriver/commands/webelement_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698