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