Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / renderer / test_runner / WebTestDelegate.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_WEBTESTDELEGATE_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_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
15 #define WEBTESTRUNNER_NEW_HISTORY_CAPTURE
16
17 namespace blink {
18 class WebDeviceMotionData;
19 class WebDeviceOrientationData;
20 class WebFrame;
21 class WebGamepad;
22 class WebGamepads;
23 class WebHistoryItem;
24 struct WebRect;
25 struct WebSize;
26 struct WebURLError;
27 }
28
29 namespace content {
30
31 class WebTask;
32 class WebTestProxyBase;
33 struct TestPreferences;
34
35 class WebTestDelegate {
36 public:
37     // Set and clear the edit command to execute on the next call to
38     // WebViewClient::handleCurrentKeyboardEvent().
39     virtual void clearEditCommand() = 0;
40     virtual void setEditCommand(const std::string& name, const std::string& value) = 0;
41
42     // Set the gamepads to return from Platform::sampleGamepads().
43     virtual void setGamepadData(const blink::WebGamepads&) = 0;
44
45     // Notifies blink about a new gamepad.
46     virtual void didConnectGamepad(int index, const blink::WebGamepad&) = 0;
47
48     // Notifies blink that a gamepad has been disconnected.
49     virtual void didDisconnectGamepad(int index, const blink::WebGamepad&) = 0;
50
51     // Set data to return when registering via Platform::setDeviceMotionListener().
52     virtual void setDeviceMotionData(const blink::WebDeviceMotionData&) = 0;
53     // Set data to return when registering via Platform::setDeviceOrientationListener().
54     virtual void setDeviceOrientationData(const blink::WebDeviceOrientationData&) = 0;
55
56     // Set orientation to set when registering via Platform::setScreenOrientationListener().
57     virtual void setScreenOrientation(const blink::WebScreenOrientationType&) = 0;
58
59     // Add a message to the text dump for the layout test.
60     virtual void printMessage(const std::string& message) = 0;
61
62     // The delegate takes ownership of the WebTask objects and is responsible
63     // for deleting them.
64     virtual void postTask(WebTask*) = 0;
65     virtual void postDelayedTask(WebTask*, long long ms) = 0;
66
67     // Register a new isolated filesystem with the given files, and return the
68     // new filesystem id.
69     virtual blink::WebString registerIsolatedFileSystem(const blink::WebVector<blink::WebString>& absoluteFilenames) = 0;
70
71     // Gets the current time in milliseconds since the UNIX epoch.
72     virtual long long getCurrentTimeInMillisecond() = 0;
73
74     // Convert the provided relative path into an absolute path.
75     virtual blink::WebString getAbsoluteWebStringFromUTF8Path(const std::string& path) = 0;
76
77     // Reads in the given file and returns its contents as data URL.
78     virtual blink::WebURL localFileToDataURL(const blink::WebURL&) = 0;
79
80     // Replaces file:///tmp/LayoutTests/ with the actual path to the
81     // LayoutTests directory.
82     virtual blink::WebURL rewriteLayoutTestsURL(const std::string& utf8URL) = 0;
83
84     // Manages the settings to used for layout tests.
85     virtual TestPreferences* preferences() = 0;
86     virtual void applyPreferences() = 0;
87
88     // Enables or disables synchronous resize mode. When enabled, all window-sizing machinery is
89     // short-circuited inside the renderer. This mode is necessary for some tests that were written
90     // before browsers had multi-process architecture and rely on window resizes to happen synchronously.
91     // The function has "unfortunate" it its name because we must strive to remove all tests
92     // that rely on this... well, unfortunate behavior. See http://crbug.com/309760 for the plan.
93     virtual void useUnfortunateSynchronousResizeMode(bool) = 0;
94
95     // Controls auto resize mode.
96     virtual void enableAutoResizeMode(const blink::WebSize& minSize, const blink::WebSize& maxSize) = 0;
97     virtual void disableAutoResizeMode(const blink::WebSize&) = 0;
98
99     // Clears DevTools' localStorage when an inspector test is started.
100     virtual void clearDevToolsLocalStorage() = 0;
101
102     // Opens and closes the inspector.
103     virtual void showDevTools(const std::string& settings,
104                               const std::string& frontend_url) = 0;
105     virtual void closeDevTools() = 0;
106
107     // Evaluate the given script in the DevTools agent.
108     virtual void evaluateInWebInspector(long callID, const std::string& script) = 0;
109
110     // Controls WebSQL databases.
111     virtual void clearAllDatabases() = 0;
112     virtual void setDatabaseQuota(int) = 0;
113
114     // Controls the device scale factor of the main WebView for hidpi tests.
115     virtual void setDeviceScaleFactor(float) = 0;
116
117     // Change the device color profile while running a layout test.
118     virtual void setDeviceColorProfile(const std::string& name) = 0;
119
120     // Controls which WebView should be focused.
121     virtual void setFocus(WebTestProxyBase*, bool) = 0;
122
123     // Controls whether all cookies should be accepted or writing cookies in a
124     // third-party context is blocked.
125     virtual void setAcceptAllCookies(bool) = 0;
126
127     // The same as rewriteLayoutTestsURL unless the resource is a path starting
128     // with /tmp/, then return a file URL to a temporary file.
129     virtual std::string pathToLocalResource(const std::string& resource) = 0;
130
131     // Sets the POSIX locale of the current process.
132     virtual void setLocale(const std::string&) = 0;
133
134     // Invoked when the test finished.
135     virtual void testFinished() = 0;
136
137     // Invoked when the embedder should close all but the main WebView.
138     virtual void closeRemainingWindows() = 0;
139
140     virtual void deleteAllCookies() = 0;
141
142     // Returns the length of the back/forward history of the main WebView.
143     virtual int navigationEntryCount() = 0;
144
145     // The following trigger navigations on the main WebViwe.
146     virtual void goToOffset(int offset) = 0;
147     virtual void reload() = 0;
148     virtual void loadURLForFrame(const blink::WebURL&, const std::string& frameName) = 0;
149
150     // Returns true if resource requests to external URLs should be permitted.
151     virtual bool allowExternalPages() = 0;
152
153     // Returns a text dump the back/forward history for the WebView associated
154     // with the given WebTestProxyBase.
155     virtual std::string dumpHistoryForWindow(WebTestProxyBase*) = 0;
156 };
157
158 }  // namespace content
159
160 #endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_