OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/print_messages.h" | 9 #include "chrome/common/print_messages.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "chrome/renderer/autofill/autofill_agent.h" | 11 #include "chrome/renderer/autofill/autofill_agent.h" |
12 #include "chrome/renderer/autofill/password_autofill_manager.h" | 12 #include "chrome/renderer/autofill/password_autofill_manager.h" |
13 #include "chrome/renderer/extensions/event_bindings.h" | 13 #include "chrome/renderer/extensions/event_bindings.h" |
| 14 #include "chrome/renderer/extensions/extension_dispatcher.h" |
14 #include "chrome/renderer/extensions/extension_process_bindings.h" | 15 #include "chrome/renderer/extensions/extension_process_bindings.h" |
15 #include "chrome/renderer/extensions/js_only_v8_extensions.h" | 16 #include "chrome/renderer/extensions/js_only_v8_extensions.h" |
16 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 17 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
17 #include "chrome/renderer/mock_render_process.h" | 18 #include "chrome/renderer/mock_render_process.h" |
18 #include "chrome/renderer/renderer_main_platform_delegate.h" | 19 #include "chrome/renderer/renderer_main_platform_delegate.h" |
19 #include "content/common/dom_storage_common.h" | 20 #include "content/common/dom_storage_common.h" |
20 #include "content/common/native_web_keyboard_event.h" | 21 #include "content/common/native_web_keyboard_event.h" |
21 #include "content/common/renderer_preferences.h" | 22 #include "content/common/renderer_preferences.h" |
22 #include "content/common/view_messages.h" | 23 #include "content/common/view_messages.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
(...skipping 17 matching lines...) Expand all Loading... |
41 using WebKit::WebString; | 42 using WebKit::WebString; |
42 using WebKit::WebURLRequest; | 43 using WebKit::WebURLRequest; |
43 using autofill::AutofillAgent; | 44 using autofill::AutofillAgent; |
44 using autofill::PasswordAutofillManager; | 45 using autofill::PasswordAutofillManager; |
45 | 46 |
46 namespace { | 47 namespace { |
47 const int32 kRouteId = 5; | 48 const int32 kRouteId = 5; |
48 const int32 kOpenerId = 7; | 49 const int32 kOpenerId = 7; |
49 } // namespace | 50 } // namespace |
50 | 51 |
51 RenderViewTest::RenderViewTest() { | 52 RenderViewTest::RenderViewTest() : extension_dispatcher_(NULL) { |
52 } | 53 } |
53 | 54 |
54 RenderViewTest::~RenderViewTest() { | 55 RenderViewTest::~RenderViewTest() { |
55 } | 56 } |
56 | 57 |
57 void RenderViewTest::ProcessPendingMessages() { | 58 void RenderViewTest::ProcessPendingMessages() { |
58 msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 59 msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
59 msg_loop_.Run(); | 60 msg_loop_.Run(); |
60 } | 61 } |
61 | 62 |
(...skipping 26 matching lines...) Expand all Loading... |
88 | 89 |
89 GetMainFrame()->loadRequest(WebURLRequest(url)); | 90 GetMainFrame()->loadRequest(WebURLRequest(url)); |
90 | 91 |
91 // The load actually happens asynchronously, so we pump messages to process | 92 // The load actually happens asynchronously, so we pump messages to process |
92 // the pending continuation. | 93 // the pending continuation. |
93 ProcessPendingMessages(); | 94 ProcessPendingMessages(); |
94 } | 95 } |
95 | 96 |
96 void RenderViewTest::SetUp() { | 97 void RenderViewTest::SetUp() { |
97 content::GetContentClient()->set_renderer(&content_renderer_client_); | 98 content::GetContentClient()->set_renderer(&content_renderer_client_); |
| 99 extension_dispatcher_ = new ExtensionDispatcher(); |
98 sandbox_init_wrapper_.reset(new SandboxInitWrapper()); | 100 sandbox_init_wrapper_.reset(new SandboxInitWrapper()); |
99 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 101 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
100 params_.reset(new MainFunctionParams(*command_line_, *sandbox_init_wrapper_, | 102 params_.reset(new MainFunctionParams(*command_line_, *sandbox_init_wrapper_, |
101 NULL)); | 103 NULL)); |
102 platform_.reset(new RendererMainPlatformDelegate(*params_)); | 104 platform_.reset(new RendererMainPlatformDelegate(*params_)); |
103 platform_->PlatformInitialize(); | 105 platform_->PlatformInitialize(); |
104 | 106 |
105 // Setting flags and really doing anything with WebKit is fairly fragile and | 107 // Setting flags and really doing anything with WebKit is fairly fragile and |
106 // hacky, but this is the world we live in... | 108 // hacky, but this is the world we live in... |
107 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 109 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 174 |
173 WebKit::shutdown(); | 175 WebKit::shutdown(); |
174 | 176 |
175 mock_keyboard_.reset(); | 177 mock_keyboard_.reset(); |
176 | 178 |
177 platform_->PlatformUninitialize(); | 179 platform_->PlatformUninitialize(); |
178 platform_.reset(); | 180 platform_.reset(); |
179 params_.reset(); | 181 params_.reset(); |
180 command_line_.reset(); | 182 command_line_.reset(); |
181 sandbox_init_wrapper_.reset(); | 183 sandbox_init_wrapper_.reset(); |
| 184 |
| 185 extension_dispatcher_->OnRenderProcessShutdown(); |
| 186 extension_dispatcher_ = NULL; |
182 } | 187 } |
183 | 188 |
184 int RenderViewTest::SendKeyEvent(MockKeyboard::Layout layout, | 189 int RenderViewTest::SendKeyEvent(MockKeyboard::Layout layout, |
185 int key_code, | 190 int key_code, |
186 MockKeyboard::Modifiers modifiers, | 191 MockKeyboard::Modifiers modifiers, |
187 std::wstring* output) { | 192 std::wstring* output) { |
188 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
189 // Retrieve the Unicode character for the given tuple (keyboard-layout, | 194 // Retrieve the Unicode character for the given tuple (keyboard-layout, |
190 // key-code, and modifiers). | 195 // key-code, and modifiers). |
191 // Exit when a keyboard-layout driver cannot assign a Unicode character to | 196 // Exit when a keyboard-layout driver cannot assign a Unicode character to |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 mouse_event.x = bounds.CenterPoint().x(); | 356 mouse_event.x = bounds.CenterPoint().x(); |
352 mouse_event.y = bounds.CenterPoint().y(); | 357 mouse_event.y = bounds.CenterPoint().y(); |
353 mouse_event.clickCount = 1; | 358 mouse_event.clickCount = 1; |
354 ViewMsg_HandleInputEvent input_event(0); | 359 ViewMsg_HandleInputEvent input_event(0); |
355 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); | 360 scoped_ptr<IPC::Message> input_message(new ViewMsg_HandleInputEvent(0)); |
356 input_message->WriteData(reinterpret_cast<const char*>(&mouse_event), | 361 input_message->WriteData(reinterpret_cast<const char*>(&mouse_event), |
357 sizeof(WebMouseEvent)); | 362 sizeof(WebMouseEvent)); |
358 view_->OnMessageReceived(*input_message); | 363 view_->OnMessageReceived(*input_message); |
359 return true; | 364 return true; |
360 } | 365 } |
OLD | NEW |