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 10 namespace blink { 11 class WebDeviceMotionData; 12 class WebDeviceOrientationData; 13 class WebGamepads; 14 struct WebSize; 15 } 16 17 namespace WebTestRunner { 18 class WebTestProxyBase; 19 } 20 21 namespace content { 22 23 class RenderView; 24 25 // Turn the browser process into layout test mode. 26 void EnableBrowserLayoutTestMode(); 27 28 /////////////////////////////////////////////////////////////////////////////// 29 // The following methods are meant to be used from a renderer. 30 31 // Turn a renderer into layout test mode. 32 void 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. 37 void EnableWebTestProxyCreation(const base::Callback< 38 void(RenderView*, WebTestRunner::WebTestProxyBase*)>& callback); 39 40 // Sets the WebGamepads that should be returned by 41 // WebKitPlatformSupport::sampleGamepads(). 42 void SetMockGamepads(const blink::WebGamepads& pads); 43 44 // Sets WebDeviceMotionData that should be used when registering 45 // a listener through WebKitPlatformSupport::setDeviceMotionListener(). 46 void SetMockDeviceMotionData(const blink::WebDeviceMotionData& data); 47 48 // Sets WebDeviceOrientationData that should be used when registering 49 // a listener through WebKitPlatformSupport::setDeviceOrientationListener(). 50 void SetMockDeviceOrientationData(const blink::WebDeviceOrientationData& data); 51 52 // Returns the length of the local session history of a render view. 53 int GetLocalSessionHistoryLength(RenderView* render_view); 54 55 // Sync the current session history to the browser process. 56 void 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. 61 void SetFocusAndActivate(RenderView* render_view, bool enable); 62 63 // Changes the window rect of the given render view. 64 void ForceResizeRenderView(RenderView* render_view, 65 const blink::WebSize& new_size); 66 67 // Set the device scale factor and force the compositor to resize. 68 void SetDeviceScaleFactor(RenderView* render_view, float factor); 69 70 // Enables or disables synchronous resize mode. When enabled, all window-sizing 71 // machinery is short-circuited inside the renderer. This mode is necessary for 72 // some tests that were written before browsers had multi-process architecture 73 // and rely on window resizes to happen synchronously. 74 // See http://crbug.com/309760 for details. 75 void UseSynchronousResizeMode(RenderView* render_view, bool enable); 76 77 // Control auto resize mode. 78 void EnableAutoResizeMode(RenderView* render_view, 79 const blink::WebSize& min_size, 80 const blink::WebSize& max_size); 81 void DisableAutoResizeMode(RenderView* render_view, 82 const blink::WebSize& new_size); 83 84 // Forces the |render_view| to use mock media streams. 85 void UseMockMediaStreams(RenderView* render_view); 86 87 } // namespace content 88 89 #endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_ 90