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