Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: content/test/layouttest_support.cc

Issue 1841833005: Revert of Extract WebFrameClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/renderer/layout_test/layout_test_content_renderer_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 using blink::WebDeviceOrientationData; 52 using blink::WebDeviceOrientationData;
53 using blink::WebGamepad; 53 using blink::WebGamepad;
54 using blink::WebGamepads; 54 using blink::WebGamepads;
55 using blink::WebRect; 55 using blink::WebRect;
56 using blink::WebSize; 56 using blink::WebSize;
57 57
58 namespace content { 58 namespace content {
59 59
60 namespace { 60 namespace {
61 61
62 base::LazyInstance<ViewProxyCreationCallback>::Leaky 62 base::LazyInstance<
63 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; 63 base::Callback<void(RenderView*, test_runner::WebTestProxyBase*)>>::Leaky
64 64 g_callback = LAZY_INSTANCE_INITIALIZER;
65 base::LazyInstance<FrameProxyCreationCallback>::Leaky
66 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
67 65
68 RenderViewImpl* CreateWebTestProxy(CompositorDependencies* compositor_deps, 66 RenderViewImpl* CreateWebTestProxy(CompositorDependencies* compositor_deps,
69 const ViewMsg_New_Params& params) { 67 const ViewMsg_New_Params& params) {
70 typedef test_runner::WebTestProxy<RenderViewImpl, CompositorDependencies*, 68 typedef test_runner::WebTestProxy<RenderViewImpl, CompositorDependencies*,
71 const ViewMsg_New_Params&> ProxyType; 69 const ViewMsg_New_Params&> ProxyType;
72 ProxyType* render_view_proxy = new ProxyType(compositor_deps, params); 70 ProxyType* render_view_proxy = new ProxyType(compositor_deps, params);
73 if (g_view_test_proxy_callback == 0) 71 if (g_callback == 0)
74 return render_view_proxy; 72 return render_view_proxy;
75 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy); 73 g_callback.Get().Run(render_view_proxy, render_view_proxy);
76 return render_view_proxy; 74 return render_view_proxy;
77 } 75 }
78 76
77 test_runner::WebTestProxyBase* GetWebTestProxyBase(
78 RenderViewImpl* render_view) {
79 typedef test_runner::WebTestProxy<RenderViewImpl, const ViewMsg_New_Params&>
80 ViewProxy;
81
82 ViewProxy* render_view_proxy = static_cast<ViewProxy*>(render_view);
83 return static_cast<test_runner::WebTestProxyBase*>(render_view_proxy);
84 }
85
79 RenderFrameImpl* CreateWebFrameTestProxy( 86 RenderFrameImpl* CreateWebFrameTestProxy(
80 const RenderFrameImpl::CreateParams& params) { 87 const RenderFrameImpl::CreateParams& params) {
81 typedef test_runner::WebFrameTestProxy< 88 typedef test_runner::WebFrameTestProxy<
82 RenderFrameImpl, const RenderFrameImpl::CreateParams&> FrameProxy; 89 RenderFrameImpl, const RenderFrameImpl::CreateParams&> FrameProxy;
83 90
84 FrameProxy* render_frame_proxy = new FrameProxy(params); 91 FrameProxy* render_frame_proxy = new FrameProxy(params);
85 if (g_frame_test_proxy_callback == 0) 92 render_frame_proxy->set_base_proxy(GetWebTestProxyBase(params.render_view));
86 return render_frame_proxy; 93
87 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy);
88 return render_frame_proxy; 94 return render_frame_proxy;
89 } 95 }
90 96
91 #if defined(OS_WIN) 97 #if defined(OS_WIN)
92 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer 98 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer
93 // side-loading, support kRegisterFontFiles to allow access to additional fonts. 99 // side-loading, support kRegisterFontFiles to allow access to additional fonts.
94 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) { 100 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) {
95 std::vector<std::string> files = switches::GetSideloadFontFiles(); 101 std::vector<std::string> files = switches::GetSideloadFontFiles();
96 for (std::vector<std::string>::const_iterator i(files.begin()); 102 for (std::vector<std::string>::const_iterator i(files.begin());
97 i != files.end(); 103 i != files.end();
98 ++i) { 104 ++i) {
99 SkTypeface* typeface = fontmgr->createFromFile(i->c_str()); 105 SkTypeface* typeface = fontmgr->createFromFile(i->c_str());
100 if (!ShouldUseDirectWriteFontProxyFieldTrial()) 106 if (!ShouldUseDirectWriteFontProxyFieldTrial())
101 DoPreSandboxWarmupForTypeface(typeface); 107 DoPreSandboxWarmupForTypeface(typeface);
102 blink::WebFontRendering::addSideloadedFontForTesting(typeface); 108 blink::WebFontRendering::addSideloadedFontForTesting(typeface);
103 } 109 }
104 } 110 }
105 #endif // OS_WIN 111 #endif // OS_WIN
106 112
107 } // namespace 113 } // namespace
108 114
109 void EnableWebTestProxyCreation( 115 void EnableWebTestProxyCreation(
110 const ViewProxyCreationCallback& view_proxy_creation_callback, 116 const base::Callback<void(RenderView*, test_runner::WebTestProxyBase*)>&
111 const FrameProxyCreationCallback& frame_proxy_creation_callback) { 117 callback) {
112 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; 118 g_callback.Get() = callback;
113 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback;
114 RenderViewImpl::InstallCreateHook(CreateWebTestProxy); 119 RenderViewImpl::InstallCreateHook(CreateWebTestProxy);
115 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); 120 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy);
116 } 121 }
117 122
118 void FetchManifestDoneCallback( 123 void FetchManifestDoneCallback(
119 scoped_ptr<ManifestFetcher> fetcher, 124 scoped_ptr<ManifestFetcher> fetcher,
120 const FetchManifestCallback& callback, 125 const FetchManifestCallback& callback,
121 const blink::WebURLResponse& response, 126 const blink::WebURLResponse& response,
122 const std::string& data) { 127 const std::string& data) {
123 // |fetcher| will be autodeleted here as it is going out of scope. 128 // |fetcher| will be autodeleted here as it is going out of scope.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 result.append( 450 result.append(
446 DumpHistoryItem(entry->root_history_node(), 451 DumpHistoryItem(entry->root_history_node(),
447 8, 452 8,
448 index == current_index)); 453 index == current_index));
449 } 454 }
450 result.append("===============================================\n"); 455 result.append("===============================================\n");
451 return result; 456 return result;
452 } 457 }
453 458
454 } // namespace content 459 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/layout_test/layout_test_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698