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 15 matching lines...) Expand all Loading... |
26 #include "webkit/glue/glue_serialize.h" | 26 #include "webkit/glue/glue_serialize.h" |
27 #include "webkit/glue/webkit_glue.h" | 27 #include "webkit/glue/webkit_glue.h" |
28 | 28 |
29 using WebKit::WebFrame; | 29 using WebKit::WebFrame; |
30 using WebKit::WebInputEvent; | 30 using WebKit::WebInputEvent; |
31 using WebKit::WebMouseEvent; | 31 using WebKit::WebMouseEvent; |
32 using WebKit::WebScriptController; | 32 using WebKit::WebScriptController; |
33 using WebKit::WebScriptSource; | 33 using WebKit::WebScriptSource; |
34 using WebKit::WebString; | 34 using WebKit::WebString; |
35 using WebKit::WebURLRequest; | 35 using WebKit::WebURLRequest; |
36 using content::NativeWebKeyboardEvent; | |
37 | 36 |
38 namespace { | 37 namespace { |
39 const int32 kOpenerId = -2; | 38 const int32 kOpenerId = -2; |
40 const int32 kRouteId = 5; | 39 const int32 kRouteId = 5; |
41 const int32 kNewWindowRouteId = 6; | 40 const int32 kNewWindowRouteId = 6; |
42 const int32 kSurfaceId = 42; | 41 const int32 kSurfaceId = 42; |
43 | 42 |
44 } // namespace | 43 } // namespace |
45 | 44 |
46 namespace content { | 45 namespace content { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 129 |
131 // Subclasses can set render_thread_ with their own implementation before | 130 // Subclasses can set render_thread_ with their own implementation before |
132 // calling RenderViewTest::SetUp(). | 131 // calling RenderViewTest::SetUp(). |
133 if (!render_thread_.get()) | 132 if (!render_thread_.get()) |
134 render_thread_.reset(new MockRenderThread()); | 133 render_thread_.reset(new MockRenderThread()); |
135 render_thread_->set_routing_id(kRouteId); | 134 render_thread_->set_routing_id(kRouteId); |
136 render_thread_->set_surface_id(kSurfaceId); | 135 render_thread_->set_surface_id(kSurfaceId); |
137 render_thread_->set_new_window_routing_id(kNewWindowRouteId); | 136 render_thread_->set_new_window_routing_id(kNewWindowRouteId); |
138 | 137 |
139 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 138 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
140 params_.reset(new content::MainFunctionParams(*command_line_)); | 139 params_.reset(new MainFunctionParams(*command_line_)); |
141 platform_.reset(new RendererMainPlatformDelegate(*params_)); | 140 platform_.reset(new RendererMainPlatformDelegate(*params_)); |
142 platform_->PlatformInitialize(); | 141 platform_->PlatformInitialize(); |
143 | 142 |
144 // Setting flags and really doing anything with WebKit is fairly fragile and | 143 // Setting flags and really doing anything with WebKit is fairly fragile and |
145 // hacky, but this is the world we live in... | 144 // hacky, but this is the world we live in... |
146 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 145 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
147 WebKit::initialize(webkit_platform_support_.Get()); | 146 WebKit::initialize(webkit_platform_support_.Get()); |
148 | 147 |
149 // Ensure that we register any necessary schemes when initializing WebKit, | 148 // Ensure that we register any necessary schemes when initializing WebKit, |
150 // since we are using a MockRenderThread. | 149 // since we are using a MockRenderThread. |
151 RenderThreadImpl::RegisterSchemes(); | 150 RenderThreadImpl::RegisterSchemes(); |
152 | 151 |
153 // This check is needed because when run under content_browsertests, | 152 // This check is needed because when run under content_browsertests, |
154 // ResourceBundle isn't initialized (since we have to use a diferent test | 153 // ResourceBundle isn't initialized (since we have to use a diferent test |
155 // suite implementation than for content_unittests). For browser_tests, this | 154 // suite implementation than for content_unittests). For browser_tests, this |
156 // is already initialized. | 155 // is already initialized. |
157 if (!ResourceBundle::HasSharedInstance()) | 156 if (!ResourceBundle::HasSharedInstance()) |
158 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 157 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
159 | 158 |
160 mock_process_.reset(new MockRenderProcess); | 159 mock_process_.reset(new MockRenderProcess); |
161 | 160 |
162 // This needs to pass the mock render thread to the view. | 161 // This needs to pass the mock render thread to the view. |
163 RenderViewImpl* view = RenderViewImpl::Create( | 162 RenderViewImpl* view = RenderViewImpl::Create( |
164 0, | 163 0, |
165 kOpenerId, | 164 kOpenerId, |
166 content::RendererPreferences(), | 165 RendererPreferences(), |
167 webkit_glue::WebPreferences(), | 166 webkit_glue::WebPreferences(), |
168 new SharedRenderViewCounter(0), | 167 new SharedRenderViewCounter(0), |
169 kRouteId, | 168 kRouteId, |
170 kSurfaceId, | 169 kSurfaceId, |
171 dom_storage::kInvalidSessionStorageNamespaceId, | 170 dom_storage::kInvalidSessionStorageNamespaceId, |
172 string16(), | 171 string16(), |
173 false, | 172 false, |
174 false, | 173 false, |
175 1, | 174 1, |
176 WebKit::WebScreenInfo(), | 175 WebKit::WebScreenInfo(), |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 void RenderViewTest::GoToOffset(int offset, | 347 void RenderViewTest::GoToOffset(int offset, |
349 const WebKit::WebHistoryItem& history_item) { | 348 const WebKit::WebHistoryItem& history_item) { |
350 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); | 349 RenderViewImpl* impl = static_cast<RenderViewImpl*>(view_); |
351 | 350 |
352 int history_list_length = impl->historyBackListCount() + | 351 int history_list_length = impl->historyBackListCount() + |
353 impl->historyForwardListCount() + 1; | 352 impl->historyForwardListCount() + 1; |
354 int pending_offset = offset + impl->history_list_offset(); | 353 int pending_offset = offset + impl->history_list_offset(); |
355 | 354 |
356 ViewMsg_Navigate_Params navigate_params; | 355 ViewMsg_Navigate_Params navigate_params; |
357 navigate_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; | 356 navigate_params.navigation_type = ViewMsg_Navigate_Type::NORMAL; |
358 navigate_params.transition = content::PAGE_TRANSITION_FORWARD_BACK; | 357 navigate_params.transition = PAGE_TRANSITION_FORWARD_BACK; |
359 navigate_params.current_history_list_length = history_list_length; | 358 navigate_params.current_history_list_length = history_list_length; |
360 navigate_params.current_history_list_offset = impl->history_list_offset(); | 359 navigate_params.current_history_list_offset = impl->history_list_offset(); |
361 navigate_params.pending_history_list_offset = pending_offset; | 360 navigate_params.pending_history_list_offset = pending_offset; |
362 navigate_params.page_id = impl->GetPageId() + offset; | 361 navigate_params.page_id = impl->GetPageId() + offset; |
363 navigate_params.state = webkit_glue::HistoryItemToString(history_item); | 362 navigate_params.state = webkit_glue::HistoryItemToString(history_item); |
364 navigate_params.request_time = base::Time::Now(); | 363 navigate_params.request_time = base::Time::Now(); |
365 | 364 |
366 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); | 365 ViewMsg_Navigate navigate_message(impl->GetRoutingID(), navigate_params); |
367 OnMessageReceived(navigate_message); | 366 OnMessageReceived(navigate_message); |
368 | 367 |
369 // The load actually happens asynchronously, so we pump messages to process | 368 // The load actually happens asynchronously, so we pump messages to process |
370 // the pending continuation. | 369 // the pending continuation. |
371 ProcessPendingMessages(); | 370 ProcessPendingMessages(); |
372 } | 371 } |
373 | 372 |
374 } // namespace content | 373 } // namespace content |
OLD | NEW |