| 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 48694180c123a2037fe64616d028b5e6d5b56e05..3ef3d6f0fa9e45ec9a7f3be6fe4ed720b36ba2cf 100644
|
| --- a/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
|
| +++ b/content/browser/renderer_host/input/synthetic_pointer_action_unittest.cc
|
| @@ -33,7 +33,6 @@ WebTouchPoint::State ToWebTouchPointState(
|
| return WebTouchPoint::StateReleased;
|
| case SyntheticPointerActionParams::PointerActionType::IDLE:
|
| return WebTouchPoint::StateStationary;
|
| - case SyntheticPointerActionParams::PointerActionType::FINISH:
|
| case SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED:
|
| NOTREACHED()
|
| << "Invalid SyntheticPointerActionParams::PointerActionType.";
|
| @@ -53,7 +52,6 @@ WebInputEvent::Type ToWebMouseEventType(
|
| case SyntheticPointerActionParams::PointerActionType::RELEASE:
|
| return WebInputEvent::MouseUp;
|
| case SyntheticPointerActionParams::PointerActionType::IDLE:
|
| - case SyntheticPointerActionParams::PointerActionType::FINISH:
|
| case SyntheticPointerActionParams::PointerActionType::NOT_INITIALIZED:
|
| NOTREACHED()
|
| << "Invalid SyntheticPointerActionParams::PointerActionType.";
|
| @@ -102,7 +100,7 @@ class MockSyntheticPointerTouchActionTarget
|
| DCHECK(WebInputEvent::isTouchEventType(event.type));
|
| const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
|
| type_ = touch_event.type;
|
| - for (size_t i = 0; i < touch_event.touchesLength; ++i) {
|
| + for (size_t i = 0; i < WebTouchEvent::kTouchesLengthCap; ++i) {
|
| indexes_[i] = touch_event.touches[i].id;
|
| positions_[i] = gfx::PointF(touch_event.touches[i].position);
|
| states_[i] = touch_event.touches[i].state;
|
| @@ -150,7 +148,8 @@ class MockSyntheticPointerTouchActionTarget
|
|
|
| testing::AssertionResult result = testing::AssertionSuccess();
|
| for (size_t i = 0; i < params_list.size(); ++i) {
|
| - result = SyntheticTouchActionDispatchedCorrectly(params_list[i], i);
|
| + result = SyntheticTouchActionDispatchedCorrectly(params_list[i],
|
| + params_list[i].index());
|
| if (result == testing::AssertionFailure())
|
| return result;
|
| }
|
| @@ -187,29 +186,28 @@ class MockSyntheticPointerMouseActionTarget
|
| testing::AssertionResult SyntheticMouseActionDispatchedCorrectly(
|
| const SyntheticPointerActionParams& param,
|
| int click_count) {
|
| - if (type() != ToWebMouseEventType(param.pointer_action_type())) {
|
| + if (type_ != ToWebMouseEventType(param.pointer_action_type())) {
|
| return testing::AssertionFailure()
|
| - << "Pointer type was " << WebInputEvent::GetName(type())
|
| + << "Pointer type was " << WebInputEvent::GetName(type_)
|
| << ", expected " << WebInputEvent::GetName(ToWebMouseEventType(
|
| - param.pointer_action_type()))
|
| - << ".";
|
| + param.pointer_action_type())) << ".";
|
| }
|
|
|
| - if (clickCount() != click_count) {
|
| + if (clickCount_ != click_count) {
|
| return testing::AssertionFailure() << "Pointer click count was "
|
| - << clickCount() << ", expected "
|
| + << clickCount_ << ", expected "
|
| << click_count << ".";
|
| }
|
|
|
| - if (clickCount() == 1 && button() != WebMouseEvent::Button::Left) {
|
| + if (clickCount_ == 1 && button_ != WebMouseEvent::Button::Left) {
|
| return testing::AssertionFailure()
|
| - << "Pointer button was " << (int)button() << ", expected "
|
| + << "Pointer button was " << (int)button_ << ", expected "
|
| << (int)WebMouseEvent::Button::Left << ".";
|
| }
|
|
|
| - if (clickCount() == 0 && button() != WebMouseEvent::Button::NoButton) {
|
| + if (clickCount_ == 0 && button_ != WebMouseEvent::Button::NoButton) {
|
| return testing::AssertionFailure()
|
| - << "Pointer button was " << (int)button() << ", expected "
|
| + << "Pointer button was " << (int)button_ << ", expected "
|
| << (int)WebMouseEvent::Button::NoButton << ".";
|
| }
|
|
|
| @@ -217,9 +215,9 @@ class MockSyntheticPointerMouseActionTarget
|
| SyntheticPointerActionParams::PointerActionType::PRESS ||
|
| param.pointer_action_type() ==
|
| SyntheticPointerActionParams::PointerActionType::MOVE) &&
|
| - position() != param.position()) {
|
| + position_ != param.position()) {
|
| return testing::AssertionFailure()
|
| - << "Pointer position was " << position().ToString()
|
| + << "Pointer position was " << position_.ToString()
|
| << ", expected " << param.position().ToString() << ".";
|
| }
|
| return testing::AssertionSuccess();
|
| @@ -230,10 +228,6 @@ class MockSyntheticPointerMouseActionTarget
|
| return SyntheticGestureParams::MOUSE_INPUT;
|
| }
|
|
|
| - gfx::PointF position() const { return position_; }
|
| - int clickCount() const { return clickCount_; }
|
| - WebMouseEvent::Button button() const { return button_; }
|
| -
|
| private:
|
| gfx::PointF position_;
|
| int clickCount_;
|
| @@ -243,7 +237,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;
|
| }
|
| @@ -258,13 +252,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_++;
|
| @@ -275,202 +267,201 @@ 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::PointerActionType::PRESS,
|
| - SyntheticGestureParams::TOUCH_INPUT);
|
| - params0.set_position(gfx::PointF(54, 89));
|
| - action_param_list_->push_back(params0);
|
| - ForwardSyntheticPointerAction();
|
| + SyntheticPointerActionParams param1 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param1.set_index(0);
|
| + param1.set_position(gfx::PointF(54, 89));
|
| + SyntheticPointerActionListParams::ParamList param_list1;
|
| + param_list1.push_back(param1);
|
| + params_.PushPointerActionParamsList(param_list1);
|
| +
|
| + // Send a touch move for the first finger and a touch press for the second
|
| + // finger.
|
| + param1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + param1.set_position(gfx::PointF(133, 156));
|
| + SyntheticPointerActionParams param2 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param2.set_index(1);
|
| + param2.set_position(gfx::PointF(79, 132));
|
| + SyntheticPointerActionListParams::ParamList param_list2;
|
| + param_list2.push_back(param1);
|
| + param_list2.push_back(param2);
|
| + params_.PushPointerActionParamsList(param_list2);
|
|
|
| + // Send a touch move for the second finger.
|
| + param1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::IDLE);
|
| + param2.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + param2.set_position(gfx::PointF(87, 253));
|
| + SyntheticPointerActionListParams::ParamList param_list3;
|
| + param_list3.push_back(param1);
|
| + param_list3.push_back(param2);
|
| + params_.PushPointerActionParamsList(param_list3);
|
| +
|
| + // Send touch releases for both fingers.
|
| + SyntheticPointerActionListParams::ParamList param_list4;
|
| + param1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + param2.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + param_list4.push_back(param1);
|
| + param_list4.push_back(param2);
|
| + params_.PushPointerActionParamsList(param_list4);
|
| + 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list1));
|
|
|
| - // 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list2));
|
|
|
| - // 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list3));
|
|
|
| - // 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list4));
|
| }
|
|
|
| -TEST_F(SyntheticPointerActionTest, PointerTouchActionWithIdle) {
|
| +TEST_F(SyntheticPointerActionTest, PointerTouchActionsMultiPressRelease) {
|
| CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
|
| int count_success = 1;
|
| +
|
| // Send a touch press for one finger.
|
| - SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::PRESS,
|
| - SyntheticGestureParams::TOUCH_INPUT);
|
| - params0.set_position(gfx::PointF(54, 89));
|
| - action_param_list_->push_back(params0);
|
| - ForwardSyntheticPointerAction();
|
| + SyntheticPointerActionParams param1 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param1.set_index(0);
|
| + param1.set_position(gfx::PointF(54, 89));
|
| + SyntheticPointerActionListParams::ParamList param_list1;
|
| + param_list1.push_back(param1);
|
| + params_.PushPointerActionParamsList(param_list1);
|
| +
|
| + SyntheticPointerActionParams param2 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param2.set_index(1);
|
| + param2.set_position(gfx::PointF(123, 69));
|
| + param1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::IDLE);
|
| + SyntheticPointerActionListParams::ParamList param_list2;
|
| + param_list2.push_back(param1);
|
| + param_list2.push_back(param2);
|
| +
|
| + param2.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + SyntheticPointerActionListParams::ParamList param_list3;
|
| + param_list3.push_back(param1);
|
| + param_list3.push_back(param2);
|
| + for (int i = 0; i < 3; ++i) {
|
| + // Send a touch press for the second finger and not move the first finger.
|
| + params_.PushPointerActionParamsList(param_list2);
|
|
|
| + // Send a touch release for the second finger and not move the first finger.
|
| + params_.PushPointerActionParamsList(param_list3);
|
| + }
|
| + 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list1));
|
|
|
| - 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));
|
| + 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_TRUE(
|
| pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| -
|
| - // 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);
|
| + param_list2));
|
|
|
| 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_TRUE(
|
| pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + param_list3));
|
| }
|
| }
|
|
|
| -TEST_F(SyntheticPointerActionTest, PointerTouchActionSourceTypeInvalid) {
|
| - CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
|
| -
|
| - // Users' gesture source type does not match with the touch action.
|
| - SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::PRESS,
|
| - SyntheticGestureParams::MOUSE_INPUT);
|
| - params.set_position(gfx::PointF(54, 89));
|
| - action_param_list_->push_back(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();
|
| -
|
| - 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| -}
|
| -
|
| TEST_F(SyntheticPointerActionTest, PointerTouchActionTypeInvalid) {
|
| CreateSyntheticPointerActionTarget<MockSyntheticPointerTouchActionTarget>();
|
|
|
| // Cannot send a touch move or touch release without sending a touch press
|
| // first.
|
| - SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::MOVE,
|
| - SyntheticGestureParams::TOUCH_INPUT);
|
| - params.set_position(gfx::PointF(54, 89));
|
| - action_param_list_->push_back(params);
|
| - ForwardSyntheticPointerAction();
|
| + SyntheticPointerActionParams param = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + 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_TRUE(pointer_touch_target->SyntheticTouchActionListDispatchedCorrectly(
|
| - *action_param_list_.get()));
|
| + EXPECT_TRUE(
|
| + pointer_touch_target->SyntheticTouchActionDispatchedCorrectly(param, 0));
|
|
|
| // 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_);
|
| }
|
| @@ -479,124 +470,90 @@ TEST_F(SyntheticPointerActionTest, PointerMouseAction) {
|
| CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
|
|
|
| // Send a mouse move.
|
| - SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::MOVE,
|
| - SyntheticGestureParams::MOUSE_INPUT);
|
| - params.set_position(gfx::PointF(189, 62));
|
| - action_param_list_->push_back(params);
|
| - ForwardSyntheticPointerAction();
|
| + SyntheticPointerActionParams param1 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + param1.set_position(gfx::PointF(189, 62));
|
| + params_.PushPointerActionParams(param1);
|
|
|
| + // Send a mouse down.
|
| + SyntheticPointerActionParams param2 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param2.set_position(gfx::PointF(189, 62));
|
| + params_.PushPointerActionParams(param2);
|
| +
|
| + // Send a mouse drag.
|
| + SyntheticPointerActionParams param3 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + param3.set_position(gfx::PointF(326, 298));
|
| + params_.PushPointerActionParams(param3);
|
| +
|
| + // Send a mouse up.
|
| + SyntheticPointerActionParams param4 = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + params_.PushPointerActionParams(param4);
|
| + 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_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 0));
|
| + EXPECT_TRUE(
|
| + pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param1, 0));
|
|
|
| - // 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_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 1));
|
| + EXPECT_TRUE(
|
| + pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param2, 1));
|
|
|
| - // 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_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 1));
|
| + EXPECT_TRUE(
|
| + pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param3, 1));
|
|
|
| - // 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_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 1));
|
| + EXPECT_TRUE(
|
| + pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param4, 1));
|
| }
|
|
|
| -TEST_F(SyntheticPointerActionTest, PointerMouseActionSourceTypeInvalid) {
|
| +TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
|
| CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
|
|
|
| - // Users' gesture source type does not match with the mouse action.
|
| - SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::PRESS,
|
| - SyntheticGestureParams::TOUCH_INPUT);
|
| - params.set_position(gfx::PointF(54, 89));
|
| - action_param_list_->push_back(params);
|
| - ForwardSyntheticPointerAction();
|
| + // Cannot send a mouse up without sending a mouse down first.
|
| + SyntheticPointerActionParams param = SyntheticPointerActionParams(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + 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();
|
| -
|
| - MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
|
| - static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
|
| - EXPECT_EQ(1, num_success_);
|
| - EXPECT_EQ(1, num_failure_);
|
| - EXPECT_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 1));
|
| -}
|
| + // Send a mouse down for one finger.
|
| + param.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + param.set_position(gfx::PointF(54, 89));
|
| + params_ = SyntheticPointerActionListParams();
|
| + params_.PushPointerActionParams(param);
|
|
|
| -TEST_F(SyntheticPointerActionTest, PointerMouseActionTypeInvalid) {
|
| - CreateSyntheticPointerActionTarget<MockSyntheticPointerMouseActionTarget>();
|
| + // Cannot send a mouse down again without releasing the mouse button.
|
| + params_.PushPointerActionParams(param);
|
| + pointer_action_.reset(new SyntheticPointerAction(params_));
|
|
|
| - // Send a mouse move.
|
| - SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| - SyntheticPointerActionParams::PointerActionType::MOVE,
|
| - SyntheticGestureParams::MOUSE_INPUT);
|
| - params.set_position(gfx::PointF(189, 62));
|
| - action_param_list_->push_back(params);
|
| ForwardSyntheticPointerAction();
|
| -
|
| MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
|
| static_cast<MockSyntheticPointerMouseActionTarget*>(target_.get());
|
| EXPECT_EQ(1, num_success_);
|
| - EXPECT_EQ(0, num_failure_);
|
| - EXPECT_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 0));
|
| -
|
| - // 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(1, num_failure_);
|
| -
|
| - // Send a mouse down for one finger.
|
| - action_param_list_->at(0).set_pointer_action_type(
|
| - SyntheticPointerActionParams::PointerActionType::PRESS);
|
| - ForwardSyntheticPointerAction();
|
| -
|
| - EXPECT_EQ(2, num_success_);
|
| EXPECT_EQ(1, num_failure_);
|
| - EXPECT_TRUE(pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(
|
| - action_param_list_->at(0), 1));
|
| + EXPECT_TRUE(
|
| + pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1));
|
|
|
| - // 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_);
|
| }
|
|
|
|
|