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