| 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 "content/common/view_messages.h" | 7 #include "content/common/view_messages.h" |
| 8 #include "content/public/browser/native_web_keyboard_event.h" | 8 #include "content/public/browser/native_web_keyboard_event.h" |
| 9 #include "content/public/common/renderer_preferences.h" | 9 #include "content/public/common/renderer_preferences.h" |
| 10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 void RenderViewTest::SendNativeKeyEvent( | 205 void RenderViewTest::SendNativeKeyEvent( |
| 206 const NativeWebKeyboardEvent& key_event) { | 206 const NativeWebKeyboardEvent& key_event) { |
| 207 SendWebKeyboardEvent(key_event); | 207 SendWebKeyboardEvent(key_event); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void RenderViewTest::SendWebKeyboardEvent( | 210 void RenderViewTest::SendWebKeyboardEvent( |
| 211 const WebKit::WebKeyboardEvent& key_event) { | 211 const WebKit::WebKeyboardEvent& key_event) { |
| 212 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 212 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 213 impl->OnMessageReceived(ViewMsg_HandleInputEvent(0, &key_event, false)); | 213 impl->OnMessageReceived(ViewMsg_HandleInputEvent(0, 0, &key_event, false)); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void RenderViewTest::SendWebMouseEvent( | 216 void RenderViewTest::SendWebMouseEvent( |
| 217 const WebKit::WebMouseEvent& mouse_event) { | 217 const WebKit::WebMouseEvent& mouse_event) { |
| 218 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 218 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 219 impl->OnMessageReceived(ViewMsg_HandleInputEvent(0, &mouse_event, false)); | 219 impl->OnMessageReceived(ViewMsg_HandleInputEvent(0, 0, &mouse_event, false)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 const char* const kGetCoordinatesScript = | 222 const char* const kGetCoordinatesScript = |
| 223 "(function() {" | 223 "(function() {" |
| 224 " function GetCoordinates(elem) {" | 224 " function GetCoordinates(elem) {" |
| 225 " if (!elem)" | 225 " if (!elem)" |
| 226 " return [ 0, 0];" | 226 " return [ 0, 0];" |
| 227 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" | 227 " var coordinates = [ elem.offsetLeft, elem.offsetTop];" |
| 228 " var parent_coordinates = GetCoordinates(elem.offsetParent);" | 228 " var parent_coordinates = GetCoordinates(elem.offsetParent);" |
| 229 " coordinates[0] += parent_coordinates[0];" | 229 " coordinates[0] += parent_coordinates[0];" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 gfx::Rect bounds = GetElementBounds(element_id); | 268 gfx::Rect bounds = GetElementBounds(element_id); |
| 269 if (bounds.IsEmpty()) | 269 if (bounds.IsEmpty()) |
| 270 return false; | 270 return false; |
| 271 WebMouseEvent mouse_event; | 271 WebMouseEvent mouse_event; |
| 272 mouse_event.type = WebInputEvent::MouseDown; | 272 mouse_event.type = WebInputEvent::MouseDown; |
| 273 mouse_event.button = WebMouseEvent::ButtonLeft; | 273 mouse_event.button = WebMouseEvent::ButtonLeft; |
| 274 mouse_event.x = bounds.CenterPoint().x(); | 274 mouse_event.x = bounds.CenterPoint().x(); |
| 275 mouse_event.y = bounds.CenterPoint().y(); | 275 mouse_event.y = bounds.CenterPoint().y(); |
| 276 mouse_event.clickCount = 1; | 276 mouse_event.clickCount = 1; |
| 277 scoped_ptr<IPC::Message> input_message( | 277 scoped_ptr<IPC::Message> input_message( |
| 278 new ViewMsg_HandleInputEvent(0, &mouse_event, false)); | 278 new ViewMsg_HandleInputEvent(0, 0, &mouse_event, false)); |
| 279 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 279 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 280 impl->OnMessageReceived(*input_message); | 280 impl->OnMessageReceived(*input_message); |
| 281 return true; | 281 return true; |
| 282 } | 282 } |
| 283 | 283 |
| 284 void RenderViewTest::SetFocused(const WebKit::WebNode& node) { | 284 void RenderViewTest::SetFocused(const WebKit::WebNode& node) { |
| 285 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 285 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 286 impl->focusedNodeChanged(node); | 286 impl->focusedNodeChanged(node); |
| 287 } | 287 } |
| 288 | 288 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); | 356 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); |
| 357 OnMessageReceived(navigate_message); | 357 OnMessageReceived(navigate_message); |
| 358 | 358 |
| 359 // The load actually happens asynchronously, so we pump messages to process | 359 // The load actually happens asynchronously, so we pump messages to process |
| 360 // the pending continuation. | 360 // the pending continuation. |
| 361 ProcessPendingMessages(); | 361 ProcessPendingMessages(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 } // namespace content | 364 } // namespace content |
| OLD | NEW |