| 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 "content/test/render_view_test.h" | 5 #include "content/test/render_view_test.h" |
| 6 | 6 |
| 7 #include "content/common/dom_storage_common.h" | 7 #include "content/common/dom_storage_common.h" |
| 8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/public/browser/native_web_keyboard_event.h" | 9 #include "content/public/browser/native_web_keyboard_event.h" |
| 10 #include "content/public/common/renderer_preferences.h" | 10 #include "content/public/common/renderer_preferences.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 using WebKit::WebInputEvent; | 39 using WebKit::WebInputEvent; |
| 40 using WebKit::WebMouseEvent; | 40 using WebKit::WebMouseEvent; |
| 41 using WebKit::WebScriptController; | 41 using WebKit::WebScriptController; |
| 42 using WebKit::WebScriptSource; | 42 using WebKit::WebScriptSource; |
| 43 using WebKit::WebString; | 43 using WebKit::WebString; |
| 44 using WebKit::WebURLRequest; | 44 using WebKit::WebURLRequest; |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 const int32 kOpenerId = 7; | 47 const int32 kOpenerId = 7; |
| 48 const int32 kRouteId = 5; | 48 const int32 kRouteId = 5; |
| 49 const int32 kSurfaceId = 42; |
| 49 | 50 |
| 50 #if defined(USE_AURA) && defined(USE_X11) | 51 #if defined(USE_AURA) && defined(USE_X11) |
| 51 // Converts MockKeyboard::Modifiers to ui::EventFlags. | 52 // Converts MockKeyboard::Modifiers to ui::EventFlags. |
| 52 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { | 53 int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) { |
| 53 static struct ModifierMap { | 54 static struct ModifierMap { |
| 54 MockKeyboard::Modifiers src; | 55 MockKeyboard::Modifiers src; |
| 55 int dst; | 56 int dst; |
| 56 } kModifierMap[] = { | 57 } kModifierMap[] = { |
| 57 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN }, | 58 { MockKeyboard::LEFT_SHIFT, ui::EF_SHIFT_DOWN }, |
| 58 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN }, | 59 { MockKeyboard::RIGHT_SHIFT, ui::EF_SHIFT_DOWN }, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Subclasses can set the ContentClient's renderer before calling | 124 // Subclasses can set the ContentClient's renderer before calling |
| 124 // RenderViewTest::SetUp(). | 125 // RenderViewTest::SetUp(). |
| 125 if (!GetContentClient()->renderer()) | 126 if (!GetContentClient()->renderer()) |
| 126 GetContentClient()->set_renderer(&mock_content_renderer_client_); | 127 GetContentClient()->set_renderer(&mock_content_renderer_client_); |
| 127 | 128 |
| 128 // Subclasses can set render_thread_ with their own implementation before | 129 // Subclasses can set render_thread_ with their own implementation before |
| 129 // calling RenderViewTest::SetUp(). | 130 // calling RenderViewTest::SetUp(). |
| 130 if (!render_thread_.get()) | 131 if (!render_thread_.get()) |
| 131 render_thread_.reset(new MockRenderThread()); | 132 render_thread_.reset(new MockRenderThread()); |
| 132 render_thread_->set_routing_id(kRouteId); | 133 render_thread_->set_routing_id(kRouteId); |
| 134 render_thread_->set_surface_id(kSurfaceId); |
| 133 | 135 |
| 134 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 136 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
| 135 params_.reset(new content::MainFunctionParams(*command_line_)); | 137 params_.reset(new content::MainFunctionParams(*command_line_)); |
| 136 platform_.reset(new RendererMainPlatformDelegate(*params_)); | 138 platform_.reset(new RendererMainPlatformDelegate(*params_)); |
| 137 platform_->PlatformInitialize(); | 139 platform_->PlatformInitialize(); |
| 138 | 140 |
| 139 // Setting flags and really doing anything with WebKit is fairly fragile and | 141 // Setting flags and really doing anything with WebKit is fairly fragile and |
| 140 // hacky, but this is the world we live in... | 142 // hacky, but this is the world we live in... |
| 141 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 143 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
| 142 WebKit::initialize(&webkit_platform_support_); | 144 WebKit::initialize(&webkit_platform_support_); |
| 143 | 145 |
| 144 mock_process_.reset(new MockRenderProcess); | 146 mock_process_.reset(new MockRenderProcess); |
| 145 | 147 |
| 146 // This needs to pass the mock render thread to the view. | 148 // This needs to pass the mock render thread to the view. |
| 147 RenderViewImpl* view = RenderViewImpl::Create( | 149 RenderViewImpl* view = RenderViewImpl::Create( |
| 148 0, | 150 0, |
| 149 kOpenerId, | 151 kOpenerId, |
| 150 content::RendererPreferences(), | 152 content::RendererPreferences(), |
| 151 WebPreferences(), | 153 WebPreferences(), |
| 152 new SharedRenderViewCounter(0), | 154 new SharedRenderViewCounter(0), |
| 153 kRouteId, | 155 kRouteId, |
| 156 kSurfaceId, |
| 154 kInvalidSessionStorageNamespaceId, | 157 kInvalidSessionStorageNamespaceId, |
| 155 string16(), | 158 string16(), |
| 156 1); | 159 1); |
| 157 view->AddRef(); | 160 view->AddRef(); |
| 158 view_ = view; | 161 view_ = view; |
| 159 | 162 |
| 160 // Attach a pseudo keyboard device to this object. | 163 // Attach a pseudo keyboard device to this object. |
| 161 mock_keyboard_.reset(new MockKeyboard()); | 164 mock_keyboard_.reset(new MockKeyboard()); |
| 162 } | 165 } |
| 163 | 166 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 430 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 428 impl->set_send_content_state_immediately(true); | 431 impl->set_send_content_state_immediately(true); |
| 429 } | 432 } |
| 430 | 433 |
| 431 WebKit::WebWidget* RenderViewTest::GetWebWidget() { | 434 WebKit::WebWidget* RenderViewTest::GetWebWidget() { |
| 432 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 435 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
| 433 return impl->webwidget(); | 436 return impl->webwidget(); |
| 434 } | 437 } |
| 435 | 438 |
| 436 } // namespace content | 439 } // namespace content |
| OLD | NEW |