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_WEBTESTDELEGATE_H_
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_
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
18 class WebDeviceMotionData;
19 class WebDeviceOrientationData;
32 class WebTestProxyBase;
33 struct TestPreferences;
35 class WebTestDelegate {
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;
42 // Set the gamepads to return from Platform::sampleGamepads().
43 virtual void setGamepadData(const blink::WebGamepads&) = 0;
45 // Notifies blink about a new gamepad.
46 virtual void didConnectGamepad(int index, const blink::WebGamepad&) = 0;
48 // Notifies blink that a gamepad has been disconnected.
49 virtual void didDisconnectGamepad(int index, const blink::WebGamepad&) = 0;
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;
56 // Set orientation to set when registering via Platform::setScreenOrientationListener().
57 virtual void setScreenOrientation(const blink::WebScreenOrientationType&) = 0;
59 // Add a message to the text dump for the layout test.
60 virtual void printMessage(const std::string& message) = 0;
62 // The delegate takes ownership of the WebTask objects and is responsible
64 virtual void postTask(WebTask*) = 0;
65 virtual void postDelayedTask(WebTask*, long long ms) = 0;
67 // Register a new isolated filesystem with the given files, and return the
69 virtual blink::WebString registerIsolatedFileSystem(const blink::WebVector<blink::WebString>& absoluteFilenames) = 0;
71 // Gets the current time in milliseconds since the UNIX epoch.
72 virtual long long getCurrentTimeInMillisecond() = 0;
74 // Convert the provided relative path into an absolute path.
75 virtual blink::WebString getAbsoluteWebStringFromUTF8Path(const std::string& path) = 0;
77 // Reads in the given file and returns its contents as data URL.
78 virtual blink::WebURL localFileToDataURL(const blink::WebURL&) = 0;
80 // Replaces file:///tmp/LayoutTests/ with the actual path to the
81 // LayoutTests directory.
82 virtual blink::WebURL rewriteLayoutTestsURL(const std::string& utf8URL) = 0;
84 // Manages the settings to used for layout tests.
85 virtual TestPreferences* preferences() = 0;
86 virtual void applyPreferences() = 0;
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;
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;
99 // Clears DevTools' localStorage when an inspector test is started.
100 virtual void clearDevToolsLocalStorage() = 0;
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;
107 // Evaluate the given script in the DevTools agent.
108 virtual void evaluateInWebInspector(long callID, const std::string& script) = 0;
110 // Controls WebSQL databases.
111 virtual void clearAllDatabases() = 0;
112 virtual void setDatabaseQuota(int) = 0;
114 // Controls the device scale factor of the main WebView for hidpi tests.
115 virtual void setDeviceScaleFactor(float) = 0;
117 // Change the device color profile while running a layout test.
118 virtual void setDeviceColorProfile(const std::string& name) = 0;
120 // Controls which WebView should be focused.
121 virtual void setFocus(WebTestProxyBase*, bool) = 0;
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;
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;
131 // Sets the POSIX locale of the current process.
132 virtual void setLocale(const std::string&) = 0;
134 // Invoked when the test finished.
135 virtual void testFinished() = 0;
137 // Invoked when the embedder should close all but the main WebView.
138 virtual void closeRemainingWindows() = 0;
140 virtual void deleteAllCookies() = 0;
142 // Returns the length of the back/forward history of the main WebView.
143 virtual int navigationEntryCount() = 0;
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;
150 // Returns true if resource requests to external URLs should be permitted.
151 virtual bool allowExternalPages() = 0;
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;
158 } // namespace content
160 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_