| OLD | NEW | 
|     1 // Copyright 2013 The Chromium Authors. All rights reserved. |     1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
|     2 // Use of this source code is governed by a BSD-style license that can be |     2 // Use of this source code is governed by a BSD-style license that can be | 
|     3 // found in the LICENSE file. |     3 // found in the LICENSE file. | 
|     4  |     4  | 
|     5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |     5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 
|     6  |     6  | 
|     7 #include <stddef.h> |     7 #include <stddef.h> | 
|     8 #include <stdint.h> |     8 #include <stdint.h> | 
|     9  |     9  | 
|    10 #include <memory> |    10 #include <memory> | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   181   gfx::Vector2dF start_to_end_distance_; |   181   gfx::Vector2dF start_to_end_distance_; | 
|   182   float total_abs_move_distance_length_; |   182   float total_abs_move_distance_length_; | 
|   183 }; |   183 }; | 
|   184  |   184  | 
|   185 class MockScrollMouseTarget : public MockMoveGestureTarget { |   185 class MockScrollMouseTarget : public MockMoveGestureTarget { | 
|   186  public: |   186  public: | 
|   187   MockScrollMouseTarget() {} |   187   MockScrollMouseTarget() {} | 
|   188   ~MockScrollMouseTarget() override {} |   188   ~MockScrollMouseTarget() override {} | 
|   189  |   189  | 
|   190   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   190   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   191     ASSERT_EQ(event.type, WebInputEvent::MouseWheel); |   191     ASSERT_EQ(event.type(), WebInputEvent::MouseWheel); | 
|   192     const WebMouseWheelEvent& mouse_wheel_event = |   192     const WebMouseWheelEvent& mouse_wheel_event = | 
|   193         static_cast<const WebMouseWheelEvent&>(event); |   193         static_cast<const WebMouseWheelEvent&>(event); | 
|   194     gfx::Vector2dF delta(mouse_wheel_event.deltaX, mouse_wheel_event.deltaY); |   194     gfx::Vector2dF delta(mouse_wheel_event.deltaX, mouse_wheel_event.deltaY); | 
|   195     start_to_end_distance_ += delta; |   195     start_to_end_distance_ += delta; | 
|   196     total_abs_move_distance_length_ += delta.Length(); |   196     total_abs_move_distance_length_ += delta.Length(); | 
|   197   } |   197   } | 
|   198 }; |   198 }; | 
|   199  |   199  | 
|   200 class MockMoveTouchTarget : public MockMoveGestureTarget { |   200 class MockMoveTouchTarget : public MockMoveGestureTarget { | 
|   201  public: |   201  public: | 
|   202   MockMoveTouchTarget() : started_(false) {} |   202   MockMoveTouchTarget() : started_(false) {} | 
|   203   ~MockMoveTouchTarget() override {} |   203   ~MockMoveTouchTarget() override {} | 
|   204  |   204  | 
|   205   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   205   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   206     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); |   206     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type())); | 
|   207     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); |   207     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); | 
|   208     ASSERT_EQ(touch_event.touchesLength, 1U); |   208     ASSERT_EQ(touch_event.touchesLength, 1U); | 
|   209  |   209  | 
|   210     if (!started_) { |   210     if (!started_) { | 
|   211       ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); |   211       ASSERT_EQ(touch_event.type(), WebInputEvent::TouchStart); | 
|   212       start_.SetPoint(touch_event.touches[0].position.x, |   212       start_.SetPoint(touch_event.touches[0].position.x, | 
|   213                       touch_event.touches[0].position.y); |   213                       touch_event.touches[0].position.y); | 
|   214       last_touch_point_ = gfx::PointF(start_); |   214       last_touch_point_ = gfx::PointF(start_); | 
|   215       started_ = true; |   215       started_ = true; | 
|   216     } else { |   216     } else { | 
|   217       ASSERT_NE(touch_event.type, WebInputEvent::TouchStart); |   217       ASSERT_NE(touch_event.type(), WebInputEvent::TouchStart); | 
|   218       ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel); |   218       ASSERT_NE(touch_event.type(), WebInputEvent::TouchCancel); | 
|   219  |   219  | 
|   220       gfx::PointF touch_point(touch_event.touches[0].position.x, |   220       gfx::PointF touch_point(touch_event.touches[0].position.x, | 
|   221                               touch_event.touches[0].position.y); |   221                               touch_event.touches[0].position.y); | 
|   222       gfx::Vector2dF delta = touch_point - last_touch_point_; |   222       gfx::Vector2dF delta = touch_point - last_touch_point_; | 
|   223       total_abs_move_distance_length_ += delta.Length(); |   223       total_abs_move_distance_length_ += delta.Length(); | 
|   224  |   224  | 
|   225       if (touch_event.type == WebInputEvent::TouchEnd) |   225       if (touch_event.type() == WebInputEvent::TouchEnd) | 
|   226         start_to_end_distance_ = touch_point - gfx::PointF(start_); |   226         start_to_end_distance_ = touch_point - gfx::PointF(start_); | 
|   227  |   227  | 
|   228       last_touch_point_ = touch_point; |   228       last_touch_point_ = touch_point; | 
|   229     } |   229     } | 
|   230   } |   230   } | 
|   231  |   231  | 
|   232  protected: |   232  protected: | 
|   233   gfx::Point start_; |   233   gfx::Point start_; | 
|   234   gfx::PointF last_touch_point_; |   234   gfx::PointF last_touch_point_; | 
|   235   bool started_; |   235   bool started_; | 
|   236 }; |   236 }; | 
|   237  |   237  | 
|   238 class MockDragMouseTarget : public MockMoveGestureTarget { |   238 class MockDragMouseTarget : public MockMoveGestureTarget { | 
|   239  public: |   239  public: | 
|   240   MockDragMouseTarget() : started_(false) {} |   240   MockDragMouseTarget() : started_(false) {} | 
|   241   ~MockDragMouseTarget() override {} |   241   ~MockDragMouseTarget() override {} | 
|   242  |   242  | 
|   243   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   243   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   244     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); |   244     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); | 
|   245     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |   245     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 
|   246     if (!started_) { |   246     if (!started_) { | 
|   247       EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |   247       EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 
|   248       EXPECT_EQ(mouse_event.clickCount, 1); |   248       EXPECT_EQ(mouse_event.clickCount, 1); | 
|   249       EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown); |   249       EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseDown); | 
|   250       start_.SetPoint(mouse_event.x, mouse_event.y); |   250       start_.SetPoint(mouse_event.x, mouse_event.y); | 
|   251       last_mouse_point_ = start_; |   251       last_mouse_point_ = start_; | 
|   252       started_ = true; |   252       started_ = true; | 
|   253     } else { |   253     } else { | 
|   254       EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |   254       EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 
|   255       ASSERT_NE(mouse_event.type, WebInputEvent::MouseDown); |   255       ASSERT_NE(mouse_event.type(), WebInputEvent::MouseDown); | 
|   256  |   256  | 
|   257       gfx::PointF mouse_point(mouse_event.x, mouse_event.y); |   257       gfx::PointF mouse_point(mouse_event.x, mouse_event.y); | 
|   258       gfx::Vector2dF delta = mouse_point - last_mouse_point_; |   258       gfx::Vector2dF delta = mouse_point - last_mouse_point_; | 
|   259       total_abs_move_distance_length_ += delta.Length(); |   259       total_abs_move_distance_length_ += delta.Length(); | 
|   260       if (mouse_event.type == WebInputEvent::MouseUp) |   260       if (mouse_event.type() == WebInputEvent::MouseUp) | 
|   261         start_to_end_distance_ = mouse_point - start_; |   261         start_to_end_distance_ = mouse_point - start_; | 
|   262       last_mouse_point_ = mouse_point; |   262       last_mouse_point_ = mouse_point; | 
|   263     } |   263     } | 
|   264   } |   264   } | 
|   265  |   265  | 
|   266  private: |   266  private: | 
|   267   bool started_; |   267   bool started_; | 
|   268   gfx::PointF start_, last_mouse_point_; |   268   gfx::PointF start_, last_mouse_point_; | 
|   269 }; |   269 }; | 
|   270  |   270  | 
|   271 class MockSyntheticTouchscreenPinchTouchTarget |   271 class MockSyntheticTouchscreenPinchTouchTarget | 
|   272     : public MockSyntheticGestureTarget { |   272     : public MockSyntheticGestureTarget { | 
|   273  public: |   273  public: | 
|   274   enum ZoomDirection { |   274   enum ZoomDirection { | 
|   275     ZOOM_DIRECTION_UNKNOWN, |   275     ZOOM_DIRECTION_UNKNOWN, | 
|   276     ZOOM_IN, |   276     ZOOM_IN, | 
|   277     ZOOM_OUT |   277     ZOOM_OUT | 
|   278   }; |   278   }; | 
|   279  |   279  | 
|   280   MockSyntheticTouchscreenPinchTouchTarget() |   280   MockSyntheticTouchscreenPinchTouchTarget() | 
|   281       : initial_pointer_distance_(0), |   281       : initial_pointer_distance_(0), | 
|   282         last_pointer_distance_(0), |   282         last_pointer_distance_(0), | 
|   283         zoom_direction_(ZOOM_DIRECTION_UNKNOWN), |   283         zoom_direction_(ZOOM_DIRECTION_UNKNOWN), | 
|   284         started_(false) {} |   284         started_(false) {} | 
|   285   ~MockSyntheticTouchscreenPinchTouchTarget() override {} |   285   ~MockSyntheticTouchscreenPinchTouchTarget() override {} | 
|   286  |   286  | 
|   287   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   287   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   288     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); |   288     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type())); | 
|   289     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); |   289     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); | 
|   290     ASSERT_EQ(touch_event.touchesLength, 2U); |   290     ASSERT_EQ(touch_event.touchesLength, 2U); | 
|   291  |   291  | 
|   292     if (!started_) { |   292     if (!started_) { | 
|   293       ASSERT_EQ(touch_event.type, WebInputEvent::TouchStart); |   293       ASSERT_EQ(touch_event.type(), WebInputEvent::TouchStart); | 
|   294  |   294  | 
|   295       start_0_ = gfx::PointF(touch_event.touches[0].position); |   295       start_0_ = gfx::PointF(touch_event.touches[0].position); | 
|   296       start_1_ = gfx::PointF(touch_event.touches[1].position); |   296       start_1_ = gfx::PointF(touch_event.touches[1].position); | 
|   297       last_pointer_distance_ = (start_0_ - start_1_).Length(); |   297       last_pointer_distance_ = (start_0_ - start_1_).Length(); | 
|   298       initial_pointer_distance_ = last_pointer_distance_; |   298       initial_pointer_distance_ = last_pointer_distance_; | 
|   299       EXPECT_GE(initial_pointer_distance_, GetMinScalingSpanInDips()); |   299       EXPECT_GE(initial_pointer_distance_, GetMinScalingSpanInDips()); | 
|   300  |   300  | 
|   301       started_ = true; |   301       started_ = true; | 
|   302     } else { |   302     } else { | 
|   303       ASSERT_NE(touch_event.type, WebInputEvent::TouchStart); |   303       ASSERT_NE(touch_event.type(), WebInputEvent::TouchStart); | 
|   304       ASSERT_NE(touch_event.type, WebInputEvent::TouchCancel); |   304       ASSERT_NE(touch_event.type(), WebInputEvent::TouchCancel); | 
|   305  |   305  | 
|   306       gfx::PointF current_0 = gfx::PointF(touch_event.touches[0].position); |   306       gfx::PointF current_0 = gfx::PointF(touch_event.touches[0].position); | 
|   307       gfx::PointF current_1 = gfx::PointF(touch_event.touches[1].position); |   307       gfx::PointF current_1 = gfx::PointF(touch_event.touches[1].position); | 
|   308  |   308  | 
|   309       float pointer_distance = (current_0 - current_1).Length(); |   309       float pointer_distance = (current_0 - current_1).Length(); | 
|   310  |   310  | 
|   311       if (last_pointer_distance_ != pointer_distance) { |   311       if (last_pointer_distance_ != pointer_distance) { | 
|   312         if (zoom_direction_ == ZOOM_DIRECTION_UNKNOWN) |   312         if (zoom_direction_ == ZOOM_DIRECTION_UNKNOWN) | 
|   313           zoom_direction_ = |   313           zoom_direction_ = | 
|   314               ComputeZoomDirection(last_pointer_distance_, pointer_distance); |   314               ComputeZoomDirection(last_pointer_distance_, pointer_distance); | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   367   enum ZoomDirection { ZOOM_DIRECTION_UNKNOWN, ZOOM_IN, ZOOM_OUT }; |   367   enum ZoomDirection { ZOOM_DIRECTION_UNKNOWN, ZOOM_IN, ZOOM_OUT }; | 
|   368  |   368  | 
|   369   MockSyntheticTouchpadPinchTouchTarget() |   369   MockSyntheticTouchpadPinchTouchTarget() | 
|   370       : zoom_direction_(ZOOM_DIRECTION_UNKNOWN), |   370       : zoom_direction_(ZOOM_DIRECTION_UNKNOWN), | 
|   371         started_(false), |   371         started_(false), | 
|   372         ended_(false), |   372         ended_(false), | 
|   373         scale_factor_(1.0f) {} |   373         scale_factor_(1.0f) {} | 
|   374   ~MockSyntheticTouchpadPinchTouchTarget() override {} |   374   ~MockSyntheticTouchpadPinchTouchTarget() override {} | 
|   375  |   375  | 
|   376   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   376   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   377     EXPECT_TRUE(WebInputEvent::isGestureEventType(event.type)); |   377     EXPECT_TRUE(WebInputEvent::isGestureEventType(event.type())); | 
|   378     const blink::WebGestureEvent& gesture_event = |   378     const blink::WebGestureEvent& gesture_event = | 
|   379         static_cast<const blink::WebGestureEvent&>(event); |   379         static_cast<const blink::WebGestureEvent&>(event); | 
|   380  |   380  | 
|   381     if (gesture_event.type == WebInputEvent::GesturePinchBegin) { |   381     if (gesture_event.type() == WebInputEvent::GesturePinchBegin) { | 
|   382       EXPECT_FALSE(started_); |   382       EXPECT_FALSE(started_); | 
|   383       EXPECT_FALSE(ended_); |   383       EXPECT_FALSE(ended_); | 
|   384       started_ = true; |   384       started_ = true; | 
|   385     } else if (gesture_event.type == WebInputEvent::GesturePinchEnd) { |   385     } else if (gesture_event.type() == WebInputEvent::GesturePinchEnd) { | 
|   386       EXPECT_TRUE(started_); |   386       EXPECT_TRUE(started_); | 
|   387       EXPECT_FALSE(ended_); |   387       EXPECT_FALSE(ended_); | 
|   388       ended_ = true; |   388       ended_ = true; | 
|   389     } else { |   389     } else { | 
|   390       EXPECT_EQ(WebInputEvent::GesturePinchUpdate, gesture_event.type); |   390       EXPECT_EQ(WebInputEvent::GesturePinchUpdate, gesture_event.type()); | 
|   391       EXPECT_TRUE(started_); |   391       EXPECT_TRUE(started_); | 
|   392       EXPECT_FALSE(ended_); |   392       EXPECT_FALSE(ended_); | 
|   393       const float scale = gesture_event.data.pinchUpdate.scale; |   393       const float scale = gesture_event.data.pinchUpdate.scale; | 
|   394       if (scale != 1.0f) { |   394       if (scale != 1.0f) { | 
|   395         if (zoom_direction_ == ZOOM_DIRECTION_UNKNOWN) { |   395         if (zoom_direction_ == ZOOM_DIRECTION_UNKNOWN) { | 
|   396           zoom_direction_ = scale > 1.0f ? ZOOM_IN : ZOOM_OUT; |   396           zoom_direction_ = scale > 1.0f ? ZOOM_IN : ZOOM_OUT; | 
|   397         } else if (zoom_direction_ == ZOOM_IN) { |   397         } else if (zoom_direction_ == ZOOM_IN) { | 
|   398           EXPECT_GT(scale, 1.0f); |   398           EXPECT_GT(scale, 1.0f); | 
|   399         } else { |   399         } else { | 
|   400           EXPECT_EQ(ZOOM_OUT, zoom_direction_); |   400           EXPECT_EQ(ZOOM_OUT, zoom_direction_); | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   443   base::TimeDelta stop_time_; |   443   base::TimeDelta stop_time_; | 
|   444   GestureState state_; |   444   GestureState state_; | 
|   445 }; |   445 }; | 
|   446  |   446  | 
|   447 class MockSyntheticTapTouchTarget : public MockSyntheticTapGestureTarget { |   447 class MockSyntheticTapTouchTarget : public MockSyntheticTapGestureTarget { | 
|   448  public: |   448  public: | 
|   449   MockSyntheticTapTouchTarget() {} |   449   MockSyntheticTapTouchTarget() {} | 
|   450   ~MockSyntheticTapTouchTarget() override {} |   450   ~MockSyntheticTapTouchTarget() override {} | 
|   451  |   451  | 
|   452   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   452   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   453     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type)); |   453     ASSERT_TRUE(WebInputEvent::isTouchEventType(event.type())); | 
|   454     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); |   454     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); | 
|   455     ASSERT_EQ(touch_event.touchesLength, 1U); |   455     ASSERT_EQ(touch_event.touchesLength, 1U); | 
|   456  |   456  | 
|   457     switch (state_) { |   457     switch (state_) { | 
|   458       case NOT_STARTED: |   458       case NOT_STARTED: | 
|   459         EXPECT_EQ(touch_event.type, WebInputEvent::TouchStart); |   459         EXPECT_EQ(touch_event.type(), WebInputEvent::TouchStart); | 
|   460         position_ = gfx::PointF(touch_event.touches[0].position); |   460         position_ = gfx::PointF(touch_event.touches[0].position); | 
|   461         start_time_ = base::TimeDelta::FromMilliseconds( |   461         start_time_ = base::TimeDelta::FromMilliseconds( | 
|   462             static_cast<int64_t>(touch_event.timeStampSeconds * 1000)); |   462             static_cast<int64_t>(touch_event.timeStampSeconds() * 1000)); | 
|   463         state_ = STARTED; |   463         state_ = STARTED; | 
|   464         break; |   464         break; | 
|   465       case STARTED: |   465       case STARTED: | 
|   466         EXPECT_EQ(touch_event.type, WebInputEvent::TouchEnd); |   466         EXPECT_EQ(touch_event.type(), WebInputEvent::TouchEnd); | 
|   467         EXPECT_EQ(position_, gfx::PointF(touch_event.touches[0].position)); |   467         EXPECT_EQ(position_, gfx::PointF(touch_event.touches[0].position)); | 
|   468         stop_time_ = base::TimeDelta::FromMilliseconds( |   468         stop_time_ = base::TimeDelta::FromMilliseconds( | 
|   469             static_cast<int64_t>(touch_event.timeStampSeconds * 1000)); |   469             static_cast<int64_t>(touch_event.timeStampSeconds() * 1000)); | 
|   470         state_ = FINISHED; |   470         state_ = FINISHED; | 
|   471         break; |   471         break; | 
|   472       case FINISHED: |   472       case FINISHED: | 
|   473         EXPECT_FALSE(true); |   473         EXPECT_FALSE(true); | 
|   474         break; |   474         break; | 
|   475     } |   475     } | 
|   476   } |   476   } | 
|   477 }; |   477 }; | 
|   478  |   478  | 
|   479 class MockSyntheticTapMouseTarget : public MockSyntheticTapGestureTarget { |   479 class MockSyntheticTapMouseTarget : public MockSyntheticTapGestureTarget { | 
|   480  public: |   480  public: | 
|   481   MockSyntheticTapMouseTarget() {} |   481   MockSyntheticTapMouseTarget() {} | 
|   482   ~MockSyntheticTapMouseTarget() override {} |   482   ~MockSyntheticTapMouseTarget() override {} | 
|   483  |   483  | 
|   484   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   484   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   485     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); |   485     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); | 
|   486     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |   486     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 
|   487  |   487  | 
|   488     switch (state_) { |   488     switch (state_) { | 
|   489       case NOT_STARTED: |   489       case NOT_STARTED: | 
|   490         EXPECT_EQ(mouse_event.type, WebInputEvent::MouseDown); |   490         EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseDown); | 
|   491         EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |   491         EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 
|   492         EXPECT_EQ(mouse_event.clickCount, 1); |   492         EXPECT_EQ(mouse_event.clickCount, 1); | 
|   493         position_ = gfx::PointF(mouse_event.x, mouse_event.y); |   493         position_ = gfx::PointF(mouse_event.x, mouse_event.y); | 
|   494         start_time_ = base::TimeDelta::FromMilliseconds( |   494         start_time_ = base::TimeDelta::FromMilliseconds( | 
|   495             static_cast<int64_t>(mouse_event.timeStampSeconds * 1000)); |   495             static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); | 
|   496         state_ = STARTED; |   496         state_ = STARTED; | 
|   497         break; |   497         break; | 
|   498       case STARTED: |   498       case STARTED: | 
|   499         EXPECT_EQ(mouse_event.type, WebInputEvent::MouseUp); |   499         EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseUp); | 
|   500         EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |   500         EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 
|   501         EXPECT_EQ(mouse_event.clickCount, 1); |   501         EXPECT_EQ(mouse_event.clickCount, 1); | 
|   502         EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y)); |   502         EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y)); | 
|   503         stop_time_ = base::TimeDelta::FromMilliseconds( |   503         stop_time_ = base::TimeDelta::FromMilliseconds( | 
|   504             static_cast<int64_t>(mouse_event.timeStampSeconds * 1000)); |   504             static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); | 
|   505         state_ = FINISHED; |   505         state_ = FINISHED; | 
|   506         break; |   506         break; | 
|   507       case FINISHED: |   507       case FINISHED: | 
|   508         EXPECT_FALSE(true); |   508         EXPECT_FALSE(true); | 
|   509         break; |   509         break; | 
|   510     } |   510     } | 
|   511   } |   511   } | 
|   512 }; |   512 }; | 
|   513  |   513  | 
|   514 class MockSyntheticPointerActionTarget : public MockSyntheticGestureTarget { |   514 class MockSyntheticPointerActionTarget : public MockSyntheticGestureTarget { | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   525   int num_actions_dispatched_; |   525   int num_actions_dispatched_; | 
|   526 }; |   526 }; | 
|   527  |   527  | 
|   528 class MockSyntheticPointerTouchActionTarget |   528 class MockSyntheticPointerTouchActionTarget | 
|   529     : public MockSyntheticPointerActionTarget { |   529     : public MockSyntheticPointerActionTarget { | 
|   530  public: |   530  public: | 
|   531   MockSyntheticPointerTouchActionTarget() {} |   531   MockSyntheticPointerTouchActionTarget() {} | 
|   532   ~MockSyntheticPointerTouchActionTarget() override {} |   532   ~MockSyntheticPointerTouchActionTarget() override {} | 
|   533  |   533  | 
|   534   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   534   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   535     DCHECK(WebInputEvent::isTouchEventType(event.type)); |   535     DCHECK(WebInputEvent::isTouchEventType(event.type())); | 
|   536     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); |   536     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event); | 
|   537     type_ = touch_event.type; |   537     type_ = touch_event.type(); | 
|   538     for (size_t i = 0; i < WebTouchEvent::kTouchesLengthCap; ++i) { |   538     for (size_t i = 0; i < WebTouchEvent::kTouchesLengthCap; ++i) { | 
|   539       indexes_[i] = touch_event.touches[i].id; |   539       indexes_[i] = touch_event.touches[i].id; | 
|   540       positions_[i] = gfx::PointF(touch_event.touches[i].position); |   540       positions_[i] = gfx::PointF(touch_event.touches[i].position); | 
|   541       states_[i] = touch_event.touches[i].state; |   541       states_[i] = touch_event.touches[i].state; | 
|   542     } |   542     } | 
|   543     touch_length_ = touch_event.touchesLength; |   543     touch_length_ = touch_event.touchesLength; | 
|   544     num_actions_dispatched_++; |   544     num_actions_dispatched_++; | 
|   545   } |   545   } | 
|   546  |   546  | 
|   547   testing::AssertionResult SyntheticTouchActionDispatchedCorrectly( |   547   testing::AssertionResult SyntheticTouchActionDispatchedCorrectly( | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   599   WebTouchPoint::State states_[kTouchPointersLength]; |   599   WebTouchPoint::State states_[kTouchPointersLength]; | 
|   600 }; |   600 }; | 
|   601  |   601  | 
|   602 class MockSyntheticPointerMouseActionTarget |   602 class MockSyntheticPointerMouseActionTarget | 
|   603     : public MockSyntheticPointerActionTarget { |   603     : public MockSyntheticPointerActionTarget { | 
|   604  public: |   604  public: | 
|   605   MockSyntheticPointerMouseActionTarget() {} |   605   MockSyntheticPointerMouseActionTarget() {} | 
|   606   ~MockSyntheticPointerMouseActionTarget() override {} |   606   ~MockSyntheticPointerMouseActionTarget() override {} | 
|   607  |   607  | 
|   608   void DispatchInputEventToPlatform(const WebInputEvent& event) override { |   608   void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 
|   609     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type)); |   609     ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); | 
|   610     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |   610     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 
|   611     type_ = mouse_event.type; |   611     type_ = mouse_event.type(); | 
|   612     position_ = gfx::PointF(mouse_event.x, mouse_event.y); |   612     position_ = gfx::PointF(mouse_event.x, mouse_event.y); | 
|   613     clickCount_ = mouse_event.clickCount; |   613     clickCount_ = mouse_event.clickCount; | 
|   614     button_ = mouse_event.button; |   614     button_ = mouse_event.button; | 
|   615     num_actions_dispatched_++; |   615     num_actions_dispatched_++; | 
|   616   } |   616   } | 
|   617  |   617  | 
|   618   testing::AssertionResult SyntheticMouseActionDispatchedCorrectly( |   618   testing::AssertionResult SyntheticMouseActionDispatchedCorrectly( | 
|   619       const SyntheticPointerActionParams& param, |   619       const SyntheticPointerActionParams& param, | 
|   620       int click_count) { |   620       int click_count) { | 
|   621     if (type_ != ToWebMouseEventType(param.pointer_action_type())) { |   621     if (type_ != ToWebMouseEventType(param.pointer_action_type())) { | 
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1759  |  1759  | 
|  1760   EXPECT_EQ(4, num_success_); |  1760   EXPECT_EQ(4, num_success_); | 
|  1761   EXPECT_EQ(0, num_failure_); |  1761   EXPECT_EQ(0, num_failure_); | 
|  1762   EXPECT_EQ(pointer_mouse_target->num_actions_dispatched(), 4); |  1762   EXPECT_EQ(pointer_mouse_target->num_actions_dispatched(), 4); | 
|  1763   EXPECT_TRUE( |  1763   EXPECT_TRUE( | 
|  1764       pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1)); |  1764       pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1)); | 
|  1765 } |  1765 } | 
|  1766  |  1766  | 
|  1767 }  // namespace |  1767 }  // namespace | 
|  1768  |  1768  | 
|  1769 }  // namespace content |  1769 }  // namespace content | 
| OLD | NEW |