| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_ | |
| 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" | |
| 14 #include "third_party/WebKit/public/platform/WebString.h" | |
| 15 #include "third_party/WebKit/public/platform/WebURL.h" | |
| 16 #include "third_party/WebKit/public/platform/WebVector.h" | |
| 17 | |
| 18 #define WEBTESTRUNNER_NEW_HISTORY_CAPTURE | |
| 19 | |
| 20 namespace blink { | |
| 21 class WebBatteryStatus; | |
| 22 class WebDeviceMotionData; | |
| 23 class WebDeviceOrientationData; | |
| 24 class WebFrame; | |
| 25 class WebGamepad; | |
| 26 class WebGamepads; | |
| 27 class WebHistoryItem; | |
| 28 class WebLayer; | |
| 29 class WebLocalFrame; | |
| 30 class WebPlugin; | |
| 31 struct WebPluginParams; | |
| 32 class WebURLResponse; | |
| 33 class WebView; | |
| 34 struct WebRect; | |
| 35 struct WebSize; | |
| 36 struct WebURLError; | |
| 37 } | |
| 38 | |
| 39 namespace cc { | |
| 40 class TextureLayer; | |
| 41 class TextureLayerClient; | |
| 42 class SharedBitmapManager; | |
| 43 } | |
| 44 | |
| 45 namespace content { | |
| 46 | |
| 47 class DeviceLightData; | |
| 48 class GamepadController; | |
| 49 class WebTask; | |
| 50 class WebTestProxyBase; | |
| 51 struct TestPreferences; | |
| 52 | |
| 53 class WebTestDelegate { | |
| 54 public: | |
| 55 // Set and clear the edit command to execute on the next call to | |
| 56 // WebViewClient::handleCurrentKeyboardEvent(). | |
| 57 virtual void ClearEditCommand() = 0; | |
| 58 virtual void SetEditCommand(const std::string& name, | |
| 59 const std::string& value) = 0; | |
| 60 | |
| 61 // Sets gamepad provider to be used for tests. | |
| 62 virtual void SetGamepadProvider(GamepadController* controller) = 0; | |
| 63 | |
| 64 // Set data to return when registering via | |
| 65 // Platform::setDeviceLightListener(). | |
| 66 virtual void SetDeviceLightData(const double data) = 0; | |
| 67 // Set data to return when registering via | |
| 68 // Platform::setDeviceMotionListener(). | |
| 69 virtual void SetDeviceMotionData(const blink::WebDeviceMotionData& data) = 0; | |
| 70 // Set data to return when registering via | |
| 71 // Platform::setDeviceOrientationListener(). | |
| 72 virtual void SetDeviceOrientationData( | |
| 73 const blink::WebDeviceOrientationData& data) = 0; | |
| 74 | |
| 75 // Set orientation to set when registering via | |
| 76 // Platform::setScreenOrientationListener(). | |
| 77 virtual void SetScreenOrientation( | |
| 78 const blink::WebScreenOrientationType& orientation) = 0; | |
| 79 | |
| 80 // Reset the screen orientation data used for testing. | |
| 81 virtual void ResetScreenOrientation() = 0; | |
| 82 | |
| 83 // Notifies blink about a change in battery status. | |
| 84 virtual void DidChangeBatteryStatus( | |
| 85 const blink::WebBatteryStatus& status) = 0; | |
| 86 | |
| 87 // Add a message to the text dump for the layout test. | |
| 88 virtual void PrintMessage(const std::string& message) = 0; | |
| 89 | |
| 90 // The delegate takes ownership of the WebTask objects and is responsible | |
| 91 // for deleting them. | |
| 92 virtual void PostTask(WebTask* task) = 0; | |
| 93 virtual void PostDelayedTask(WebTask* task, long long ms) = 0; | |
| 94 | |
| 95 // Register a new isolated filesystem with the given files, and return the | |
| 96 // new filesystem id. | |
| 97 virtual blink::WebString RegisterIsolatedFileSystem( | |
| 98 const blink::WebVector<blink::WebString>& absolute_filenames) = 0; | |
| 99 | |
| 100 // Gets the current time in milliseconds since the UNIX epoch. | |
| 101 virtual long long GetCurrentTimeInMillisecond() = 0; | |
| 102 | |
| 103 // Convert the provided relative path into an absolute path. | |
| 104 virtual blink::WebString GetAbsoluteWebStringFromUTF8Path( | |
| 105 const std::string& path) = 0; | |
| 106 | |
| 107 // Reads in the given file and returns its contents as data URL. | |
| 108 virtual blink::WebURL LocalFileToDataURL(const blink::WebURL& file_url) = 0; | |
| 109 | |
| 110 // Replaces file:///tmp/LayoutTests/ with the actual path to the | |
| 111 // LayoutTests directory. | |
| 112 virtual blink::WebURL RewriteLayoutTestsURL(const std::string& utf8_url) = 0; | |
| 113 | |
| 114 // Manages the settings to used for layout tests. | |
| 115 virtual TestPreferences* Preferences() = 0; | |
| 116 virtual void ApplyPreferences() = 0; | |
| 117 | |
| 118 // Enables or disables synchronous resize mode. When enabled, all | |
| 119 // window-sizing machinery is | |
| 120 // short-circuited inside the renderer. This mode is necessary for some tests | |
| 121 // that were written | |
| 122 // before browsers had multi-process architecture and rely on window resizes | |
| 123 // to happen synchronously. | |
| 124 // The function has "unfortunate" it its name because we must strive to remove | |
| 125 // all tests | |
| 126 // that rely on this... well, unfortunate behavior. See | |
| 127 // http://crbug.com/309760 for the plan. | |
| 128 virtual void UseUnfortunateSynchronousResizeMode(bool enable) = 0; | |
| 129 | |
| 130 // Controls auto resize mode. | |
| 131 virtual void EnableAutoResizeMode(const blink::WebSize& min_size, | |
| 132 const blink::WebSize& max_size) = 0; | |
| 133 virtual void DisableAutoResizeMode(const blink::WebSize& new_size) = 0; | |
| 134 | |
| 135 // Clears DevTools' localStorage when an inspector test is started. | |
| 136 virtual void ClearDevToolsLocalStorage() = 0; | |
| 137 | |
| 138 // Opens and closes the inspector. | |
| 139 virtual void ShowDevTools(const std::string& settings, | |
| 140 const std::string& frontend_url) = 0; | |
| 141 virtual void CloseDevTools() = 0; | |
| 142 | |
| 143 // Evaluate the given script in the DevTools agent. | |
| 144 virtual void EvaluateInWebInspector(long call_id, | |
| 145 const std::string& script) = 0; | |
| 146 | |
| 147 // Controls WebSQL databases. | |
| 148 virtual void ClearAllDatabases() = 0; | |
| 149 virtual void SetDatabaseQuota(int quota) = 0; | |
| 150 | |
| 151 // Controls Web Notifications. | |
| 152 virtual void SimulateWebNotificationClick(const std::string& title) = 0; | |
| 153 | |
| 154 // Controls the device scale factor of the main WebView for hidpi tests. | |
| 155 virtual void SetDeviceScaleFactor(float factor) = 0; | |
| 156 | |
| 157 // Change the device color profile while running a layout test. | |
| 158 virtual void SetDeviceColorProfile(const std::string& name) = 0; | |
| 159 | |
| 160 // Change the bluetooth test data while running a layout test. | |
| 161 virtual void SetBluetoothMockDataSet(const std::string& data_set) = 0; | |
| 162 | |
| 163 // Enables mock geofencing service while running a layout test. | |
| 164 // |service_available| indicates if the mock service should mock geofencing | |
| 165 // being available or not. | |
| 166 virtual void SetGeofencingMockProvider(bool service_available) = 0; | |
| 167 | |
| 168 // Disables mock geofencing service while running a layout test. | |
| 169 virtual void ClearGeofencingMockProvider() = 0; | |
| 170 | |
| 171 // Set the mock geofencing position while running a layout test. | |
| 172 virtual void SetGeofencingMockPosition(double latitude, double longitude) = 0; | |
| 173 | |
| 174 // Controls which WebView should be focused. | |
| 175 virtual void SetFocus(WebTestProxyBase* proxy, bool focus) = 0; | |
| 176 | |
| 177 // Controls whether all cookies should be accepted or writing cookies in a | |
| 178 // third-party context is blocked. | |
| 179 virtual void SetAcceptAllCookies(bool accept) = 0; | |
| 180 | |
| 181 // The same as RewriteLayoutTestsURL unless the resource is a path starting | |
| 182 // with /tmp/, then return a file URL to a temporary file. | |
| 183 virtual std::string PathToLocalResource(const std::string& resource) = 0; | |
| 184 | |
| 185 // Sets the POSIX locale of the current process. | |
| 186 virtual void SetLocale(const std::string& locale) = 0; | |
| 187 | |
| 188 // Invoked when the test finished. | |
| 189 virtual void TestFinished() = 0; | |
| 190 | |
| 191 // Invoked when the embedder should close all but the main WebView. | |
| 192 virtual void CloseRemainingWindows() = 0; | |
| 193 | |
| 194 virtual void DeleteAllCookies() = 0; | |
| 195 | |
| 196 // Returns the length of the back/forward history of the main WebView. | |
| 197 virtual int NavigationEntryCount() = 0; | |
| 198 | |
| 199 // The following trigger navigations on the main WebViwe. | |
| 200 virtual void GoToOffset(int offset) = 0; | |
| 201 virtual void Reload() = 0; | |
| 202 virtual void LoadURLForFrame(const blink::WebURL& url, | |
| 203 const std::string& frame_name) = 0; | |
| 204 | |
| 205 // Returns true if resource requests to external URLs should be permitted. | |
| 206 virtual bool AllowExternalPages() = 0; | |
| 207 | |
| 208 // Returns a text dump the back/forward history for the WebView associated | |
| 209 // with the given WebTestProxyBase. | |
| 210 virtual std::string DumpHistoryForWindow(WebTestProxyBase* proxy) = 0; | |
| 211 | |
| 212 // Fetch the manifest for a given WebView from the given url. | |
| 213 virtual void FetchManifest( | |
| 214 blink::WebView* view, | |
| 215 const GURL& url, | |
| 216 const base::Callback<void(const blink::WebURLResponse& response, | |
| 217 const std::string& data)>& callback) = 0; | |
| 218 | |
| 219 // Sends a message to the LayoutTestPermissionManager in order for it to | |
| 220 // update its database. | |
| 221 virtual void SetPermission(const std::string& permission_name, | |
| 222 const std::string& permission_value, | |
| 223 const GURL& origin, | |
| 224 const GURL& embedding_origin) = 0; | |
| 225 | |
| 226 // Clear all the permissions set via SetPermission(). | |
| 227 virtual void ResetPermissions() = 0; | |
| 228 | |
| 229 // Creates cc::TextureLayer for TestPlugin. | |
| 230 virtual scoped_refptr<cc::TextureLayer> CreateTextureLayerForMailbox( | |
| 231 cc::TextureLayerClient* client) = 0; | |
| 232 | |
| 233 // Instantiates WebLayerImpl for TestPlugin. | |
| 234 virtual blink::WebLayer* InstantiateWebLayer( | |
| 235 scoped_refptr<cc::TextureLayer> layer) = 0; | |
| 236 | |
| 237 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | |
| 238 | |
| 239 // Causes the beforeinstallprompt event to be sent to the renderer with a | |
| 240 // request id of |request_id|. |event_platforms| are the platforms to be sent | |
| 241 // with the event. Once the event listener completes, |callback| will be | |
| 242 // called with a boolean argument. This argument will be true if the event is | |
| 243 // canceled, and false otherwise. | |
| 244 virtual void DispatchBeforeInstallPromptEvent( | |
| 245 int request_id, | |
| 246 const std::vector<std::string>& event_platforms, | |
| 247 const base::Callback<void(bool)>& callback) = 0; | |
| 248 | |
| 249 // Resolve the promise associated with the beforeinstallprompt even with | |
| 250 // request id |request_id|. The promise is resolved with a result.platform set | |
| 251 // to |platform|. If |platform| is not empty, result.outcome will be | |
| 252 // 'accepted', otherwise it will be 'dismissed'. | |
| 253 virtual void ResolveBeforeInstallPromptPromise( | |
| 254 int request_id, | |
| 255 const std::string& platform) = 0; | |
| 256 | |
| 257 virtual blink::WebPlugin* CreatePluginPlaceholder( | |
| 258 blink::WebLocalFrame* frame, | |
| 259 const blink::WebPluginParams& params) = 0; | |
| 260 }; | |
| 261 | |
| 262 } // namespace content | |
| 263 | |
| 264 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_ | |
| OLD | NEW |