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