OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 524 } |
525 | 525 |
526 void SimulateMouseClickAt(WebContents* web_contents, | 526 void SimulateMouseClickAt(WebContents* web_contents, |
527 int modifiers, | 527 int modifiers, |
528 blink::WebMouseEvent::Button button, | 528 blink::WebMouseEvent::Button button, |
529 const gfx::Point& point) { | 529 const gfx::Point& point) { |
530 blink::WebMouseEvent mouse_event( | 530 blink::WebMouseEvent mouse_event( |
531 blink::WebInputEvent::MouseDown, modifiers, | 531 blink::WebInputEvent::MouseDown, modifiers, |
532 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 532 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
533 mouse_event.button = button; | 533 mouse_event.button = button; |
534 mouse_event.x = point.x(); | 534 mouse_event.setPositionInWidget(point.x(), point.y()); |
535 mouse_event.y = point.y(); | 535 // Mac needs positionInScreen for events to plugins. |
536 // Mac needs globalX/globalY for events to plugins. | |
537 gfx::Rect offset = web_contents->GetContainerBounds(); | 536 gfx::Rect offset = web_contents->GetContainerBounds(); |
538 mouse_event.globalX = point.x() + offset.x(); | 537 mouse_event.setPositionInScreen(point.x() + offset.x(), |
539 mouse_event.globalY = point.y() + offset.y(); | 538 point.y() + offset.y()); |
540 mouse_event.clickCount = 1; | 539 mouse_event.clickCount = 1; |
541 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 540 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
542 mouse_event); | 541 mouse_event); |
543 mouse_event.setType(blink::WebInputEvent::MouseUp); | 542 mouse_event.setType(blink::WebInputEvent::MouseUp); |
544 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 543 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
545 mouse_event); | 544 mouse_event); |
546 } | 545 } |
547 | 546 |
548 void SimulateMouseEvent(WebContents* web_contents, | 547 void SimulateMouseEvent(WebContents* web_contents, |
549 blink::WebInputEvent::Type type, | 548 blink::WebInputEvent::Type type, |
550 const gfx::Point& point) { | 549 const gfx::Point& point) { |
551 blink::WebMouseEvent mouse_event( | 550 blink::WebMouseEvent mouse_event( |
552 type, blink::WebInputEvent::NoModifiers, | 551 type, blink::WebInputEvent::NoModifiers, |
553 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 552 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
554 mouse_event.x = point.x(); | 553 mouse_event.setPositionInWidget(point.x(), point.y()); |
555 mouse_event.y = point.y(); | |
556 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 554 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
557 mouse_event); | 555 mouse_event); |
558 } | 556 } |
559 | 557 |
560 void SimulateMouseWheelEvent(WebContents* web_contents, | 558 void SimulateMouseWheelEvent(WebContents* web_contents, |
561 const gfx::Point& point, | 559 const gfx::Point& point, |
562 const gfx::Vector2d& delta) { | 560 const gfx::Vector2d& delta) { |
563 blink::WebMouseWheelEvent wheel_event( | 561 blink::WebMouseWheelEvent wheel_event( |
564 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, | 562 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, |
565 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 563 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
566 | 564 |
567 wheel_event.x = point.x(); | 565 wheel_event.setPositionInWidget(point.x(), point.y()); |
568 wheel_event.y = point.y(); | |
569 wheel_event.deltaX = delta.x(); | 566 wheel_event.deltaX = delta.x(); |
570 wheel_event.deltaY = delta.y(); | 567 wheel_event.deltaY = delta.y(); |
571 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( | 568 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( |
572 web_contents->GetRenderViewHost()->GetWidget()); | 569 web_contents->GetRenderViewHost()->GetWidget()); |
573 widget_host->ForwardWheelEvent(wheel_event); | 570 widget_host->ForwardWheelEvent(wheel_event); |
574 } | 571 } |
575 | 572 |
576 void SimulateGestureScrollSequence(WebContents* web_contents, | 573 void SimulateGestureScrollSequence(WebContents* web_contents, |
577 const gfx::Point& point, | 574 const gfx::Point& point, |
578 const gfx::Vector2dF& delta) { | 575 const gfx::Vector2dF& delta) { |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 bool user_gesture, | 1871 bool user_gesture, |
1875 bool last_unlocked_by_target, | 1872 bool last_unlocked_by_target, |
1876 bool privileged) { | 1873 bool privileged) { |
1877 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 1874 IPC::IpcSecurityTestUtil::PwnMessageReceived( |
1878 process->GetChannel(), | 1875 process->GetChannel(), |
1879 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, | 1876 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, |
1880 privileged)); | 1877 privileged)); |
1881 } | 1878 } |
1882 | 1879 |
1883 } // namespace content | 1880 } // namespace content |
OLD | NEW |