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

Unified Diff: content/renderer/gpu/actions_parser.cc

Issue 2621353003: Replace mouse actions in pointer event tests with pointerActionSequence (Closed)
Patch Set: pointer mouse tests Created 3 years, 11 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
Index: content/renderer/gpu/actions_parser.cc
diff --git a/content/renderer/gpu/actions_parser.cc b/content/renderer/gpu/actions_parser.cc
index 41b5a3e25a748187d3187ee8718f5bfd9a2236e3..a469ce30cbc18c41a1ad73176d94110cd15b4dae 100644
--- a/content/renderer/gpu/actions_parser.cc
+++ b/content/renderer/gpu/actions_parser.cc
@@ -37,6 +37,16 @@ SyntheticGestureParams::GestureSourceType ToSyntheticGestureSourceType(
return SyntheticGestureParams::DEFAULT_INPUT;
}
+SyntheticPointerActionParams::Button ToSyntheticMouseButton(
+ std::string button) {
+ if (button == "left")
+ return SyntheticPointerActionParams::Button::LEFT;
+ else if (button == "middle")
+ return SyntheticPointerActionParams::Button::MIDDLE;
+ else
tdresser 2017/01/19 14:41:57 Let's be explicit here, DCHECK if the string isn't
+ return SyntheticPointerActionParams::Button::RIGHT;
+}
+
} // namespace
ActionsParser::ActionsParser(base::Value* pointer_actions_value)
@@ -192,6 +202,20 @@ bool ActionsParser::ParseAction(
return false;
}
+ std::string button_name = "left";
+ if (action.HasKey("button") && !action.GetString("button", &button_name)) {
+ error_message_ = base::StringPrintf(
+ "actions[%d].actions.button is not a string", action_index_);
+ return false;
+ } else if (button_name != "left" && button_name != "middle" &&
+ button_name != "right") {
+ error_message_ = base::StringPrintf(
+ "actions[%d].actions.button is an unsupported button", action_index_);
+ return false;
+ }
+ SyntheticPointerActionParams::Button button =
+ ToSyntheticMouseButton(button_name);
+
double duration = 0;
int num_idle = 0;
if (pointer_action_type ==
@@ -212,11 +236,20 @@ bool ActionsParser::ParseAction(
SyntheticPointerActionParams action_param(pointer_action_type);
action_param.set_index(action_index_);
- if (pointer_action_type ==
- SyntheticPointerActionParams::PointerActionType::PRESS ||
- pointer_action_type ==
- SyntheticPointerActionParams::PointerActionType::MOVE) {
- action_param.set_position(gfx::PointF(position_x, position_y));
+ switch (pointer_action_type) {
+ case SyntheticPointerActionParams::PointerActionType::PRESS:
+ action_param.set_position(gfx::PointF(position_x, position_y));
+ action_param.set_button(button);
+ break;
+ case SyntheticPointerActionParams::PointerActionType::MOVE:
+ action_param.set_position(gfx::PointF(position_x, position_y));
+ break;
+ case SyntheticPointerActionParams::PointerActionType::RELEASE:
+ action_param.set_button(button);
+ break;
+ case SyntheticPointerActionParams::PointerActionType::IDLE:
+ case SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED:
+ break;
}
param_list.push_back(action_param);

Powered by Google App Engine
This is Rietveld 408576698