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