layouttest_support.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
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. 4 5#ifndef CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_ 6#define CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_ 7 8#include "base/callback_forward.h" 9 10namespace WebKit { 11class WebDeviceMotionData; 12class WebDeviceOrientationData; 13class WebGamepads; 14struct WebSize; 15} 16 17namespace WebTestRunner { 18class WebTestProxyBase; 19} 20 21namespace content { 22 23class RenderView; 24 25// Turn the browser process into layout test mode. 26void EnableBrowserLayoutTestMode(); 27 28/////////////////////////////////////////////////////////////////////////////// 29// The following methods are meant to be used from a renderer. 30 31// Turn a renderer into layout test mode. 32void EnableRendererLayoutTestMode(); 33 34// Enable injecting of a WebTestProxy between WebViews and RenderViews. 35// |callback| is invoked with a pointer to WebTestProxyBase for each created 36// WebTestProxy. 37void EnableWebTestProxyCreation(const base::Callback< 38 void(RenderView*, WebTestRunner::WebTestProxyBase*)>& callback); 39 40// Sets the WebGamepads that should be returned by 41// WebKitPlatformSupport::sampleGamepads(). 42void SetMockGamepads(const WebKit::WebGamepads& pads); 43 44// Sets WebDeviceMotionData that should be used when registering 45// a listener through WebKitPlatformSupport::setDeviceMotionListener(). 46void SetMockDeviceMotionData(const WebKit::WebDeviceMotionData& data); 47 48// Sets WebDeviceOrientationData that should be used when registering 49// a listener through WebKitPlatformSupport::setDeviceOrientationListener(). 50void SetMockDeviceOrientationData(const WebKit::WebDeviceOrientationData& data); 51 52// Returns the length of the local session history of a render view. 53int GetLocalSessionHistoryLength(RenderView* render_view); 54 55// Sync the current session history to the browser process. 56void SyncNavigationState(RenderView* render_view); 57 58// Sets the focus of the render view depending on |enable|. This only overrides 59// the state of the renderer, and does not sync the focus to the browser 60// process. 61void SetFocusAndActivate(RenderView* render_view, bool enable); 62 63// Changes the window rect of the given render view. 64void ForceResizeRenderView(RenderView* render_view, 65 const WebKit::WebSize& new_size); 66 67// Set the device scale factor and force the compositor to resize. 68void SetDeviceScaleFactor(RenderView* render_view, float factor); 69 70// Enables or disables synchronous resize mode. When enabled, all window-sizing 71// machinery is short-circuited inside the renderer. This mode is necessary for 72// some tests that were written before browsers had multi-process architecture 73// and rely on window resizes to happen synchronously. 74// See http://crbug.com/309760 for details. 75void UseSynchronousResizeMode(RenderView* render_view, bool enable); 76 77// Control auto resize mode. 78void EnableAutoResizeMode(RenderView* render_view, 79 const WebKit::WebSize& min_size, 80 const WebKit::WebSize& max_size); 81void DisableAutoResizeMode(RenderView* render_view, 82 const WebKit::WebSize& new_size); 83 84// Forces the |render_view| to use mock media streams. 85void UseMockMediaStreams(RenderView* render_view); 86 87} // namespace content 88 89#endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_ 90