Fix build break
[chromium-blink-merge.git] / content / test / layouttest_support.cc
blobefa333aef56adc5f6df3f5ae1764c7af702d31a4
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_thread_impl.h"
12 #include "content/renderer/render_view_impl.h"
13 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
14 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h"
16 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h"
18 using WebKit::WebGamepads;
19 using WebTestRunner::WebTestProxy;
20 using WebTestRunner::WebTestProxyBase;
22 namespace content {
24 namespace {
26 base::LazyInstance<base::Callback<void(RenderView*, WebTestProxyBase*)> >::Leaky
27 g_callback = LAZY_INSTANCE_INITIALIZER;
29 RenderViewImpl* CreateWebTestProxy(RenderViewImplParams* params) {
30 typedef WebTestProxy<RenderViewImpl, RenderViewImplParams*> ProxyType;
31 ProxyType* render_view_proxy = new ProxyType(
32 reinterpret_cast<RenderViewImplParams*>(params));
33 if (g_callback == 0)
34 return render_view_proxy;
35 g_callback.Get().Run(
36 static_cast<RenderView*>(render_view_proxy), render_view_proxy);
37 return render_view_proxy;
40 } // namespace
43 void EnableWebTestProxyCreation(
44 const base::Callback<void(RenderView*, WebTestProxyBase*)>& callback) {
45 g_callback.Get() = callback;
46 RenderViewImpl::InstallCreateHook(CreateWebTestProxy);
49 void SetMockGamepads(const WebGamepads& pads) {
50 RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(pads);
53 void DisableAppCacheLogging() {
54 RendererWebApplicationCacheHostImpl::DisableLoggingForTesting();
57 void EnableDevToolsFrontendTesting() {
58 DevToolsClient::EnableDevToolsFrontendTesting();
61 int GetLocalSessionHistoryLength(RenderView* render_view) {
62 return static_cast<RenderViewImpl*>(render_view)
63 ->GetLocalSessionHistoryLengthForTesting();
66 void SetAllowOSMesaImageTransportForTesting() {
67 #if defined(OS_MACOSX)
68 ImageTransportSurface::SetAllowOSMesaForTesting(true);
69 #endif
72 void DoNotSendFocusEvents() {
73 RenderThreadImpl::current()->set_should_send_focus_ipcs(false);
76 void SyncNavigationState(RenderView* render_view) {
77 static_cast<RenderViewImpl*>(render_view)->SyncNavigationState();
80 void SetFocusAndActivate(RenderView* render_view, bool enable) {
81 static_cast<RenderViewImpl*>(render_view)
82 ->SetFocusAndActivateForTesting(enable);
85 void EnableShortCircuitSizeUpdates() {
86 RenderThreadImpl::current()->set_short_circuit_size_updates(true);
89 void ForceResizeRenderView(RenderView* render_view,
90 const WebKit::WebSize& new_size) {
91 static_cast<RenderViewImpl*>(render_view)->didAutoResize(new_size);
94 void DisableNavigationErrorPages() {
95 RenderThreadImpl::current()->set_skip_error_pages(true);
98 void SetDeviceScaleFactor(RenderView* render_view, float factor) {
99 static_cast<RenderViewImpl*>(render_view)
100 ->SetDeviceScaleFactorForTesting(factor);
103 } // namespace content