Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / public / test / layouttest_support.h
blob2890139c45bc5bd3cb857a5547a5a52216c5bdab
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/modules/screen_orientation/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 device {
30 class BluetoothAdapter;
33 namespace test_runner {
34 class WebTestProxyBase;
37 namespace content {
39 class PageState;
40 class RenderFrame;
41 class RendererGamepadProvider;
42 class RenderView;
44 // Turn the browser process into layout test mode.
45 void EnableBrowserLayoutTestMode();
47 ///////////////////////////////////////////////////////////////////////////////
48 // The following methods are meant to be used from a renderer.
50 // Turn a renderer into layout test mode.
51 void EnableRendererLayoutTestMode();
53 // Enable injecting of a WebTestProxy between WebViews and RenderViews.
54 // |callback| is invoked with a pointer to WebTestProxyBase for each created
55 // WebTestProxy.
56 void EnableWebTestProxyCreation(
57 const base::Callback<void(RenderView*, test_runner::WebTestProxyBase*)>&
58 callback);
60 typedef base::Callback<void(const blink::WebURLResponse& response,
61 const std::string& data)> FetchManifestCallback;
62 void FetchManifest(blink::WebView* view, const GURL& url,
63 const FetchManifestCallback&);
65 // Sets gamepad provider to be used for layout tests.
66 void SetMockGamepadProvider(scoped_ptr<RendererGamepadProvider> provider);
68 // Sets a double that should be used when registering
69 // a listener through BlinkPlatformImpl::setDeviceLightListener().
70 void SetMockDeviceLightData(const double data);
72 // Sets WebDeviceMotionData that should be used when registering
73 // a listener through BlinkPlatformImpl::setDeviceMotionListener().
74 void SetMockDeviceMotionData(const blink::WebDeviceMotionData& data);
76 // Sets WebDeviceOrientationData that should be used when registering
77 // a listener through BlinkPlatformImpl::setDeviceOrientationListener().
78 void SetMockDeviceOrientationData(const blink::WebDeviceOrientationData& data);
80 // Notifies blink that battery status has changed.
81 void MockBatteryStatusChanged(const blink::WebBatteryStatus& status);
83 // Returns the length of the local session history of a render view.
84 int GetLocalSessionHistoryLength(RenderView* render_view);
86 // Sync the current session history to the browser process.
87 void SyncNavigationState(RenderView* render_view);
89 // Sets the focus of the render view depending on |enable|. This only overrides
90 // the state of the renderer, and does not sync the focus to the browser
91 // process.
92 void SetFocusAndActivate(RenderView* render_view, bool enable);
94 // Changes the window rect of the given render view.
95 void ForceResizeRenderView(RenderView* render_view,
96 const blink::WebSize& new_size);
98 // Set the device scale factor and force the compositor to resize.
99 void SetDeviceScaleFactor(RenderView* render_view, float factor);
101 // Set the device color profile associated with the profile |name|.
102 void SetDeviceColorProfile(RenderView* render_view, const std::string& name);
104 // Change the bluetooth test adapter while running a layout test.
105 void SetBluetoothAdapter(int render_process_id,
106 scoped_refptr<device::BluetoothAdapter> adapter);
108 // Enables mock geofencing service while running a layout test.
109 // |service_available| indicates if the mock service should mock geofencing
110 // being available or not.
111 void SetGeofencingMockProvider(bool service_available);
113 // Disables mock geofencing service while running a layout test.
114 void ClearGeofencingMockProvider();
116 // Set the mock geofencing position while running a layout test.
117 void SetGeofencingMockPosition(double latitude, double longitude);
119 // Enables or disables synchronous resize mode. When enabled, all window-sizing
120 // machinery is short-circuited inside the renderer. This mode is necessary for
121 // some tests that were written before browsers had multi-process architecture
122 // and rely on window resizes to happen synchronously.
123 // See http://crbug.com/309760 for details.
124 void UseSynchronousResizeMode(RenderView* render_view, bool enable);
126 // Control auto resize mode.
127 void EnableAutoResizeMode(RenderView* render_view,
128 const blink::WebSize& min_size,
129 const blink::WebSize& max_size);
130 void DisableAutoResizeMode(RenderView* render_view,
131 const blink::WebSize& new_size);
133 // Provides a text dump of the contents of the given page state.
134 std::string DumpBackForwardList(std::vector<PageState>& page_state,
135 size_t current_index);
137 // Creates cc::TextureLayer for TestPlugin.
138 scoped_refptr<cc::TextureLayer> CreateTextureLayerForMailbox(
139 cc::TextureLayerClient* client);
141 // Instantiates WebLayerImpl for TestPlugin.
142 blink::WebLayer* InstantiateWebLayer(scoped_refptr<cc::TextureLayer> layer);
144 } // namespace content
146 #endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_