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

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

Issue 2621303004: Keep track of coalesced events in main thread event queue (Closed)
Patch Set: Rebase Created 3 years, 11 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/common/input_messages.h ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | 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/render_view_test.h" 5 #include "content/public/test/render_view_test.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cctype> 9 #include <cctype>
10 10
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 void RenderViewTest::SendNativeKeyEvent( 379 void RenderViewTest::SendNativeKeyEvent(
380 const NativeWebKeyboardEvent& key_event) { 380 const NativeWebKeyboardEvent& key_event) {
381 SendWebKeyboardEvent(key_event); 381 SendWebKeyboardEvent(key_event);
382 } 382 }
383 383
384 void RenderViewTest::SendWebKeyboardEvent( 384 void RenderViewTest::SendWebKeyboardEvent(
385 const blink::WebKeyboardEvent& key_event) { 385 const blink::WebKeyboardEvent& key_event) {
386 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 386 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
387 impl->OnMessageReceived(InputMsg_HandleInputEvent( 387 impl->OnMessageReceived(InputMsg_HandleInputEvent(
388 0, &key_event, ui::LatencyInfo(), 388 0, &key_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
389 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 389 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
390 } 390 }
391 391
392 void RenderViewTest::SendWebMouseEvent( 392 void RenderViewTest::SendWebMouseEvent(
393 const blink::WebMouseEvent& mouse_event) { 393 const blink::WebMouseEvent& mouse_event) {
394 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 394 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
395 impl->OnMessageReceived(InputMsg_HandleInputEvent( 395 impl->OnMessageReceived(InputMsg_HandleInputEvent(
396 0, &mouse_event, ui::LatencyInfo(), 396 0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
397 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 397 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
398 } 398 }
399 399
400 const char* const kGetCoordinatesScript = 400 const char* const kGetCoordinatesScript =
401 "(function() {" 401 "(function() {"
402 " function GetCoordinates(elem) {" 402 " function GetCoordinates(elem) {"
403 " if (!elem)" 403 " if (!elem)"
404 " return [ 0, 0];" 404 " return [ 0, 0];"
405 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" 405 " var coordinates = [ elem.offsetLeft, elem.offsetTop];"
406 " var parent_coordinates = GetCoordinates(elem.offsetParent);" 406 " var parent_coordinates = GetCoordinates(elem.offsetParent);"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 void RenderViewTest::SimulatePointClick(const gfx::Point& point) { 455 void RenderViewTest::SimulatePointClick(const gfx::Point& point) {
456 WebMouseEvent mouse_event(WebInputEvent::MouseDown, 456 WebMouseEvent mouse_event(WebInputEvent::MouseDown,
457 WebInputEvent::NoModifiers, 457 WebInputEvent::NoModifiers,
458 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 458 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
459 mouse_event.button = WebMouseEvent::Button::Left; 459 mouse_event.button = WebMouseEvent::Button::Left;
460 mouse_event.x = point.x(); 460 mouse_event.x = point.x();
461 mouse_event.y = point.y(); 461 mouse_event.y = point.y();
462 mouse_event.clickCount = 1; 462 mouse_event.clickCount = 1;
463 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 463 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
464 impl->OnMessageReceived(InputMsg_HandleInputEvent( 464 impl->OnMessageReceived(InputMsg_HandleInputEvent(
465 0, &mouse_event, ui::LatencyInfo(), 465 0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
466 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 466 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
467 mouse_event.setType(WebInputEvent::MouseUp); 467 mouse_event.setType(WebInputEvent::MouseUp);
468 impl->OnMessageReceived(InputMsg_HandleInputEvent( 468 impl->OnMessageReceived(InputMsg_HandleInputEvent(
469 0, &mouse_event, ui::LatencyInfo(), 469 0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
470 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 470 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
471 } 471 }
472 472
473 473
474 bool RenderViewTest::SimulateElementRightClick(const std::string& element_id) { 474 bool RenderViewTest::SimulateElementRightClick(const std::string& element_id) {
475 gfx::Rect bounds = GetElementBounds(element_id); 475 gfx::Rect bounds = GetElementBounds(element_id);
476 if (bounds.IsEmpty()) 476 if (bounds.IsEmpty())
477 return false; 477 return false;
478 SimulatePointRightClick(bounds.CenterPoint()); 478 SimulatePointRightClick(bounds.CenterPoint());
479 return true; 479 return true;
480 } 480 }
481 481
482 void RenderViewTest::SimulatePointRightClick(const gfx::Point& point) { 482 void RenderViewTest::SimulatePointRightClick(const gfx::Point& point) {
483 WebMouseEvent mouse_event(WebInputEvent::MouseDown, 483 WebMouseEvent mouse_event(WebInputEvent::MouseDown,
484 WebInputEvent::NoModifiers, 484 WebInputEvent::NoModifiers,
485 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 485 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
486 mouse_event.button = WebMouseEvent::Button::Right; 486 mouse_event.button = WebMouseEvent::Button::Right;
487 mouse_event.x = point.x(); 487 mouse_event.x = point.x();
488 mouse_event.y = point.y(); 488 mouse_event.y = point.y();
489 mouse_event.clickCount = 1; 489 mouse_event.clickCount = 1;
490 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 490 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
491 impl->OnMessageReceived(InputMsg_HandleInputEvent( 491 impl->OnMessageReceived(InputMsg_HandleInputEvent(
492 0, &mouse_event, ui::LatencyInfo(), 492 0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
493 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 493 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
494 mouse_event.setType(WebInputEvent::MouseUp); 494 mouse_event.setType(WebInputEvent::MouseUp);
495 impl->OnMessageReceived(InputMsg_HandleInputEvent( 495 impl->OnMessageReceived(InputMsg_HandleInputEvent(
496 0, &mouse_event, ui::LatencyInfo(), 496 0, &mouse_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
497 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 497 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
498 } 498 }
499 499
500 void RenderViewTest::SimulateRectTap(const gfx::Rect& rect) { 500 void RenderViewTest::SimulateRectTap(const gfx::Rect& rect) {
501 WebGestureEvent gesture_event( 501 WebGestureEvent gesture_event(
502 WebInputEvent::GestureTap, WebInputEvent::NoModifiers, 502 WebInputEvent::GestureTap, WebInputEvent::NoModifiers,
503 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 503 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
504 gesture_event.x = rect.CenterPoint().x(); 504 gesture_event.x = rect.CenterPoint().x();
505 gesture_event.y = rect.CenterPoint().y(); 505 gesture_event.y = rect.CenterPoint().y();
506 gesture_event.data.tap.tapCount = 1; 506 gesture_event.data.tap.tapCount = 1;
507 gesture_event.data.tap.width = rect.width(); 507 gesture_event.data.tap.width = rect.width();
508 gesture_event.data.tap.height = rect.height(); 508 gesture_event.data.tap.height = rect.height();
509 gesture_event.sourceDevice = blink::WebGestureDeviceTouchpad; 509 gesture_event.sourceDevice = blink::WebGestureDeviceTouchpad;
510 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 510 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
511 impl->OnMessageReceived(InputMsg_HandleInputEvent( 511 impl->OnMessageReceived(InputMsg_HandleInputEvent(
512 0, &gesture_event, ui::LatencyInfo(), 512 0, &gesture_event, std::vector<const WebInputEvent*>(), ui::LatencyInfo(),
513 InputEventDispatchType::DISPATCH_TYPE_BLOCKING)); 513 InputEventDispatchType::DISPATCH_TYPE_BLOCKING));
514 impl->FocusChangeComplete(); 514 impl->FocusChangeComplete();
515 } 515 }
516 516
517 void RenderViewTest::SetFocused(const blink::WebNode& node) { 517 void RenderViewTest::SetFocused(const blink::WebNode& node) {
518 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); 518 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_);
519 impl->focusedNodeChanged(blink::WebNode(), node); 519 impl->focusedNodeChanged(blink::WebNode(), node);
520 } 520 }
521 521
522 void RenderViewTest::Reload(const GURL& url) { 522 void RenderViewTest::Reload(const GURL& url) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); 673 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame());
674 frame->Navigate(common_params, StartNavigationParams(), request_params); 674 frame->Navigate(common_params, StartNavigationParams(), request_params);
675 675
676 // The load actually happens asynchronously, so we pump messages to process 676 // The load actually happens asynchronously, so we pump messages to process
677 // the pending continuation. 677 // the pending continuation.
678 FrameLoadWaiter(frame).Wait(); 678 FrameLoadWaiter(frame).Wait();
679 view_->GetWebView()->updateAllLifecyclePhases(); 679 view_->GetWebView()->updateAllLifecyclePhases();
680 } 680 }
681 681
682 } // namespace content 682 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input_messages.h ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698