| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/render_view_test.h" | 5 #include "chrome/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 7 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/native_web_keyboard_event.h" | 9 #include "chrome/common/native_web_keyboard_event.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| 11 #include "chrome/common/renderer_preferences.h" | 11 #include "chrome/common/renderer_preferences.h" |
| 12 #include "chrome/renderer/extensions/event_bindings.h" | 12 #include "chrome/renderer/extensions/event_bindings.h" |
| 13 #include "chrome/renderer/extensions/extension_process_bindings.h" | 13 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| 14 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 14 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
| 15 #include "chrome/renderer/js_only_v8_extensions.h" | 15 #include "chrome/renderer/js_only_v8_extensions.h" |
| 16 #include "chrome/renderer/renderer_main_platform_delegate.h" | 16 #include "chrome/renderer/renderer_main_platform_delegate.h" |
| 17 #include "webkit/api/public/WebFrame.h" |
| 17 #include "webkit/api/public/WebInputEvent.h" | 18 #include "webkit/api/public/WebInputEvent.h" |
| 18 #include "webkit/api/public/WebKit.h" | 19 #include "webkit/api/public/WebKit.h" |
| 19 #include "webkit/api/public/WebScriptSource.h" | 20 #include "webkit/api/public/WebScriptSource.h" |
| 20 #include "webkit/api/public/WebURLRequest.h" | 21 #include "webkit/api/public/WebURLRequest.h" |
| 21 #include "webkit/glue/webview.h" | 22 #include "webkit/glue/webview.h" |
| 22 | 23 |
| 24 using WebKit::WebFrame; |
| 23 using WebKit::WebScriptSource; | 25 using WebKit::WebScriptSource; |
| 24 using WebKit::WebString; | 26 using WebKit::WebString; |
| 25 using WebKit::WebURLRequest; | 27 using WebKit::WebURLRequest; |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | |
| 29 const int32 kRouteId = 5; | 30 const int32 kRouteId = 5; |
| 30 const int32 kOpenerId = 7; | 31 const int32 kOpenerId = 7; |
| 31 | 32 } |
| 32 }; | |
| 33 | 33 |
| 34 void RenderViewTest::ProcessPendingMessages() { | 34 void RenderViewTest::ProcessPendingMessages() { |
| 35 msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 35 msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 36 msg_loop_.Run(); | 36 msg_loop_.Run(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 WebFrame* RenderViewTest::GetMainFrame() { | 39 WebFrame* RenderViewTest::GetMainFrame() { |
| 40 return view_->webview()->GetMainFrame(); | 40 return view_->webview()->GetMainFrame(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RenderViewTest::ExecuteJavaScript(const char* js) { | 43 void RenderViewTest::ExecuteJavaScript(const char* js) { |
| 44 GetMainFrame()->ExecuteScript(WebScriptSource(WebString::fromUTF8(js))); | 44 GetMainFrame()->executeScript(WebScriptSource(WebString::fromUTF8(js))); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RenderViewTest::LoadHTML(const char* html) { | 47 void RenderViewTest::LoadHTML(const char* html) { |
| 48 std::string url_str = "data:text/html;charset=utf-8,"; | 48 std::string url_str = "data:text/html;charset=utf-8,"; |
| 49 url_str.append(html); | 49 url_str.append(html); |
| 50 GURL url(url_str); | 50 GURL url(url_str); |
| 51 | 51 |
| 52 GetMainFrame()->LoadRequest(WebURLRequest(url)); | 52 GetMainFrame()->loadRequest(WebURLRequest(url)); |
| 53 | 53 |
| 54 // The load actually happens asynchronously, so we pump messages to process | 54 // The load actually happens asynchronously, so we pump messages to process |
| 55 // the pending continuation. | 55 // the pending continuation. |
| 56 ProcessPendingMessages(); | 56 ProcessPendingMessages(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void RenderViewTest::SetUp() { | 59 void RenderViewTest::SetUp() { |
| 60 sandbox_init_wrapper_.reset(new SandboxInitWrapper()); | 60 sandbox_init_wrapper_.reset(new SandboxInitWrapper()); |
| 61 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 62 command_line_.reset(new CommandLine(std::wstring())); | 62 command_line_.reset(new CommandLine(std::wstring())); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 keyup_message->WriteData(reinterpret_cast<const char*>(&keyup_event), | 161 keyup_message->WriteData(reinterpret_cast<const char*>(&keyup_event), |
| 162 sizeof(WebKit::WebKeyboardEvent)); | 162 sizeof(WebKit::WebKeyboardEvent)); |
| 163 view_->OnHandleInputEvent(*keyup_message); | 163 view_->OnHandleInputEvent(*keyup_message); |
| 164 | 164 |
| 165 return length; | 165 return length; |
| 166 #else | 166 #else |
| 167 NOTIMPLEMENTED(); | 167 NOTIMPLEMENTED(); |
| 168 return L'\0'; | 168 return L'\0'; |
| 169 #endif | 169 #endif |
| 170 } | 170 } |
| OLD | NEW |