| Index: content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
|
| diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
|
| index c2e16707f9d306ef4a0bc8f65fe4e4fdb2882557..10fd98a01c83aa51d63fa538c51ec89b8773a07f 100644
|
| --- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
|
| +++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
|
| @@ -478,17 +478,9 @@ class MockSyntheticPointerActionTarget : public MockSyntheticGestureTarget {
|
| MockSyntheticPointerActionTarget() {}
|
| ~MockSyntheticPointerActionTarget() override {}
|
|
|
| - gfx::PointF positions(int index) const { return positions_[index]; }
|
| - int indexes(int index) const { return indexes_[index]; }
|
| - WebTouchPoint::State states(int index) { return states_[index]; }
|
| - unsigned touch_length() const { return touch_length_; }
|
| WebInputEvent::Type type() const { return type_; }
|
|
|
| protected:
|
| - gfx::PointF positions_[kTouchPointersLength];
|
| - unsigned touch_length_;
|
| - int indexes_[kTouchPointersLength];
|
| - WebTouchPoint::State states_[kTouchPointersLength];
|
| WebInputEvent::Type type_;
|
| };
|
|
|
| @@ -509,6 +501,42 @@ class MockSyntheticPointerTouchActionTarget
|
| }
|
| touch_length_ = touch_event.touchesLength;
|
| }
|
| +
|
| + gfx::PointF positions(int index) const { return positions_[index]; }
|
| + int indexes(int index) const { return indexes_[index]; }
|
| + WebTouchPoint::State states(int index) { return states_[index]; }
|
| + unsigned touch_length() const { return touch_length_; }
|
| +
|
| + private:
|
| + gfx::PointF positions_[kTouchPointersLength];
|
| + unsigned touch_length_;
|
| + int indexes_[kTouchPointersLength];
|
| + WebTouchPoint::State states_[kTouchPointersLength];
|
| +};
|
| +
|
| +class MockSyntheticPointerMouseActionTarget
|
| + : public MockSyntheticPointerActionTarget {
|
| + public:
|
| + MockSyntheticPointerMouseActionTarget() {}
|
| + ~MockSyntheticPointerMouseActionTarget() override {}
|
| +
|
| + void DispatchInputEventToPlatform(const WebInputEvent& event) override {
|
| + ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type));
|
| + const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
|
| + type_ = mouse_event.type;
|
| + position_ = gfx::PointF(mouse_event.x, mouse_event.y);
|
| + clickCount_ = mouse_event.clickCount;
|
| + button_ = mouse_event.button;
|
| + }
|
| +
|
| + gfx::PointF position() const { return position_; }
|
| + int clickCount() const { return clickCount_; }
|
| + WebMouseEvent::Button button() const { return button_; }
|
| +
|
| + private:
|
| + gfx::PointF position_;
|
| + int clickCount_;
|
| + WebMouseEvent::Button button_;
|
| };
|
|
|
| class SyntheticGestureControllerTestBase {
|
| @@ -1472,6 +1500,145 @@ TEST_F(SyntheticGestureControllerTest, TapGestureMouse) {
|
| base::TimeDelta::FromMilliseconds(params.duration_ms));
|
| }
|
|
|
| +TEST_F(SyntheticGestureControllerTest, PointerTouchAction) {
|
| + CreateControllerAndTarget<MockSyntheticPointerTouchActionTarget>();
|
| + std::unique_ptr<SyntheticPointer> synthetic_pointer =
|
| + SyntheticPointer::Create(SyntheticGestureParams::TOUCH_INPUT);
|
| + SyntheticPointerAction::IndexMap index_map;
|
| + std::fill(index_map.begin(), index_map.end(), -1);
|
| + std::vector<SyntheticPointerActionParams> action_param_list;
|
| +
|
| + SyntheticPointerActionParams params0 = SyntheticPointerActionParams(
|
| + SyntheticGestureParams::TOUCH_INPUT,
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + SyntheticPointerActionParams params1 = SyntheticPointerActionParams(
|
| + SyntheticGestureParams::TOUCH_INPUT,
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + params0.set_index(0);
|
| + params0.set_position(gfx::PointF(54, 89));
|
| + params1.set_index(1);
|
| + params1.set_position(gfx::PointF(79, 132));
|
| + action_param_list.push_back(params0);
|
| + action_param_list.push_back(params1);
|
| + std::unique_ptr<SyntheticPointerAction> gesture(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + MockSyntheticPointerTouchActionTarget* pointer_touch_target =
|
| + static_cast<MockSyntheticPointerTouchActionTarget*>(target_);
|
| + ASSERT_EQ(pointer_touch_target->touch_length(), 2u);
|
| + EXPECT_EQ(pointer_touch_target->indexes(0), params0.index());
|
| + EXPECT_EQ(pointer_touch_target->positions(0), params0.position());
|
| + EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StatePressed);
|
| + EXPECT_EQ(pointer_touch_target->indexes(1), params1.index());
|
| + EXPECT_EQ(pointer_touch_target->positions(1), params1.position());
|
| + EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StatePressed);
|
| +
|
| + action_param_list.clear();
|
| + params0.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + params1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + params1.set_position(gfx::PointF(183, 239));
|
| + action_param_list.push_back(params0);
|
| + action_param_list.push_back(params1);
|
| + gesture.reset(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + ASSERT_EQ(pointer_touch_target->touch_length(), 2u);
|
| + EXPECT_EQ(pointer_touch_target->indexes(0), params0.index());
|
| + EXPECT_EQ(pointer_touch_target->states(0), WebTouchPoint::StateReleased);
|
| + EXPECT_EQ(pointer_touch_target->indexes(1), params1.index());
|
| + EXPECT_EQ(pointer_touch_target->positions(1), params1.position());
|
| + EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateMoved);
|
| +
|
| + action_param_list.clear();
|
| + params1.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + action_param_list.push_back(params1);
|
| + gesture.reset(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + ASSERT_EQ(pointer_touch_target->touch_length(), 2u);
|
| + EXPECT_EQ(pointer_touch_target->indexes(1), params1.index());
|
| + EXPECT_EQ(pointer_touch_target->states(1), WebTouchPoint::StateReleased);
|
| +}
|
| +
|
| +TEST_F(SyntheticGestureControllerTest, PointerMouseAction) {
|
| + CreateControllerAndTarget<MockSyntheticPointerMouseActionTarget>();
|
| + std::unique_ptr<SyntheticPointer> synthetic_pointer =
|
| + SyntheticPointer::Create(SyntheticGestureParams::MOUSE_INPUT);
|
| + SyntheticPointerAction::IndexMap index_map;
|
| + std::fill(index_map.begin(), index_map.end(), -1);
|
| + std::vector<SyntheticPointerActionParams> action_param_list;
|
| +
|
| + SyntheticPointerActionParams params = SyntheticPointerActionParams(
|
| + SyntheticGestureParams::MOUSE_INPUT,
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + params.set_index(0);
|
| + params.set_position(gfx::PointF(54, 89));
|
| + action_param_list.push_back(params);
|
| + std::unique_ptr<SyntheticPointerAction> gesture(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + MockSyntheticPointerMouseActionTarget* pointer_mouse_target =
|
| + static_cast<MockSyntheticPointerMouseActionTarget*>(target_);
|
| + 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);
|
| +
|
| + action_param_list.clear();
|
| + params.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::PRESS);
|
| + params.set_position(gfx::PointF(183, 239));
|
| + action_param_list.push_back(params);
|
| + gesture.reset(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseDown);
|
| + EXPECT_EQ(pointer_mouse_target->position(), params.position());
|
| + EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
|
| + EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
|
| +
|
| + action_param_list.clear();
|
| + params.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::MOVE);
|
| + params.set_position(gfx::PointF(254, 279));
|
| + action_param_list.push_back(params);
|
| + gesture.reset(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseMove);
|
| + EXPECT_EQ(pointer_mouse_target->position(), params.position());
|
| + EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
|
| + EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
|
| +
|
| + action_param_list.clear();
|
| + params.set_pointer_action_type(
|
| + SyntheticPointerActionParams::PointerActionType::RELEASE);
|
| + action_param_list.push_back(params);
|
| + gesture.reset(new SyntheticPointerAction(
|
| + action_param_list, synthetic_pointer.get(), &index_map));
|
| + QueueSyntheticGesture(std::move(gesture));
|
| + FlushInputUntilComplete();
|
| +
|
| + EXPECT_EQ(pointer_mouse_target->type(), WebInputEvent::MouseUp);
|
| + EXPECT_EQ(pointer_mouse_target->clickCount(), 1);
|
| + EXPECT_EQ(pointer_mouse_target->button(), WebMouseEvent::Button::Left);
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace content
|
|
|