Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 1403893003: Plumb gesture source value through Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert more tests (related to CL) to use Touchscreen. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 464 }
465 465
466 void SimulateGestureScrollSequence(WebContents* web_contents, 466 void SimulateGestureScrollSequence(WebContents* web_contents,
467 const gfx::Point& point, 467 const gfx::Point& point,
468 const gfx::Vector2dF& delta) { 468 const gfx::Vector2dF& delta) {
469 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( 469 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
470 web_contents->GetRenderViewHost()->GetWidget()); 470 web_contents->GetRenderViewHost()->GetWidget());
471 471
472 blink::WebGestureEvent scroll_begin; 472 blink::WebGestureEvent scroll_begin;
473 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin; 473 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin;
474 scroll_begin.sourceDevice = blink::WebGestureDeviceTouchpad;
474 scroll_begin.x = point.x(); 475 scroll_begin.x = point.x();
475 scroll_begin.y = point.y(); 476 scroll_begin.y = point.y();
476 widget_host->ForwardGestureEvent(scroll_begin); 477 widget_host->ForwardGestureEvent(scroll_begin);
477 478
478 blink::WebGestureEvent scroll_update; 479 blink::WebGestureEvent scroll_update;
479 scroll_update.type = blink::WebGestureEvent::GestureScrollUpdate; 480 scroll_update.type = blink::WebGestureEvent::GestureScrollUpdate;
481 scroll_update.sourceDevice = blink::WebGestureDeviceTouchpad;
480 scroll_update.x = point.x(); 482 scroll_update.x = point.x();
481 scroll_update.y = point.y(); 483 scroll_update.y = point.y();
482 scroll_update.data.scrollUpdate.deltaX = delta.x(); 484 scroll_update.data.scrollUpdate.deltaX = delta.x();
483 scroll_update.data.scrollUpdate.deltaY = delta.y(); 485 scroll_update.data.scrollUpdate.deltaY = delta.y();
484 scroll_update.data.scrollUpdate.velocityX = 0; 486 scroll_update.data.scrollUpdate.velocityX = 0;
485 scroll_update.data.scrollUpdate.velocityY = 0; 487 scroll_update.data.scrollUpdate.velocityY = 0;
486 widget_host->ForwardGestureEvent(scroll_update); 488 widget_host->ForwardGestureEvent(scroll_update);
487 489
488 blink::WebGestureEvent scroll_end; 490 blink::WebGestureEvent scroll_end;
489 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd; 491 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd;
492 scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad;
490 scroll_end.x = point.x() + delta.x(); 493 scroll_end.x = point.x() + delta.x();
491 scroll_end.y = point.y() + delta.y(); 494 scroll_end.y = point.y() + delta.y();
492 widget_host->ForwardGestureEvent(scroll_end); 495 widget_host->ForwardGestureEvent(scroll_end);
493 } 496 }
494 497
495 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { 498 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) {
496 blink::WebGestureEvent tap; 499 blink::WebGestureEvent tap;
497 tap.type = blink::WebGestureEvent::GestureTap; 500 tap.type = blink::WebGestureEvent::GestureTap;
501 tap.sourceDevice = blink::WebGestureDeviceTouchpad;
498 tap.x = point.x(); 502 tap.x = point.x();
499 tap.y = point.y(); 503 tap.y = point.y();
500 tap.modifiers = blink::WebInputEvent::ControlKey; 504 tap.modifiers = blink::WebInputEvent::ControlKey;
501 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( 505 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
502 web_contents->GetRenderViewHost()->GetWidget()); 506 web_contents->GetRenderViewHost()->GetWidget());
503 widget_host->ForwardGestureEvent(tap); 507 widget_host->ForwardGestureEvent(tap);
504 } 508 }
505 509
506 void SimulateTapWithModifiersAt(WebContents* web_contents, 510 void SimulateTapWithModifiersAt(WebContents* web_contents,
507 unsigned modifiers, 511 unsigned modifiers,
508 const gfx::Point& point) { 512 const gfx::Point& point) {
509 blink::WebGestureEvent tap; 513 blink::WebGestureEvent tap;
510 tap.type = blink::WebGestureEvent::GestureTap; 514 tap.type = blink::WebGestureEvent::GestureTap;
515 tap.sourceDevice = blink::WebGestureDeviceTouchpad;
511 tap.x = point.x(); 516 tap.x = point.x();
512 tap.y = point.y(); 517 tap.y = point.y();
513 tap.modifiers = modifiers; 518 tap.modifiers = modifiers;
514 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( 519 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
515 web_contents->GetRenderViewHost()->GetWidget()); 520 web_contents->GetRenderViewHost()->GetWidget());
516 widget_host->ForwardGestureEvent(tap); 521 widget_host->ForwardGestureEvent(tap);
517 } 522 }
518 523
519 void SimulateTouchPressAt(WebContents* web_contents, const gfx::Point& point) { 524 void SimulateTouchPressAt(WebContents* web_contents, const gfx::Point& point) {
520 SyntheticWebTouchEvent touch; 525 SyntheticWebTouchEvent touch;
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 void FrameWatcher::WaitFrames(int frames_to_wait) { 1091 void FrameWatcher::WaitFrames(int frames_to_wait) {
1087 if (frames_to_wait <= 0) 1092 if (frames_to_wait <= 0)
1088 return; 1093 return;
1089 base::RunLoop run_loop; 1094 base::RunLoop run_loop;
1090 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1095 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1091 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait); 1096 base::AutoReset<int> reset_frames_to_wait(&frames_to_wait_, frames_to_wait);
1092 run_loop.Run(); 1097 run_loop.Run();
1093 } 1098 }
1094 1099
1095 } // namespace content 1100 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/gesture_event_stream_validator.cc ('k') | content/public/test/render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698