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