Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / components / test_runner / web_test_delegate.h
bloba1bc3c38d6291d4d52f9a24e976099f87cd51d0a
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.
5 #ifndef COMPONENTS_TEST_RUNNER_WEB_TEST_DELEGATE_H_
6 #define COMPONENTS_TEST_RUNNER_WEB_TEST_DELEGATE_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback_forward.h"
12 #include "base/memory/ref_counted.h"
13 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "third_party/WebKit/public/platform/WebURL.h"
15 #include "third_party/WebKit/public/platform/WebVector.h"
16 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationType.h"
18 #define WEBTESTRUNNER_NEW_HISTORY_CAPTURE
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;
39 namespace cc {
40 class TextureLayer;
41 class TextureLayerClient;
42 class SharedBitmapManager;
45 namespace test_runner {
47 class DeviceLightData;
48 class GamepadController;
49 class WebTask;
50 class WebTestProxyBase;
51 struct TestPreferences;
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;
61 // Sets gamepad provider to be used for tests.
62 virtual void SetGamepadProvider(GamepadController* controller) = 0;
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;
75 // Set orientation to set when registering via
76 // Platform::setScreenOrientationListener().
77 virtual void SetScreenOrientation(
78 const blink::WebScreenOrientationType& orientation) = 0;
80 // Reset the screen orientation data used for testing.
81 virtual void ResetScreenOrientation() = 0;
83 // Notifies blink about a change in battery status.
84 virtual void DidChangeBatteryStatus(
85 const blink::WebBatteryStatus& status) = 0;
87 // Add a message to the text dump for the layout test.
88 virtual void PrintMessage(const std::string& message) = 0;
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;
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;
100 // Gets the current time in milliseconds since the UNIX epoch.
101 virtual long long GetCurrentTimeInMillisecond() = 0;
103 // Convert the provided relative path into an absolute path.
104 virtual blink::WebString GetAbsoluteWebStringFromUTF8Path(
105 const std::string& path) = 0;
107 // Reads in the given file and returns its contents as data URL.
108 virtual blink::WebURL LocalFileToDataURL(const blink::WebURL& file_url) = 0;
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;
114 // Manages the settings to used for layout tests.
115 virtual TestPreferences* Preferences() = 0;
116 virtual void ApplyPreferences() = 0;
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;
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;
135 // Clears DevTools' localStorage when an inspector test is started.
136 virtual void ClearDevToolsLocalStorage() = 0;
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;
143 // Evaluate the given script in the DevTools agent.
144 virtual void EvaluateInWebInspector(long call_id,
145 const std::string& script) = 0;
147 // Controls WebSQL databases.
148 virtual void ClearAllDatabases() = 0;
149 virtual void SetDatabaseQuota(int quota) = 0;
151 // Controls Web Notifications.
152 virtual void SimulateWebNotificationClick(const std::string& title) = 0;
154 // Controls the device scale factor of the main WebView for hidpi tests.
155 virtual void SetDeviceScaleFactor(float factor) = 0;
157 // Change the device color profile while running a layout test.
158 virtual void SetDeviceColorProfile(const std::string& name) = 0;
160 // Change the bluetooth test data while running a layout test.
161 virtual void SetBluetoothMockDataSet(const std::string& data_set) = 0;
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;
168 // Disables mock geofencing service while running a layout test.
169 virtual void ClearGeofencingMockProvider() = 0;
171 // Set the mock geofencing position while running a layout test.
172 virtual void SetGeofencingMockPosition(double latitude, double longitude) = 0;
174 // Controls which WebView should be focused.
175 virtual void SetFocus(WebTestProxyBase* proxy, bool focus) = 0;
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;
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;
185 // Sets the POSIX locale of the current process.
186 virtual void SetLocale(const std::string& locale) = 0;
188 // Invoked when the test finished.
189 virtual void TestFinished() = 0;
191 // Invoked when the embedder should close all but the main WebView.
192 virtual void CloseRemainingWindows() = 0;
194 virtual void DeleteAllCookies() = 0;
196 // Returns the length of the back/forward history of the main WebView.
197 virtual int NavigationEntryCount() = 0;
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;
205 // Returns true if resource requests to external URLs should be permitted.
206 virtual bool AllowExternalPages() = 0;
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;
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;
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;
226 // Clear all the permissions set via SetPermission().
227 virtual void ResetPermissions() = 0;
229 // Creates cc::TextureLayer for TestPlugin.
230 virtual scoped_refptr<cc::TextureLayer> CreateTextureLayerForMailbox(
231 cc::TextureLayerClient* client) = 0;
233 // Instantiates WebLayerImpl for TestPlugin.
234 virtual blink::WebLayer* InstantiateWebLayer(
235 scoped_refptr<cc::TextureLayer> layer) = 0;
237 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0;
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;
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;
257 virtual blink::WebPlugin* CreatePluginPlaceholder(
258 blink::WebLocalFrame* frame,
259 const blink::WebPluginParams& params) = 0;
262 } // namespace test_runner
264 #endif // COMPONENTS_TEST_RUNNER_WEB_TEST_DELEGATE_H_