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