Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / content / shell / renderer / test_runner / web_test_delegate.h
blob35deb59ce854cfb04b885534ba069c1f952a4b52
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 CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_
8 #include <string>
10 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
11 #include "third_party/WebKit/public/platform/WebString.h"
12 #include "third_party/WebKit/public/platform/WebURL.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
15 #define WEBTESTRUNNER_NEW_HISTORY_CAPTURE
17 namespace blink {
18 class WebBatteryStatus;
19 class WebDeviceMotionData;
20 class WebDeviceOrientationData;
21 class WebFrame;
22 class WebGamepad;
23 class WebGamepads;
24 class WebHistoryItem;
25 struct WebRect;
26 struct WebSize;
27 struct WebURLError;
30 namespace content {
32 class DeviceLightData;
33 class RendererGamepadProvider;
34 class WebTask;
35 class WebTestProxyBase;
36 struct TestPreferences;
38 class WebTestDelegate {
39 public:
40 // Set and clear the edit command to execute on the next call to
41 // WebViewClient::handleCurrentKeyboardEvent().
42 virtual void ClearEditCommand() = 0;
43 virtual void SetEditCommand(const std::string& name,
44 const std::string& value) = 0;
46 // Sets gamepad provider to be used for tests.
47 virtual void SetGamepadProvider(
48 scoped_ptr<RendererGamepadProvider> provider) = 0;
50 // Set data to return when registering via
51 // Platform::setDeviceLightListener().
52 virtual void SetDeviceLightData(const double data) = 0;
53 // Set data to return when registering via
54 // Platform::setDeviceMotionListener().
55 virtual void SetDeviceMotionData(const blink::WebDeviceMotionData& data) = 0;
56 // Set data to return when registering via
57 // Platform::setDeviceOrientationListener().
58 virtual void SetDeviceOrientationData(
59 const blink::WebDeviceOrientationData& data) = 0;
61 // Set orientation to set when registering via
62 // Platform::setScreenOrientationListener().
63 virtual void SetScreenOrientation(
64 const blink::WebScreenOrientationType& orientation) = 0;
66 // Reset the screen orientation data used for testing.
67 virtual void ResetScreenOrientation() = 0;
69 // Notifies blink about a change in battery status.
70 virtual void DidChangeBatteryStatus(
71 const blink::WebBatteryStatus& status) = 0;
73 // Sets second screen availability for the Presentation API.
74 virtual void SetScreenAvailability(bool available) = 0;
76 // Resets the Presentation API client for testing.
77 virtual void ResetPresentationService() = 0;
79 // Add a message to the text dump for the layout test.
80 virtual void PrintMessage(const std::string& message) = 0;
82 // The delegate takes ownership of the WebTask objects and is responsible
83 // for deleting them.
84 virtual void PostTask(WebTask* task) = 0;
85 virtual void PostDelayedTask(WebTask* task, long long ms) = 0;
87 // Register a new isolated filesystem with the given files, and return the
88 // new filesystem id.
89 virtual blink::WebString RegisterIsolatedFileSystem(
90 const blink::WebVector<blink::WebString>& absolute_filenames) = 0;
92 // Gets the current time in milliseconds since the UNIX epoch.
93 virtual long long GetCurrentTimeInMillisecond() = 0;
95 // Convert the provided relative path into an absolute path.
96 virtual blink::WebString GetAbsoluteWebStringFromUTF8Path(
97 const std::string& path) = 0;
99 // Reads in the given file and returns its contents as data URL.
100 virtual blink::WebURL LocalFileToDataURL(const blink::WebURL& file_url) = 0;
102 // Replaces file:///tmp/LayoutTests/ with the actual path to the
103 // LayoutTests directory.
104 virtual blink::WebURL RewriteLayoutTestsURL(const std::string& utf8_url) = 0;
106 // Manages the settings to used for layout tests.
107 virtual TestPreferences* Preferences() = 0;
108 virtual void ApplyPreferences() = 0;
110 // Enables or disables synchronous resize mode. When enabled, all
111 // window-sizing machinery is
112 // short-circuited inside the renderer. This mode is necessary for some tests
113 // that were written
114 // before browsers had multi-process architecture and rely on window resizes
115 // to happen synchronously.
116 // The function has "unfortunate" it its name because we must strive to remove
117 // all tests
118 // that rely on this... well, unfortunate behavior. See
119 // http://crbug.com/309760 for the plan.
120 virtual void UseUnfortunateSynchronousResizeMode(bool enable) = 0;
122 // Controls auto resize mode.
123 virtual void EnableAutoResizeMode(const blink::WebSize& min_size,
124 const blink::WebSize& max_size) = 0;
125 virtual void DisableAutoResizeMode(const blink::WebSize& new_size) = 0;
127 // Clears DevTools' localStorage when an inspector test is started.
128 virtual void ClearDevToolsLocalStorage() = 0;
130 // Opens and closes the inspector.
131 virtual void ShowDevTools(const std::string& settings,
132 const std::string& frontend_url) = 0;
133 virtual void CloseDevTools() = 0;
135 // Evaluate the given script in the DevTools agent.
136 virtual void EvaluateInWebInspector(long call_id,
137 const std::string& script) = 0;
139 // Controls WebSQL databases.
140 virtual void ClearAllDatabases() = 0;
141 virtual void SetDatabaseQuota(int quota) = 0;
143 // Controls Web Notifications.
144 virtual void GrantWebNotificationPermission(const GURL& origin,
145 bool permission_granted) = 0;
146 virtual void ClearWebNotificationPermissions() = 0;
147 virtual void SimulateWebNotificationClick(const std::string& title) = 0;
149 // Controls the Push API.
150 virtual void SetPushMessagingPermission(const GURL& origin, bool allowed) = 0;
151 virtual void ClearPushMessagingPermissions() = 0;
153 // Controls the device scale factor of the main WebView for hidpi tests.
154 virtual void SetDeviceScaleFactor(float factor) = 0;
156 // Change the device color profile while running a layout test.
157 virtual void SetDeviceColorProfile(const std::string& name) = 0;
159 // Change the bluetooth test data while running a layout test.
160 virtual void SetBluetoothMockDataSet(const std::string& data_set) = 0;
162 // Enables mock geofencing service while running a layout test.
163 // |service_available| indicates if the mock service should mock geofencing
164 // being available or not.
165 virtual void SetGeofencingMockProvider(bool service_available) = 0;
167 // Disables mock geofencing service while running a layout test.
168 virtual void ClearGeofencingMockProvider() = 0;
170 // Set the mock geofencing position while running a layout test.
171 virtual void SetGeofencingMockPosition(double latitude, double longitude) = 0;
173 // Controls which WebView should be focused.
174 virtual void SetFocus(WebTestProxyBase* proxy, bool focus) = 0;
176 // Controls whether all cookies should be accepted or writing cookies in a
177 // third-party context is blocked.
178 virtual void SetAcceptAllCookies(bool accept) = 0;
180 // The same as RewriteLayoutTestsURL unless the resource is a path starting
181 // with /tmp/, then return a file URL to a temporary file.
182 virtual std::string PathToLocalResource(const std::string& resource) = 0;
184 // Sets the POSIX locale of the current process.
185 virtual void SetLocale(const std::string& locale) = 0;
187 // Invoked when the test finished.
188 virtual void TestFinished() = 0;
190 // Invoked when the embedder should close all but the main WebView.
191 virtual void CloseRemainingWindows() = 0;
193 virtual void DeleteAllCookies() = 0;
195 // Returns the length of the back/forward history of the main WebView.
196 virtual int NavigationEntryCount() = 0;
198 // The following trigger navigations on the main WebViwe.
199 virtual void GoToOffset(int offset) = 0;
200 virtual void Reload() = 0;
201 virtual void LoadURLForFrame(const blink::WebURL& url,
202 const std::string& frame_name) = 0;
204 // Returns true if resource requests to external URLs should be permitted.
205 virtual bool AllowExternalPages() = 0;
207 // Returns a text dump the back/forward history for the WebView associated
208 // with the given WebTestProxyBase.
209 virtual std::string DumpHistoryForWindow(WebTestProxyBase* proxy) = 0;
212 } // namespace content
214 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_TEST_DELEGATE_H_