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/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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 435 |
436 void RenderViewTest::SendNativeKeyEvent( | 436 void RenderViewTest::SendNativeKeyEvent( |
437 const NativeWebKeyboardEvent& key_event) { | 437 const NativeWebKeyboardEvent& key_event) { |
438 SendWebKeyboardEvent(key_event); | 438 SendWebKeyboardEvent(key_event); |
439 } | 439 } |
440 | 440 |
441 void RenderViewTest::SendWebKeyboardEvent( | 441 void RenderViewTest::SendWebKeyboardEvent( |
442 const blink::WebKeyboardEvent& key_event) { | 442 const blink::WebKeyboardEvent& key_event) { |
443 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 443 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
444 impl->OnMessageReceived( | 444 impl->OnMessageReceived( |
445 InputMsg_HandleInputEvent(0, &key_event, ui::LatencyInfo())); | 445 InputMsg_HandleInputEvent(0, &key_event, ui::LatencyInfo(), false)); |
446 } | 446 } |
447 | 447 |
448 void RenderViewTest::SendWebMouseEvent( | 448 void RenderViewTest::SendWebMouseEvent( |
449 const blink::WebMouseEvent& mouse_event) { | 449 const blink::WebMouseEvent& mouse_event) { |
450 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 450 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
451 impl->OnMessageReceived( | 451 impl->OnMessageReceived( |
452 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo())); | 452 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
453 } | 453 } |
454 | 454 |
455 const char* const kGetCoordinatesScript = | 455 const char* const kGetCoordinatesScript = |
456 "(function() {" | 456 "(function() {" |
457 " function GetCoordinates(elem) {" | 457 " function GetCoordinates(elem) {" |
458 " if (!elem)" | 458 " if (!elem)" |
459 " return [ 0, 0];" | 459 " return [ 0, 0];" |
460 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" | 460 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" |
461 " var parent_coordinates = GetCoordinates(elem.offsetParent);" | 461 " var parent_coordinates = GetCoordinates(elem.offsetParent);" |
462 " coordinates[0] += parent_coordinates[0];" | 462 " coordinates[0] += parent_coordinates[0];" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 509 |
510 void RenderViewTest::SimulatePointClick(const gfx::Point& point) { | 510 void RenderViewTest::SimulatePointClick(const gfx::Point& point) { |
511 WebMouseEvent mouse_event; | 511 WebMouseEvent mouse_event; |
512 mouse_event.type = WebInputEvent::MouseDown; | 512 mouse_event.type = WebInputEvent::MouseDown; |
513 mouse_event.button = WebMouseEvent::ButtonLeft; | 513 mouse_event.button = WebMouseEvent::ButtonLeft; |
514 mouse_event.x = point.x(); | 514 mouse_event.x = point.x(); |
515 mouse_event.y = point.y(); | 515 mouse_event.y = point.y(); |
516 mouse_event.clickCount = 1; | 516 mouse_event.clickCount = 1; |
517 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 517 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
518 impl->OnMessageReceived( | 518 impl->OnMessageReceived( |
519 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo())); | 519 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
520 mouse_event.type = WebInputEvent::MouseUp; | 520 mouse_event.type = WebInputEvent::MouseUp; |
521 impl->OnMessageReceived( | 521 impl->OnMessageReceived( |
522 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo())); | 522 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
523 } | 523 } |
524 | 524 |
525 | 525 |
526 bool RenderViewTest::SimulateElementRightClick(const std::string& element_id) { | 526 bool RenderViewTest::SimulateElementRightClick(const std::string& element_id) { |
527 gfx::Rect bounds = GetElementBounds(element_id); | 527 gfx::Rect bounds = GetElementBounds(element_id); |
528 if (bounds.IsEmpty()) | 528 if (bounds.IsEmpty()) |
529 return false; | 529 return false; |
530 SimulatePointRightClick(bounds.CenterPoint()); | 530 SimulatePointRightClick(bounds.CenterPoint()); |
531 return true; | 531 return true; |
532 } | 532 } |
533 | 533 |
534 void RenderViewTest::SimulatePointRightClick(const gfx::Point& point) { | 534 void RenderViewTest::SimulatePointRightClick(const gfx::Point& point) { |
535 WebMouseEvent mouse_event; | 535 WebMouseEvent mouse_event; |
536 mouse_event.type = WebInputEvent::MouseDown; | 536 mouse_event.type = WebInputEvent::MouseDown; |
537 mouse_event.button = WebMouseEvent::ButtonRight; | 537 mouse_event.button = WebMouseEvent::ButtonRight; |
538 mouse_event.x = point.x(); | 538 mouse_event.x = point.x(); |
539 mouse_event.y = point.y(); | 539 mouse_event.y = point.y(); |
540 mouse_event.clickCount = 1; | 540 mouse_event.clickCount = 1; |
541 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 541 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
542 impl->OnMessageReceived( | 542 impl->OnMessageReceived( |
543 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo())); | 543 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
544 mouse_event.type = WebInputEvent::MouseUp; | 544 mouse_event.type = WebInputEvent::MouseUp; |
545 impl->OnMessageReceived( | 545 impl->OnMessageReceived( |
546 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo())); | 546 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
547 } | 547 } |
548 | 548 |
549 void RenderViewTest::SimulateRectTap(const gfx::Rect& rect) { | 549 void RenderViewTest::SimulateRectTap(const gfx::Rect& rect) { |
550 WebGestureEvent gesture_event; | 550 WebGestureEvent gesture_event; |
551 gesture_event.x = rect.CenterPoint().x(); | 551 gesture_event.x = rect.CenterPoint().x(); |
552 gesture_event.y = rect.CenterPoint().y(); | 552 gesture_event.y = rect.CenterPoint().y(); |
553 gesture_event.data.tap.tapCount = 1; | 553 gesture_event.data.tap.tapCount = 1; |
554 gesture_event.data.tap.width = rect.width(); | 554 gesture_event.data.tap.width = rect.width(); |
555 gesture_event.data.tap.height = rect.height(); | 555 gesture_event.data.tap.height = rect.height(); |
556 gesture_event.type = WebInputEvent::GestureTap; | 556 gesture_event.type = WebInputEvent::GestureTap; |
557 gesture_event.sourceDevice = blink::WebGestureDeviceTouchpad; | 557 gesture_event.sourceDevice = blink::WebGestureDeviceTouchpad; |
558 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 558 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
559 impl->OnMessageReceived( | 559 impl->OnMessageReceived( |
560 InputMsg_HandleInputEvent(0, &gesture_event, ui::LatencyInfo())); | 560 InputMsg_HandleInputEvent(0, &gesture_event, ui::LatencyInfo(), false)); |
561 impl->FocusChangeComplete(); | 561 impl->FocusChangeComplete(); |
562 } | 562 } |
563 | 563 |
564 void RenderViewTest::SetFocused(const blink::WebNode& node) { | 564 void RenderViewTest::SetFocused(const blink::WebNode& node) { |
565 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 565 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
566 impl->focusedNodeChanged(blink::WebNode(), node); | 566 impl->focusedNodeChanged(blink::WebNode(), node); |
567 } | 567 } |
568 | 568 |
569 void RenderViewTest::Reload(const GURL& url) { | 569 void RenderViewTest::Reload(const GURL& url) { |
570 CommonNavigationParams common_params( | 570 CommonNavigationParams common_params( |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 TestRenderFrame* frame = | 716 TestRenderFrame* frame = |
717 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); | 717 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); |
718 frame->Navigate(common_params, StartNavigationParams(), request_params); | 718 frame->Navigate(common_params, StartNavigationParams(), request_params); |
719 | 719 |
720 // The load actually happens asynchronously, so we pump messages to process | 720 // The load actually happens asynchronously, so we pump messages to process |
721 // the pending continuation. | 721 // the pending continuation. |
722 FrameLoadWaiter(frame).Wait(); | 722 FrameLoadWaiter(frame).Wait(); |
723 } | 723 } |
724 | 724 |
725 } // namespace content | 725 } // namespace content |
OLD | NEW |