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