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/layouttest_support.h" | 5 #include "content/public/test/layouttest_support.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/common/gpu/image_transport_surface.h" | 10 #include "content/common/gpu/image_transport_surface.h" |
11 #include "content/public/common/page_state.h" | 11 #include "content/public/common/page_state.h" |
12 #include "content/renderer/history_entry.h" | 12 #include "content/renderer/history_entry.h" |
13 #include "content/renderer/history_serialization.h" | 13 #include "content/renderer/history_serialization.h" |
14 #include "content/renderer/render_frame_impl.h" | 14 #include "content/renderer/render_frame_impl.h" |
15 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
16 #include "content/renderer/render_view_impl.h" | 16 #include "content/renderer/render_view_impl.h" |
17 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 17 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
18 #include "content/shell/renderer/test_runner/TestCommon.h" | 18 #include "content/shell/renderer/test_runner/TestCommon.h" |
19 #include "content/shell/renderer/test_runner/web_frame_test_proxy.h" | 19 #include "content/shell/renderer/test_runner/web_frame_test_proxy.h" |
20 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 20 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
21 #include "content/test/test_media_stream_client.h" | |
22 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | 21 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
23 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 22 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
24 #include "third_party/WebKit/public/platform/WebGamepads.h" | 23 #include "third_party/WebKit/public/platform/WebGamepads.h" |
25 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 24 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
26 | 25 |
27 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
28 #include "content/browser/renderer_host/popup_menu_helper_mac.h" | 27 #include "content/browser/renderer_host/popup_menu_helper_mac.h" |
29 #endif | 28 #endif |
30 | 29 |
31 using blink::WebDeviceMotionData; | 30 using blink::WebDeviceMotionData; |
(...skipping 27 matching lines...) Expand all Loading... |
59 } | 58 } |
60 | 59 |
61 RenderFrameImpl* CreateWebFrameTestProxy( | 60 RenderFrameImpl* CreateWebFrameTestProxy( |
62 RenderViewImpl* render_view, | 61 RenderViewImpl* render_view, |
63 int32 routing_id) { | 62 int32 routing_id) { |
64 typedef WebFrameTestProxy<RenderFrameImpl, RenderViewImpl*, int32> FrameProxy; | 63 typedef WebFrameTestProxy<RenderFrameImpl, RenderViewImpl*, int32> FrameProxy; |
65 | 64 |
66 FrameProxy* render_frame_proxy = new FrameProxy(render_view, routing_id); | 65 FrameProxy* render_frame_proxy = new FrameProxy(render_view, routing_id); |
67 render_frame_proxy->set_base_proxy(GetWebTestProxyBase(render_view)); | 66 render_frame_proxy->set_base_proxy(GetWebTestProxyBase(render_view)); |
68 | 67 |
69 UseMockMediaStreams(render_frame_proxy); | |
70 | |
71 return render_frame_proxy; | 68 return render_frame_proxy; |
72 } | 69 } |
73 | 70 |
74 } // namespace | 71 } // namespace |
75 | 72 |
76 | 73 |
77 void EnableWebTestProxyCreation( | 74 void EnableWebTestProxyCreation( |
78 const base::Callback<void(RenderView*, WebTestProxyBase*)>& callback) { | 75 const base::Callback<void(RenderView*, WebTestProxyBase*)>& callback) { |
79 g_callback.Get() = callback; | 76 g_callback.Get() = callback; |
80 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); | 77 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 const WebSize& max_size) { | 230 const WebSize& max_size) { |
234 static_cast<RenderViewImpl*>(render_view)-> | 231 static_cast<RenderViewImpl*>(render_view)-> |
235 EnableAutoResizeForTesting(min_size, max_size); | 232 EnableAutoResizeForTesting(min_size, max_size); |
236 } | 233 } |
237 | 234 |
238 void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) { | 235 void DisableAutoResizeMode(RenderView* render_view, const WebSize& new_size) { |
239 static_cast<RenderViewImpl*>(render_view)-> | 236 static_cast<RenderViewImpl*>(render_view)-> |
240 DisableAutoResizeForTesting(new_size); | 237 DisableAutoResizeForTesting(new_size); |
241 } | 238 } |
242 | 239 |
243 void UseMockMediaStreams(RenderFrame* render_frame) { | |
244 RenderFrameImpl* render_frame_impl = static_cast<RenderFrameImpl*>( | |
245 render_frame); | |
246 render_frame_impl->SetMediaStreamClientForTesting( | |
247 new TestMediaStreamClient(render_frame_impl)); | |
248 } | |
249 | |
250 struct ToLower { | 240 struct ToLower { |
251 base::char16 operator()(base::char16 c) { return tolower(c); } | 241 base::char16 operator()(base::char16 c) { return tolower(c); } |
252 }; | 242 }; |
253 | 243 |
254 // Returns True if node1 < node2. | 244 // Returns True if node1 < node2. |
255 bool HistoryEntryCompareLess(HistoryEntry::HistoryNode* node1, | 245 bool HistoryEntryCompareLess(HistoryEntry::HistoryNode* node1, |
256 HistoryEntry::HistoryNode* node2) { | 246 HistoryEntry::HistoryNode* node2) { |
257 base::string16 target1 = node1->item().target(); | 247 base::string16 target1 = node1->item().target(); |
258 base::string16 target2 = node2->item().target(); | 248 base::string16 target2 = node2->item().target(); |
259 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower()); | 249 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 result.append( | 293 result.append( |
304 DumpHistoryItem(entry->root_history_node(), | 294 DumpHistoryItem(entry->root_history_node(), |
305 8, | 295 8, |
306 index == current_index)); | 296 index == current_index)); |
307 } | 297 } |
308 result.append("===============================================\n"); | 298 result.append("===============================================\n"); |
309 return result; | 299 return result; |
310 } | 300 } |
311 | 301 |
312 } // namespace content | 302 } // namespace content |
OLD | NEW |