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

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

Issue 2015373002: Fix webview crash on attempt to scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed content_tests (handle case when view is not available), added expected event into Fling test … Created 4 years, 6 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 widget_host->ForwardGestureEvent(scroll_update); 516 widget_host->ForwardGestureEvent(scroll_update);
517 517
518 blink::WebGestureEvent scroll_end; 518 blink::WebGestureEvent scroll_end;
519 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd; 519 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd;
520 scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad; 520 scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad;
521 scroll_end.x = point.x() + delta.x(); 521 scroll_end.x = point.x() + delta.x();
522 scroll_end.y = point.y() + delta.y(); 522 scroll_end.y = point.y() + delta.y();
523 widget_host->ForwardGestureEvent(scroll_end); 523 widget_host->ForwardGestureEvent(scroll_end);
524 } 524 }
525 525
526 void SimulateGestureFlingSequence(WebContents* web_contents,
527 const gfx::Point& point,
528 const gfx::Vector2dF& velocity) {
529 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
530 web_contents->GetRenderViewHost()->GetWidget());
531
532 blink::WebGestureEvent scroll_begin;
533 scroll_begin.type = blink::WebGestureEvent::GestureScrollBegin;
534 scroll_begin.sourceDevice = blink::WebGestureDeviceTouchpad;
535 scroll_begin.x = point.x();
536 scroll_begin.y = point.y();
537 widget_host->ForwardGestureEvent(scroll_begin);
538
539 blink::WebGestureEvent scroll_end;
540 scroll_end.type = blink::WebGestureEvent::GestureScrollEnd;
541 scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad;
542 scroll_end.x = point.x();
543 scroll_end.y = point.y();
544 widget_host->ForwardGestureEvent(scroll_end);
545
546 blink::WebGestureEvent fling_start;
547 fling_start.type = blink::WebGestureEvent::GestureFlingStart;
548 fling_start.sourceDevice = blink::WebGestureDeviceTouchpad;
549 fling_start.x = point.x();
550 fling_start.y = point.y();
551 fling_start.data.flingStart.targetViewport = false;
552 fling_start.data.flingStart.velocityX = velocity.x();
553 fling_start.data.flingStart.velocityY = velocity.y();
554 widget_host->ForwardGestureEvent(fling_start);
555 }
556
526 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) { 557 void SimulateTapAt(WebContents* web_contents, const gfx::Point& point) {
527 blink::WebGestureEvent tap; 558 blink::WebGestureEvent tap;
528 tap.type = blink::WebGestureEvent::GestureTap; 559 tap.type = blink::WebGestureEvent::GestureTap;
529 tap.sourceDevice = blink::WebGestureDeviceTouchpad; 560 tap.sourceDevice = blink::WebGestureDeviceTouchpad;
530 tap.x = point.x(); 561 tap.x = point.x();
531 tap.y = point.y(); 562 tap.y = point.y();
532 tap.modifiers = blink::WebInputEvent::ControlKey; 563 tap.modifiers = blink::WebInputEvent::ControlKey;
533 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( 564 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
534 web_contents->GetRenderViewHost()->GetWidget()); 565 web_contents->GetRenderViewHost()->GetWidget());
535 widget_host->ForwardGestureEvent(tap); 566 widget_host->ForwardGestureEvent(tap);
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1289 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1259 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN) 1290 if (ack_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN)
1260 return ack_result_; 1291 return ack_result_;
1261 base::RunLoop run_loop; 1292 base::RunLoop run_loop;
1262 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure()); 1293 base::AutoReset<base::Closure> reset_quit(&quit_, run_loop.QuitClosure());
1263 run_loop.Run(); 1294 run_loop.Run();
1264 return ack_result_; 1295 return ack_result_;
1265 } 1296 }
1266 1297
1267 } // namespace content 1298 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698