layouttest_support.h revision 3551c9c881056c480085172ff9840cab31610854
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// Control auto resize mode.
71void EnableAutoResizeMode(RenderView* render_view,
72                          const WebKit::WebSize& min_size,
73                          const WebKit::WebSize& max_size);
74void DisableAutoResizeMode(RenderView* render_view,
75                           const WebKit::WebSize& new_size);
76
77// Forces the |render_view| to use mock media streams.
78void UseMockMediaStreams(RenderView* render_view);
79
80}  // namespace content
81
82#endif  // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_
83