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 WebKit { 11 class WebDeviceMotionData; 12 class WebGamepads; 13 struct WebSize; 14 } 15 16 namespace WebTestRunner { 17 class WebTestProxyBase; 18 } 19 20 namespace content { 21 22 class RenderView; 23 24 // Turn the browser process into layout test mode. 25 void EnableBrowserLayoutTestMode(); 26 27 /////////////////////////////////////////////////////////////////////////////// 28 // The following methods are meant to be used from a renderer. 29 30 // Turn a renderer into layout test mode. 31 void EnableRendererLayoutTestMode(); 32 33 // Enable injecting of a WebTestProxy between WebViews and RenderViews. 34 // |callback| is invoked with a pointer to WebTestProxyBase for each created 35 // WebTestProxy. 36 void EnableWebTestProxyCreation(const base::Callback< 37 void(RenderView*, WebTestRunner::WebTestProxyBase*)>& callback); 38 39 // Sets the WebGamepads that should be returned by 40 // WebKitPlatformSupport::sampleGamepads(). 41 void SetMockGamepads(const WebKit::WebGamepads& pads); 42 43 // Sets WebDeviceMotionData that should be used when registering 44 // a listener through WebKitPlatformSupport::setDeviceMotionListener(). 45 void SetMockDeviceMotionData(const WebKit::WebDeviceMotionData& data); 46 47 // Returns the length of the local session history of a render view. 48 int GetLocalSessionHistoryLength(RenderView* render_view); 49 50 // Sync the current session history to the browser process. 51 void SyncNavigationState(RenderView* render_view); 52 53 // Sets the focus of the render view depending on |enable|. This only overrides 54 // the state of the renderer, and does not sync the focus to the browser 55 // process. 56 void SetFocusAndActivate(RenderView* render_view, bool enable); 57 58 // Changes the window rect of the given render view. 59 void ForceResizeRenderView(RenderView* render_view, 60 const WebKit::WebSize& new_size); 61 62 // Set the device scale factor and force the compositor to resize. 63 void SetDeviceScaleFactor(RenderView* render_view, float factor); 64 65 // Control auto resize mode. 66 void EnableAutoResizeMode(RenderView* render_view, 67 const WebKit::WebSize& min_size, 68 const WebKit::WebSize& max_size); 69 void DisableAutoResizeMode(RenderView* render_view, 70 const WebKit::WebSize& new_size); 71 72 // Forces the |render_view| to use mock media streams. 73 void UseMockMediaStreams(RenderView* render_view); 74 75 } // namespace content 76 77 #endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_ 78