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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.positionInWidget().x, |
| 251 mouse_event.positionInWidget().y); |
251 last_mouse_point_ = start_; | 252 last_mouse_point_ = start_; |
252 started_ = true; | 253 started_ = true; |
253 } else { | 254 } else { |
254 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 255 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |
255 ASSERT_NE(mouse_event.type(), WebInputEvent::MouseDown); | 256 ASSERT_NE(mouse_event.type(), WebInputEvent::MouseDown); |
256 | 257 |
257 gfx::PointF mouse_point(mouse_event.x, mouse_event.y); | 258 gfx::PointF mouse_point(mouse_event.positionInWidget()); |
258 gfx::Vector2dF delta = mouse_point - last_mouse_point_; | 259 gfx::Vector2dF delta = mouse_point - last_mouse_point_; |
259 total_abs_move_distance_length_ += delta.Length(); | 260 total_abs_move_distance_length_ += delta.Length(); |
260 if (mouse_event.type() == WebInputEvent::MouseUp) | 261 if (mouse_event.type() == WebInputEvent::MouseUp) |
261 start_to_end_distance_ = mouse_point - start_; | 262 start_to_end_distance_ = mouse_point - start_; |
262 last_mouse_point_ = mouse_point; | 263 last_mouse_point_ = mouse_point; |
263 } | 264 } |
264 } | 265 } |
265 | 266 |
266 private: | 267 private: |
267 bool started_; | 268 bool started_; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 484 |
484 void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 485 void DispatchInputEventToPlatform(const WebInputEvent& event) override { |
485 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); | 486 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); |
486 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 487 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |
487 | 488 |
488 switch (state_) { | 489 switch (state_) { |
489 case NOT_STARTED: | 490 case NOT_STARTED: |
490 EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseDown); | 491 EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseDown); |
491 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 492 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |
492 EXPECT_EQ(mouse_event.clickCount, 1); | 493 EXPECT_EQ(mouse_event.clickCount, 1); |
493 position_ = gfx::PointF(mouse_event.x, mouse_event.y); | 494 position_ = gfx::PointF(mouse_event.positionInWidget()); |
494 start_time_ = base::TimeDelta::FromMilliseconds( | 495 start_time_ = base::TimeDelta::FromMilliseconds( |
495 static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); | 496 static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); |
496 state_ = STARTED; | 497 state_ = STARTED; |
497 break; | 498 break; |
498 case STARTED: | 499 case STARTED: |
499 EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseUp); | 500 EXPECT_EQ(mouse_event.type(), WebInputEvent::MouseUp); |
500 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); | 501 EXPECT_EQ(mouse_event.button, WebMouseEvent::Button::Left); |
501 EXPECT_EQ(mouse_event.clickCount, 1); | 502 EXPECT_EQ(mouse_event.clickCount, 1); |
502 EXPECT_EQ(position_, gfx::PointF(mouse_event.x, mouse_event.y)); | 503 EXPECT_EQ(position_, gfx::PointF(mouse_event.positionInWidget())); |
503 stop_time_ = base::TimeDelta::FromMilliseconds( | 504 stop_time_ = base::TimeDelta::FromMilliseconds( |
504 static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); | 505 static_cast<int64_t>(mouse_event.timeStampSeconds() * 1000)); |
505 state_ = FINISHED; | 506 state_ = FINISHED; |
506 break; | 507 break; |
507 case FINISHED: | 508 case FINISHED: |
508 EXPECT_FALSE(true); | 509 EXPECT_FALSE(true); |
509 break; | 510 break; |
510 } | 511 } |
511 } | 512 } |
512 }; | 513 }; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 class MockSyntheticPointerMouseActionTarget | 603 class MockSyntheticPointerMouseActionTarget |
603 : public MockSyntheticPointerActionTarget { | 604 : public MockSyntheticPointerActionTarget { |
604 public: | 605 public: |
605 MockSyntheticPointerMouseActionTarget() {} | 606 MockSyntheticPointerMouseActionTarget() {} |
606 ~MockSyntheticPointerMouseActionTarget() override {} | 607 ~MockSyntheticPointerMouseActionTarget() override {} |
607 | 608 |
608 void DispatchInputEventToPlatform(const WebInputEvent& event) override { | 609 void DispatchInputEventToPlatform(const WebInputEvent& event) override { |
609 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); | 610 ASSERT_TRUE(WebInputEvent::isMouseEventType(event.type())); |
610 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); | 611 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); |
611 type_ = mouse_event.type(); | 612 type_ = mouse_event.type(); |
612 position_ = gfx::PointF(mouse_event.x, mouse_event.y); | 613 position_ = gfx::PointF(mouse_event.positionInWidget()); |
613 clickCount_ = mouse_event.clickCount; | 614 clickCount_ = mouse_event.clickCount; |
614 button_ = mouse_event.button; | 615 button_ = mouse_event.button; |
615 num_actions_dispatched_++; | 616 num_actions_dispatched_++; |
616 } | 617 } |
617 | 618 |
618 testing::AssertionResult SyntheticMouseActionDispatchedCorrectly( | 619 testing::AssertionResult SyntheticMouseActionDispatchedCorrectly( |
619 const SyntheticPointerActionParams& param, | 620 const SyntheticPointerActionParams& param, |
620 int click_count) { | 621 int click_count) { |
621 if (type_ != ToWebMouseEventType(param.pointer_action_type())) { | 622 if (type_ != ToWebMouseEventType(param.pointer_action_type())) { |
622 return testing::AssertionFailure() | 623 return testing::AssertionFailure() |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 EXPECT_EQ(4, num_success_); | 1761 EXPECT_EQ(4, num_success_); |
1761 EXPECT_EQ(0, num_failure_); | 1762 EXPECT_EQ(0, num_failure_); |
1762 EXPECT_EQ(pointer_mouse_target->num_actions_dispatched(), 4); | 1763 EXPECT_EQ(pointer_mouse_target->num_actions_dispatched(), 4); |
1763 EXPECT_TRUE( | 1764 EXPECT_TRUE( |
1764 pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1)); | 1765 pointer_mouse_target->SyntheticMouseActionDispatchedCorrectly(param, 1)); |
1765 } | 1766 } |
1766 | 1767 |
1767 } // namespace | 1768 } // namespace |
1768 | 1769 |
1769 } // namespace content | 1770 } // namespace content |
OLD | NEW |