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