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

Unified Diff: content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc

Issue 2336803003: Make SyntheticPointerAction to flush the pointer action sequence (Closed)
Patch Set: controller Created 4 years 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/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
diff --git a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
index f832c919106a4a34a8149a6ee64b47e78b761b7d..0123f5ad6d8d5e829f1a6af09d5a6a412f5bbdc9 100644
--- a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
@@ -119,7 +119,7 @@ class MockSyntheticPointerMouseActionTarget
class SyntheticPointerActionTest : public testing::Test {
public:
SyntheticPointerActionTest() {
- action_param_list_.reset(new std::vector<SyntheticPointerActionParams>());
+ params_ = SyntheticPointerActionListParams();
num_success_ = 0;
num_failure_ = 0;
}
@@ -134,13 +134,11 @@ class SyntheticPointerActionTest : public testing::Test {
}
void ForwardSyntheticPointerAction() {
- pointer_action_.reset(new SyntheticPointerAction(
- action_param_list_.get(), synthetic_pointer_driver_.get()));
-
SyntheticGesture::Result result = pointer_action_->ForwardInputEvents(
base::TimeTicks::Now(), target_.get());
- if (result == SyntheticGesture::GESTURE_FINISHED)
+ if (result == SyntheticGesture::GESTURE_FINISHED ||
+ result == SyntheticGesture::GESTURE_RUNNING)
num_success_++;
else
num_failure_++;
@@ -151,153 +149,152 @@ class SyntheticPointerActionTest : public testing::Test {
std::unique_ptr<MockSyntheticPointerActionTarget> target_;
std::unique_ptr<SyntheticGesture> pointer_action_;
std::unique_ptr<SyntheticPointerDriver> synthetic_pointer_driver_;
- std::unique_ptr<std::vector<SyntheticPointerActionParams>> action_param_list_;
+ SyntheticPointerActionListParams params_;
};
TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
// Send a touch press for one finger.
- SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param0 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS,
SyntheticGestureParams::TOUCH_INPUT);
- params0.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params0);
- ForwardSyntheticPointerAction();
+ param0.set_index(0);
+ param0.set_position(gfx::PointF(54, 89));
+ params_.PushPointerActionParams(param0);
+
+ // Send a touch move for the first finger and a touch press for the second
+ // finger.
+ param0.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::MOVE);
+ param0.set_position(gfx::PointF(133, 156));
+ SyntheticPointerActionParams param1 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams::PointerActionType::PRESS,
+ SyntheticGestureParams::TOUCH_INPUT);
+ param1.set_index(1);
+ param1.set_position(gfx::PointF(79, 132));
+ params_.PushPointerActionParams(1, param0);
+ params_.PushPointerActionParams(1, param1);
+
+ // Send a touch move for the second finger.
+ param1.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::MOVE);
+ param1.set_position(gfx::PointF(87, 253));
+ params_.PushPointerActionParams(2, param1);
+
+ // Send touch releases for both fingers.
+ param0.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::RELEASE);
+ param1.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::RELEASE);
+ params_.PushPointerActionParams(3, param0);
+ params_.PushPointerActionParams(3, param1);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get());
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 1U);
- // Send a touch move for the first finger and a touch press for the second
- // finger.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::MOVE);
- action_param_list_->at(0).set_position(gfx::PointF(133, 156));
- SyntheticPointerActionParams params1 = SyntheticPointerActionParams(
- SyntheticPointerActionParams::PointerActionType::PRESS,
- SyntheticGestureParams::TOUCH_INPUT);
- params1.set_position(gfx::PointF(79, 132));
- action_param_list_->push_back(params1);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(2, num_success_);
EXPECT_EQ(0, num_failure_);
// The type of the SyntheticWebTouchEvent is the action of the last finger.
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(133, 156));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateMoved);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(action_param_list_->at(1).index(), 1);
EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(79, 132));
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 2U);
- // Send a touch move for the second finger.
- action_param_list_->at(1).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::MOVE);
- action_param_list_->at(1).set_position(gfx::PointF(87, 253));
ForwardSyntheticPointerAction();
-
EXPECT_EQ(3, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchMove);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(action_param_list_->at(1).index(), 1);
EXPECT_EQ(pointer_touch_target->positions(1), gfx::PointF(87, 253));
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved);
- ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 2U);
- // Send touch releases for both fingers.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::RELEASE);
- action_param_list_->at(1).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::RELEASE);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(4, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), -1);
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateReleased);
EXPECT_EQ(pointer_touch_target->indexes(1), 1);
- EXPECT_EQ(action_param_list_->at(1).index(), -1);
EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased);
- ASSERT_EQ(pointer_touch_target->touch_length(), 2U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 2U);
}
-TEST_F(SyntheticPointerActionTest, PointerTouchActionWithIdle) {
+TEST_F(SyntheticPointerActionTest, PointerTouchActionsMultiRelease) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
int count_success = 1;
+ int count = 0;
// Send a touch press for one finger.
- SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param0 = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS,
SyntheticGestureParams::TOUCH_INPUT);
- params0.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params0);
- ForwardSyntheticPointerAction();
+ param0.set_index(0);
+ param0.set_position(gfx::PointF(54, 89));
+ params_.PushPointerActionParams(count++, param0);
+ SyntheticPointerActionParams param1;
+ param1.set_index(1);
+ param1.set_gesture_source_type(SyntheticGestureParams::TOUCH_INPUT);
+ for (int i = 0; i < 3; ++i) {
+ // Send a touch press for the second finger and not move the first finger.
+ param1.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::PRESS);
+ param1.set_position(gfx::PointF(123, 69));
+ params_.PushPointerActionParams(count++, param1);
+
+ // Send a touch release for the second finger and not move the first finger.
+ param1.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::RELEASE);
+ params_.PushPointerActionParams(count++, param1);
+ }
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+
+ ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get());
EXPECT_EQ(count_success++, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 1U);
- SyntheticPointerActionParams params1;
- params1.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
- action_param_list_->push_back(params1);
- for (int i = 0; i < 3; ++i) {
- // Send a touch press for the second finger and not move the first finger.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::IDLE);
- action_param_list_->at(1).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::PRESS);
- action_param_list_->at(1).set_position(gfx::PointF(123, 69));
- int index = 1 + i;
+ for (int index = 1; index < 4; ++index) {
ForwardSyntheticPointerAction();
-
EXPECT_EQ(count_success++, num_success_);
EXPECT_EQ(0, num_failure_);
// The type of the SyntheticWebTouchEvent is the action of the last finger.
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(index), index);
- EXPECT_EQ(action_param_list_->at(1).index(), index);
EXPECT_EQ(pointer_touch_target->positions(index), gfx::PointF(123, 69));
EXPECT_EQ(pointer_touch_target->states(index), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), index + 1U);
-
- // Send a touch release for the second finger and not move the first finger.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::IDLE);
- action_param_list_->at(1).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::RELEASE);
+ EXPECT_EQ(pointer_touch_target->touch_length(), index + 1U);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(count_success++, num_success_);
EXPECT_EQ(0, num_failure_);
// The type of the SyntheticWebTouchEvent is the action of the last finger.
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchEnd);
EXPECT_EQ(pointer_touch_target->indexes(index), index);
- EXPECT_EQ(action_param_list_->at(1).index(), -1);
EXPECT_EQ(pointer_touch_target->states(index),
WebTouchPoint::StateReleased);
- ASSERT_EQ(pointer_touch_target->touch_length(), index + 1U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), index + 1U);
}
}
@@ -305,33 +302,35 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
// Users' gesture source type does not match with the touch action.
- SyntheticPointerActionParams params = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS,
SyntheticGestureParams::MOUSE_INPUT);
- params.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params);
- ForwardSyntheticPointerAction();
+ param.set_index(0);
+ param.set_position(gfx::PointF(54, 89));
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- params = SyntheticPointerActionParams(
- SyntheticPointerActionParams::PointerActionType::PRESS,
- SyntheticGestureParams::TOUCH_INPUT);
- params.set_position(gfx::PointF(54, 89));
- action_param_list_->at(0) = params;
- ForwardSyntheticPointerAction();
+ param.set_gesture_source_type(SyntheticGestureParams::TOUCH_INPUT);
+ param.set_index(0);
+ param.set_position(gfx::PointF(54, 89));
+ params_ = SyntheticPointerActionListParams();
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get());
EXPECT_EQ(1, num_success_);
EXPECT_EQ(1, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 1U);
}
TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
@@ -339,46 +338,49 @@ TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
// Cannot send a touch move or touch release without sending a touch press
// first.
- SyntheticPointerActionParams params = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::MOVE,
SyntheticGestureParams::TOUCH_INPUT);
- params.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params);
- ForwardSyntheticPointerAction();
+ param.set_index(0);
+ param.set_position(gfx::PointF(54, 89));
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- action_param_list_->at(0).set_pointer_action_type(
+ param.set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::RELEASE);
- ForwardSyntheticPointerAction();
+ params_ = SyntheticPointerActionListParams();
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
EXPECT_EQ(0, num_success_);
EXPECT_EQ(2, num_failure_);
// Send a touch press for one finger.
- action_param_list_->at(0).set_pointer_action_type(
+ param.set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- ForwardSyntheticPointerAction();
+ params_ = SyntheticPointerActionListParams();
+ params_.PushPointerActionParams(param);
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
MockSyntheticPointerTouchActionTarget* pointer_touch_target =
static_cast<MockSyntheticPointerTouchActionTarget*>(target_.get());
EXPECT_EQ(1, num_success_);
EXPECT_EQ(2, num_failure_);
EXPECT_EQ(pointer_touch_target->type(), WebInputEvent::TouchStart);
EXPECT_EQ(pointer_touch_target->indexes(0), 0);
- EXPECT_EQ(action_param_list_->at(0).index(), 0);
EXPECT_EQ(pointer_touch_target->positions(0), gfx::PointF(54, 89));
EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
- ASSERT_EQ(pointer_touch_target->touch_length(), 1U);
+ EXPECT_EQ(pointer_touch_target->touch_length(), 1U);
// Cannot send a touch press again without releasing the finger.
- action_param_list_->at(0).gesture_source_type =
- SyntheticGestureParams::TOUCH_INPUT;
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::PRESS);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(1, num_success_);
EXPECT_EQ(3, num_failure_);
}
@@ -387,54 +389,56 @@ TEST_F(SyntheticPointerActionTest, PointerMouseAction) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
// Send a mouse move.
- SyntheticPointerActionParams params = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::MOVE,
SyntheticGestureParams::MOUSE_INPUT);
- params.set_position(gfx::PointF(189, 62));
- action_param_list_->push_back(params);
- ForwardSyntheticPointerAction();
+ param.set_position(gfx::PointF(189, 62));
+ params_.PushPointerActionParams(param);
+
+ // Send a mouse down.
+ param.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::PRESS);
+ params_.PushPointerActionParams(param);
+ // Send a mouse drag.
+ param.set_position(gfx::PointF(326, 298));
+ param.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::MOVE);
+ params_.PushPointerActionParams(param);
+
+ // Send a mouse up.
+ param.set_pointer_action_type(
+ SyntheticPointerActionParams::PointerActionType::RELEASE);
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+
+ ForwardSyntheticPointerAction();
MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
+ EXPECT_EQ(pointer_mouse_target->position(), gfx::PointF(189, 62));
EXPECT_EQ(pointer_mouse_target->clickCount(), 0);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton);
- // Send a mouse down.
- action_param_list_->at(0).set_position(gfx::PointF(189, 62));
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::PRESS);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(2, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
+ EXPECT_EQ(pointer_mouse_target->position(), gfx::PointF(189, 62));
EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
- // Send a mouse drag.
- action_param_list_->at(0).set_position(gfx::PointF(326, 298));
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::MOVE);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(3, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove);
- EXPECT_EQ(pointer_mouse_target->position(),
- action_param_list_->at(0).position());
+ EXPECT_EQ(pointer_mouse_target->position(), gfx::PointF(326, 298));
EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
- // Send a mouse up.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::RELEASE);
ForwardSyntheticPointerAction();
-
EXPECT_EQ(4, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseUp);
@@ -446,29 +450,30 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
// Users' gesture source type does not match with the mouse action.
- SyntheticPointerActionParams params = SyntheticPointerActionParams(
+ SyntheticPointerActionParams param = SyntheticPointerActionParams(
SyntheticPointerActionParams::PointerActionType::PRESS,
SyntheticGestureParams::TOUCH_INPUT);
- params.set_position(gfx::PointF(54, 89));
- action_param_list_->push_back(params);
- ForwardSyntheticPointerAction();
+ param.set_position(gfx::PointF(54, 89));
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
- params = SyntheticPointerActionParams(
- SyntheticPointerActionParams::PointerActionType::PRESS,
- SyntheticGestureParams::MOUSE_INPUT);
- params.set_position(gfx::PointF(54, 89));
- action_param_list_->at(0) = params;
- ForwardSyntheticPointerAction();
+ param.set_gesture_source_type(SyntheticGestureParams::MOUSE_INPUT);
+ param.set_position(gfx::PointF(54, 89));
+ params_ = SyntheticPointerActionListParams();
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+ ForwardSyntheticPointerAction();
MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
EXPECT_EQ(1, num_success_);
EXPECT_EQ(1, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
+ EXPECT_EQ(pointer_mouse_target->position(), gfx::PointF(54, 89));
EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
}
@@ -476,49 +481,40 @@ TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) {
TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
- // Send a mouse move.
- SyntheticPointerActionParams params = SyntheticPointerActionParams(
- SyntheticPointerActionParams::PointerActionType::MOVE,
+ // Cannot send a mouse up without sending a mouse down first.
+ SyntheticPointerActionParams param = SyntheticPointerActionParams(
+ SyntheticPointerActionParams::PointerActionType::RELEASE,
SyntheticGestureParams::MOUSE_INPUT);
- params.set_position(gfx::PointF(189, 62));
- action_param_list_->push_back(params);
- ForwardSyntheticPointerAction();
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
- MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
- static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
- EXPECT_EQ(1, num_success_);
- EXPECT_EQ(0, num_failure_);
- EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
- EXPECT_EQ(pointer_mouse_target->clickCount(), 0);
- EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::NoButton);
-
- // Cannot send a mouse up without sending a mouse down first.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::RELEASE);
ForwardSyntheticPointerAction();
-
- EXPECT_EQ(1, num_success_);
+ EXPECT_EQ(0, num_success_);
EXPECT_EQ(1, num_failure_);
// Send a mouse down for one finger.
- action_param_list_->at(0).set_pointer_action_type(
+ param.set_pointer_action_type(
SyntheticPointerActionParams::PointerActionType::PRESS);
- ForwardSyntheticPointerAction();
+ param.set_position(gfx::PointF(54, 89));
+ params_ = SyntheticPointerActionListParams();
+ params_.PushPointerActionParams(param);
- EXPECT_EQ(2, num_success_);
+ // Cannot send a mouse down again without releasing the mouse button.
+ params_.PushPointerActionParams(param);
+ pointer_action_.reset(new SyntheticPointerAction(params_));
+
+ ForwardSyntheticPointerAction();
+ MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
+ static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
+ EXPECT_EQ(1, num_success_);
EXPECT_EQ(1, num_failure_);
EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown);
- EXPECT_EQ(pointer_mouse_target->position(), params.position());
+ EXPECT_EQ(pointer_mouse_target->position(), gfx::PointF(54, 89));
EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
- // Cannot send a mouse down again without releasing the mouse button.
- action_param_list_->at(0).set_pointer_action_type(
- SyntheticPointerActionParams::PointerActionType::PRESS);
ForwardSyntheticPointerAction();
-
- EXPECT_EQ(2, num_success_);
+ EXPECT_EQ(1, num_success_);
EXPECT_EQ(2, num_failure_);
}

Powered by Google App Engine
This is Rietveld 408576698