| 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/input_messages.h" | 8 #include "content/common/input_messages.h" |
| 9 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 #include "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 void RenderViewTest::SendNativeKeyEvent( | 211 void RenderViewTest::SendNativeKeyEvent( |
| 212 const NativeWebKeyboardEvent& key_event) { | 212 const NativeWebKeyboardEvent& key_event) { |
| 213 SendWebKeyboardEvent(key_event); | 213 SendWebKeyboardEvent(key_event); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void RenderViewTest::SendWebKeyboardEvent( | 216 void RenderViewTest::SendWebKeyboardEvent( |
| 217 const WebKit::WebKeyboardEvent& key_event) { | 217 const WebKit::WebKeyboardEvent& key_event) { |
| 218 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 218 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 219 impl->OnMessageReceived( | 219 impl->OnMessageReceived( |
| 220 InputMsg_HandleInputEvent(0, &key_event, cc::LatencyInfo(), false)); | 220 InputMsg_HandleInputEvent(0, &key_event, ui::LatencyInfo(), false)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void RenderViewTest::SendWebMouseEvent( | 223 void RenderViewTest::SendWebMouseEvent( |
| 224 const WebKit::WebMouseEvent& mouse_event) { | 224 const WebKit::WebMouseEvent& mouse_event) { |
| 225 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 225 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 226 impl->OnMessageReceived( | 226 impl->OnMessageReceived( |
| 227 InputMsg_HandleInputEvent(0, &mouse_event, cc::LatencyInfo(), false)); | 227 InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 const char* const kGetCoordinatesScript = | 230 const char* const kGetCoordinatesScript = |
| 231 "(function() {" | 231 "(function() {" |
| 232 " function GetCoordinates(elem) {" | 232 " function GetCoordinates(elem) {" |
| 233 " if (!elem)" | 233 " if (!elem)" |
| 234 " return [ 0, 0];" | 234 " return [ 0, 0];" |
| 235 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" | 235 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" |
| 236 " var parent_coordinates = GetCoordinates(elem.offsetParent);" | 236 " var parent_coordinates = GetCoordinates(elem.offsetParent);" |
| 237 " coordinates[0] += parent_coordinates[0];" | 237 " coordinates[0] += parent_coordinates[0];" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 gfx::Rect bounds = GetElementBounds(element_id); | 276 gfx::Rect bounds = GetElementBounds(element_id); |
| 277 if (bounds.IsEmpty()) | 277 if (bounds.IsEmpty()) |
| 278 return false; | 278 return false; |
| 279 WebMouseEvent mouse_event; | 279 WebMouseEvent mouse_event; |
| 280 mouse_event.type = WebInputEvent::MouseDown; | 280 mouse_event.type = WebInputEvent::MouseDown; |
| 281 mouse_event.button = WebMouseEvent::ButtonLeft; | 281 mouse_event.button = WebMouseEvent::ButtonLeft; |
| 282 mouse_event.x = bounds.CenterPoint().x(); | 282 mouse_event.x = bounds.CenterPoint().x(); |
| 283 mouse_event.y = bounds.CenterPoint().y(); | 283 mouse_event.y = bounds.CenterPoint().y(); |
| 284 mouse_event.clickCount = 1; | 284 mouse_event.clickCount = 1; |
| 285 scoped_ptr<IPC::Message> input_message( | 285 scoped_ptr<IPC::Message> input_message( |
| 286 new InputMsg_HandleInputEvent(0, &mouse_event, cc::LatencyInfo(), false)); | 286 new InputMsg_HandleInputEvent(0, &mouse_event, ui::LatencyInfo(), false)); |
| 287 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 287 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 288 impl->OnMessageReceived(*input_message); | 288 impl->OnMessageReceived(*input_message); |
| 289 return true; | 289 return true; |
| 290 } | 290 } |
| 291 | 291 |
| 292 void RenderViewTest::SetFocused(const WebKit::WebNode& node) { | 292 void RenderViewTest::SetFocused(const WebKit::WebNode& node) { |
| 293 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 293 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 294 impl->focusedNodeChanged(node); | 294 impl->focusedNodeChanged(node); |
| 295 } | 295 } |
| 296 | 296 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 | 363 |
| 364 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); | 364 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); |
| 365 OnMessageReceived(navigate_message); | 365 OnMessageReceived(navigate_message); |
| 366 | 366 |
| 367 // The load actually happens asynchronously, so we pump messages to process | 367 // The load actually happens asynchronously, so we pump messages to process |
| 368 // the pending continuation. | 368 // the pending continuation. |
| 369 ProcessPendingMessages(); | 369 ProcessPendingMessages(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace content | 372 } // namespace content |
| OLD | NEW |