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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 461 } |
462 | 462 |
463 void SimulateGestureScrollSequence(WebContents* web_contents, | 463 void SimulateGestureScrollSequence(WebContents* web_contents, |
464 const gfx::Point& point, | 464 const gfx::Point& point, |
465 const gfx::Vector2dF& delta) { | 465 const gfx::Vector2dF& delta) { |
466 RenderWidgetHostImpl* widget_host = | 466 RenderWidgetHostImpl* widget_host = |
467 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 467 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
468 | 468 |
469 blink::WebGestureEvent scroll_begin; | 469 blink::WebGestureEvent scroll_begin; |
470 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin; | 470 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin; |
| 471 scroll_begin.sourceDevice = blink::WebGestureDeviceTouchpad; |
471 scroll_begin.x = point.x(); | 472 scroll_begin.x = point.x(); |
472 scroll_begin.y = point.y(); | 473 scroll_begin.y = point.y(); |
473 widget_host->ForwardGestureEvent(scroll_begin); | 474 widget_host->ForwardGestureEvent(scroll_begin); |
474 | 475 |
475 blink::WebGestureEvent scroll_update; | 476 blink::WebGestureEvent scroll_update; |
476 scroll_update.type = blink::WebGestureEvent::GestureScrollUpdate; | 477 scroll_update.type = blink::WebGestureEvent::GestureScrollUpdate; |
| 478 scroll_update.sourceDevice = blink::WebGestureDeviceTouchpad; |
477 scroll_update.x = point.x(); | 479 scroll_update.x = point.x(); |
478 scroll_update.y = point.y(); | 480 scroll_update.y = point.y(); |
479 scroll_update.data.scrollUpdate.deltaX = delta.x(); | 481 scroll_update.data.scrollUpdate.deltaX = delta.x(); |
480 scroll_update.data.scrollUpdate.deltaY = delta.y(); | 482 scroll_update.data.scrollUpdate.deltaY = delta.y(); |
481 scroll_update.data.scrollUpdate.velocityX = 0; | 483 scroll_update.data.scrollUpdate.velocityX = 0; |
482 scroll_update.data.scrollUpdate.velocityY = 0; | 484 scroll_update.data.scrollUpdate.velocityY = 0; |
483 widget_host->ForwardGestureEvent(scroll_update); | 485 widget_host->ForwardGestureEvent(scroll_update); |
484 | 486 |
485 blink::WebGestureEvent scroll_end; | 487 blink::WebGestureEvent scroll_end; |
486 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd; | 488 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd; |
| 489 scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad; |
487 scroll_end.x = point.x() + delta.x(); | 490 scroll_end.x = point.x() + delta.x(); |
488 scroll_end.y = point.y() + delta.y(); | 491 scroll_end.y = point.y() + delta.y(); |
489 widget_host->ForwardGestureEvent(scroll_end); | 492 widget_host->ForwardGestureEvent(scroll_end); |
490 } | 493 } |
491 | 494 |
492 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { | 495 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { |
493 blink::WebGestureEvent tap; | 496 blink::WebGestureEvent tap; |
494 tap.type = blink::WebGestureEvent::GestureTap; | 497 tap.type = blink::WebGestureEvent::GestureTap; |
| 498 tap.sourceDevice = blink::WebGestureDeviceTouchpad; |
495 tap.x = point.x(); | 499 tap.x = point.x(); |
496 tap.y = point.y(); | 500 tap.y = point.y(); |
497 tap.modifiers = blink::WebInputEvent::ControlKey; | 501 tap.modifiers = blink::WebInputEvent::ControlKey; |
498 RenderWidgetHostImpl* widget_host = | 502 RenderWidgetHostImpl* widget_host = |
499 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 503 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
500 widget_host->ForwardGestureEvent(tap); | 504 widget_host->ForwardGestureEvent(tap); |
501 } | 505 } |
502 | 506 |
503 void SimulateTapWithModifiersAt(WebContents* web_contents, | 507 void SimulateTapWithModifiersAt(WebContents* web_contents, |
504 unsigned modifiers, | 508 unsigned modifiers, |
505 const gfx::Point& point) { | 509 const gfx::Point& point) { |
506 blink::WebGestureEvent tap; | 510 blink::WebGestureEvent tap; |
507 tap.type = blink::WebGestureEvent::GestureTap; | 511 tap.type = blink::WebGestureEvent::GestureTap; |
| 512 tap.sourceDevice = blink::WebGestureDeviceTouchpad; |
508 tap.x = point.x(); | 513 tap.x = point.x(); |
509 tap.y = point.y(); | 514 tap.y = point.y(); |
510 tap.modifiers = modifiers; | 515 tap.modifiers = modifiers; |
511 RenderWidgetHostImpl* widget_host = | 516 RenderWidgetHostImpl* widget_host = |
512 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | 517 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
513 widget_host->ForwardGestureEvent(tap); | 518 widget_host->ForwardGestureEvent(tap); |
514 } | 519 } |
515 | 520 |
516 void SimulateTouchPressAt(WebContents* web_contents, const gfx::Point& point) { | 521 void SimulateTouchPressAt(WebContents* web_contents, const gfx::Point& point) { |
517 SyntheticWebTouchEvent touch; | 522 SyntheticWebTouchEvent touch; |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 void FrameWatcher::WaitFrames(int frames_to_wait) { | 1087 void FrameWatcher::WaitFrames(int frames_to_wait) { |
1083 if (frames_to_wait <= 0) | 1088 if (frames_to_wait <= 0) |
1084 return; | 1089 return; |
1085 base::RunLoop run_loop; | 1090 base::RunLoop run_loop; |
1086 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); | 1091 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); |
1087 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); | 1092 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); |
1088 run_loop.Run(); | 1093 run_loop.Run(); |
1089 } | 1094 } |
1090 | 1095 |
1091 } // namespace content | 1096 } // namespace content |
OLD | NEW |