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