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_
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"
18 class WebBatteryStatus
;
19 class WebDeviceMotionData
;
20 class WebDeviceOrientationData
;
30 class BluetoothAdapter
;
33 namespace test_runner
{
34 class WebTestProxyBase
;
41 class RendererGamepadProvider
;
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
56 void EnableWebTestProxyCreation(
57 const base::Callback
<void(RenderView
*, test_runner::WebTestProxyBase
*)>&
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
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 } // namespace content
139 #endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_