| 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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/common/dom_storage/dom_storage_types.h" | 8 #include "content/common/dom_storage/dom_storage_types.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 return gfx::Rect(); | 315 return gfx::Rect(); |
| 316 coords.push_back(value->Int32Value()); | 316 coords.push_back(value->Int32Value()); |
| 317 } | 317 } |
| 318 return gfx::Rect(coords[0], coords[1], coords[2], coords[3]); | 318 return gfx::Rect(coords[0], coords[1], coords[2], coords[3]); |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool RenderViewTest::SimulateElementClick(const std::string& element_id) { | 321 bool RenderViewTest::SimulateElementClick(const std::string& element_id) { |
| 322 gfx::Rect bounds = GetElementBounds(element_id); | 322 gfx::Rect bounds = GetElementBounds(element_id); |
| 323 if (bounds.IsEmpty()) | 323 if (bounds.IsEmpty()) |
| 324 return false; | 324 return false; |
| 325 SimulatePointClick(bounds.CenterPoint()); |
| 326 return true; |
| 327 } |
| 328 |
| 329 void RenderViewTest::SimulatePointClick(const gfx::Point& point) { |
| 325 WebMouseEvent mouse_event; | 330 WebMouseEvent mouse_event; |
| 326 mouse_event.type = WebInputEvent::MouseDown; | 331 mouse_event.type = WebInputEvent::MouseDown; |
| 327 mouse_event.button = WebMouseEvent::ButtonLeft; | 332 mouse_event.button = WebMouseEvent::ButtonLeft; |
| 328 mouse_event.x = bounds.CenterPoint().x(); | 333 mouse_event.x = point.x(); |
| 329 mouse_event.y = bounds.CenterPoint().y(); | 334 mouse_event.y = point.y(); |
| 330 mouse_event.clickCount = 1; | 335 mouse_event.clickCount = 1; |
| 331 scoped_ptr<IPC::Message> input_message( | |
| 332 new InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); | |
| 333 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 336 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 334 impl->OnMessageReceived(*input_message); | 337 impl->OnMessageReceived( |
| 335 return true; | 338 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
| 339 mouse_event.type = WebInputEvent::MouseUp; |
| 340 impl->OnMessageReceived( |
| 341 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
| 336 } | 342 } |
| 337 | 343 |
| 338 void RenderViewTest::SetFocused(const blink::WebNode& node) { | 344 void RenderViewTest::SetFocused(const blink::WebNode& node) { |
| 339 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 345 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 340 impl->focusedNodeChanged(node); | 346 impl->focusedNodeChanged(node); |
| 341 } | 347 } |
| 342 | 348 |
| 343 void RenderViewTest::Reload(const GURL& url) { | 349 void RenderViewTest::Reload(const GURL& url) { |
| 344 FrameMsg_Navigate_Params params; | 350 FrameMsg_Navigate_Params params; |
| 345 params.common_params.url = url; | 351 params.common_params.url = url; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 FrameMsg_Navigate navigate_message(impl->GetMainRenderFrame()->GetRoutingID(), | 439 FrameMsg_Navigate navigate_message(impl->GetMainRenderFrame()->GetRoutingID(), |
| 434 navigate_params); | 440 navigate_params); |
| 435 impl->GetMainRenderFrame()->OnMessageReceived(navigate_message); | 441 impl->GetMainRenderFrame()->OnMessageReceived(navigate_message); |
| 436 | 442 |
| 437 // The load actually happens asynchronously, so we pump messages to process | 443 // The load actually happens asynchronously, so we pump messages to process |
| 438 // the pending continuation. | 444 // the pending continuation. |
| 439 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); | 445 FrameLoadWaiter(view_->GetMainRenderFrame()).Wait(); |
| 440 } | 446 } |
| 441 | 447 |
| 442 } // namespace content | 448 } // namespace content |
| OLD | NEW |