Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / test / layouttest_support.h
blob8e75dfefead4b97917abf9f153955b34e96254e0
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.
5 #ifndef CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_
6 #define CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "cc/layers/texture_layer.h"
13 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
15 class GURL;
17 namespace blink {
18 class WebBatteryStatus;
19 class WebDeviceMotionData;
20 class WebDeviceOrientationData;
21 class WebGamepad;
22 class WebGamepads;
23 class WebLayer;
24 struct WebSize;
25 class WebView;
26 class WebURLResponse;
29 namespace content {
31 class PageState;
32 class RenderFrame;
33 class RendererGamepadProvider;
34 class RenderView;
35 class WebTestProxyBase;
37 // Turn the browser process into layout test mode.
38 void EnableBrowserLayoutTestMode();
40 ///////////////////////////////////////////////////////////////////////////////
41 // The following methods are meant to be used from a renderer.
43 // Turn a renderer into layout test mode.
44 void EnableRendererLayoutTestMode();
46 // Enable injecting of a WebTestProxy between WebViews and RenderViews.
47 // |callback| is invoked with a pointer to WebTestProxyBase for each created
48 // WebTestProxy.
49 void EnableWebTestProxyCreation(
50 const base::Callback<void(RenderView*, WebTestProxyBase*)>& callback);
52 typedef base::Callback<void(const blink::WebURLResponse& response,
53 const std::string& data)> FetchManifestCallback;
54 void FetchManifest(blink::WebView* view, const GURL& url,
55 const FetchManifestCallback&);
57 // Sets gamepad provider to be used for layout tests.
58 void SetMockGamepadProvider(scoped_ptr<RendererGamepadProvider> provider);
60 // Sets a double that should be used when registering
61 // a listener through BlinkPlatformImpl::setDeviceLightListener().
62 void SetMockDeviceLightData(const double data);
64 // Sets WebDeviceMotionData that should be used when registering
65 // a listener through BlinkPlatformImpl::setDeviceMotionListener().
66 void SetMockDeviceMotionData(const blink::WebDeviceMotionData& data);
68 // Sets WebDeviceOrientationData that should be used when registering
69 // a listener through BlinkPlatformImpl::setDeviceOrientationListener().
70 void SetMockDeviceOrientationData(const blink::WebDeviceOrientationData& data);
72 // Notifies blink that battery status has changed.
73 void MockBatteryStatusChanged(const blink::WebBatteryStatus& status);
75 // Returns the length of the local session history of a render view.
76 int GetLocalSessionHistoryLength(RenderView* render_view);
78 // Sync the current session history to the browser process.
79 void SyncNavigationState(RenderView* render_view);
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.
84 void SetFocusAndActivate(RenderView* render_view, bool enable);
86 // Changes the window rect of the given render view.
87 void ForceResizeRenderView(RenderView* render_view,
88 const blink::WebSize& new_size);
90 // Set the device scale factor and force the compositor to resize.
91 void SetDeviceScaleFactor(RenderView* render_view, float factor);
93 // Set the device color profile associated with the profile |name|.
94 void SetDeviceColorProfile(RenderView* render_view, const std::string& name);
96 // Change the bluetooth test data while running a layout test.
97 void SetBluetoothMockDataSetForTesting(const std::string& name);
99 // Enables mock geofencing service while running a layout test.
100 // |service_available| indicates if the mock service should mock geofencing
101 // being available or not.
102 void SetGeofencingMockProvider(bool service_available);
104 // Disables mock geofencing service while running a layout test.
105 void ClearGeofencingMockProvider();
107 // Set the mock geofencing position while running a layout test.
108 void SetGeofencingMockPosition(double latitude, double longitude);
110 // Enables or disables synchronous resize mode. When enabled, all window-sizing
111 // machinery is short-circuited inside the renderer. This mode is necessary for
112 // some tests that were written before browsers had multi-process architecture
113 // and rely on window resizes to happen synchronously.
114 // See http://crbug.com/309760 for details.
115 void UseSynchronousResizeMode(RenderView* render_view, bool enable);
117 // Control auto resize mode.
118 void EnableAutoResizeMode(RenderView* render_view,
119 const blink::WebSize& min_size,
120 const blink::WebSize& max_size);
121 void DisableAutoResizeMode(RenderView* render_view,
122 const blink::WebSize& new_size);
124 // Provides a text dump of the contents of the given page state.
125 std::string DumpBackForwardList(std::vector<PageState>& page_state,
126 size_t current_index);
128 // Instantiates WebLayerImpl for TestPlugin.
129 blink::WebLayer* InstantiateWebLayer(scoped_refptr<cc::TextureLayer> layer);
131 } // namespace content
133 #endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_