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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 void SimulateMouseEvent(WebContents* web_contents, | 403 void SimulateMouseEvent(WebContents* web_contents, |
404 blink::WebInputEvent::Type type, | 404 blink::WebInputEvent::Type type, |
405 const gfx::Point& point) { | 405 const gfx::Point& point) { |
406 blink::WebMouseEvent mouse_event; | 406 blink::WebMouseEvent mouse_event; |
407 mouse_event.type = type; | 407 mouse_event.type = type; |
408 mouse_event.x = point.x(); | 408 mouse_event.x = point.x(); |
409 mouse_event.y = point.y(); | 409 mouse_event.y = point.y(); |
410 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 410 web_contents->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
411 } | 411 } |
412 | 412 |
| 413 void SimulateMouseWheelEvent(WebContents* web_contents, |
| 414 const gfx::Point& point, |
| 415 const gfx::Vector2d& delta) { |
| 416 blink::WebMouseWheelEvent wheel_event; |
| 417 wheel_event.type = blink::WebInputEvent::MouseWheel; |
| 418 wheel_event.x = point.x(); |
| 419 wheel_event.y = point.y(); |
| 420 wheel_event.deltaX = delta.x(); |
| 421 wheel_event.deltaY = delta.y(); |
| 422 RenderWidgetHostImpl* widget_host = |
| 423 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| 424 widget_host->ForwardWheelEvent(wheel_event); |
| 425 } |
| 426 |
| 427 void SimulateGestureScrollSequence(WebContents* web_contents, |
| 428 const gfx::Point& point, |
| 429 const gfx::Vector2dF& delta) { |
| 430 RenderWidgetHostImpl* widget_host = |
| 431 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| 432 |
| 433 blink::WebGestureEvent scroll_begin; |
| 434 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin; |
| 435 scroll_begin.x = point.x(); |
| 436 scroll_begin.y = point.y(); |
| 437 widget_host->ForwardGestureEvent(scroll_begin); |
| 438 |
| 439 blink::WebGestureEvent scroll_update; |
| 440 scroll_update.type = blink::WebGestureEvent::GestureScrollUpdate; |
| 441 scroll_update.x = point.x(); |
| 442 scroll_update.y = point.y(); |
| 443 scroll_update.data.scrollUpdate.deltaX = delta.x(); |
| 444 scroll_update.data.scrollUpdate.deltaY = delta.y(); |
| 445 scroll_update.data.scrollUpdate.velocityX = 0; |
| 446 scroll_update.data.scrollUpdate.velocityY = 0; |
| 447 widget_host->ForwardGestureEvent(scroll_update); |
| 448 |
| 449 blink::WebGestureEvent scroll_end; |
| 450 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd; |
| 451 scroll_end.x = point.x() + delta.x(); |
| 452 scroll_end.y = point.y() + delta.y(); |
| 453 widget_host->ForwardGestureEvent(scroll_end); |
| 454 } |
| 455 |
413 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { | 456 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { |
414 blink::WebGestureEvent tap; | 457 blink::WebGestureEvent tap; |
415 tap.type = blink::WebGestureEvent::GestureTap; | 458 tap.type = blink::WebGestureEvent::GestureTap; |
416 tap.x = point.x(); | 459 tap.x = point.x(); |
417 tap.y = point.y(); | 460 tap.y = point.y(); |
418 tap.modifiers = blink::WebInputEvent::ControlKey; | 461 tap.modifiers = blink::WebInputEvent::ControlKey; |
419 RenderWidgetHostImpl* widget_host = | 462 RenderWidgetHostImpl* widget_host = |
420 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 463 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
421 widget_host->ForwardGestureEvent(tap); | 464 widget_host->ForwardGestureEvent(tap); |
422 } | 465 } |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1030 void FrameWatcher::WaitFrames(int frames_to_wait) { |
988 if (frames_to_wait <= 0) | 1031 if (frames_to_wait <= 0) |
989 return; | 1032 return; |
990 base::RunLoop run_loop; | 1033 base::RunLoop run_loop; |
991 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1034 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
992 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1035 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
993 run_loop.Run(); | 1036 run_loop.Run(); |
994 } | 1037 } |
995 | 1038 |
996 } // namespace content | 1039 } // namespace content |
OLD | NEW |