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
3 // found in the LICENSE file.
5 #include "content/public/test/layouttest_support.h"
7 #include "base/callback.h"
8 #include "base/lazy_instance.h"
9 #include "content/common/gpu/image_transport_surface.h"
10 #include "content/renderer/devtools/devtools_client.h"
11 #include "content/renderer/render_view_impl.h"
12 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
13 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h"
15 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h"
17 using WebKit::WebGamepads
;
18 using WebTestRunner::WebTestProxy
;
19 using WebTestRunner::WebTestProxyBase
;
25 base::LazyInstance
<base::Callback
<void(RenderView
*, WebTestProxyBase
*)> >::Leaky
26 g_callback
= LAZY_INSTANCE_INITIALIZER
;
28 RenderViewImpl
* CreateWebTestProxy(RenderViewImplParams
* params
) {
29 typedef WebTestProxy
<RenderViewImpl
, RenderViewImplParams
*> ProxyType
;
30 ProxyType
* render_view_proxy
= new ProxyType(
31 reinterpret_cast<RenderViewImplParams
*>(params
));
33 return render_view_proxy
;
35 static_cast<RenderView
*>(render_view_proxy
), render_view_proxy
);
36 return render_view_proxy
;
42 void EnableWebTestProxyCreation(
43 const base::Callback
<void(RenderView
*, WebTestProxyBase
*)>& callback
) {
44 g_callback
.Get() = callback
;
45 RenderViewImpl::InstallCreateHook(CreateWebTestProxy
);
48 void SetMockGamepads(const WebGamepads
& pads
) {
49 RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(pads
);
52 void DisableAppCacheLogging() {
53 RendererWebApplicationCacheHostImpl::DisableLoggingForTesting();
56 void EnableDevToolsFrontendTesting() {
57 DevToolsClient::EnableDevToolsFrontendTesting();
60 int GetLocalSessionHistoryLength(RenderView
* render_view
) {
61 return static_cast<RenderViewImpl
*>(render_view
)
62 ->GetLocalSessionHistoryLengthForTesting();
65 void SetAllowOSMesaImageTransportForTesting() {
66 #if defined(OS_MACOSX)
67 ImageTransportSurface::SetAllowOSMesaForTesting(true);
71 } // namespace content