summaryrefslogtreecommitdiffstats
path: root/content/shell/renderer/test_runner/WebTestDelegate.h
blob: 6c7b199ef65eb6024c4da945e4347c8878e51288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_

#include <string>

#include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebVector.h"

#define WEBTESTRUNNER_NEW_HISTORY_CAPTURE

namespace blink {
class WebDeviceMotionData;
class WebDeviceOrientationData;
class WebFrame;
class WebGamepad;
class WebGamepads;
class WebHistoryItem;
struct WebRect;
struct WebSize;
struct WebURLError;
}

namespace content {
struct TestPreferences;
}

namespace WebTestRunner {

class WebTask;
class WebTestProxyBase;

class WebTestDelegate {
public:
    // Set and clear the edit command to execute on the next call to
    // WebViewClient::handleCurrentKeyboardEvent().
    virtual void clearEditCommand() = 0;
    virtual void setEditCommand(const std::string& name, const std::string& value) = 0;

    // Set the gamepads to return from Platform::sampleGamepads().
    virtual void setGamepadData(const blink::WebGamepads&) = 0;

    // Notifies blink about a new gamepad.
    virtual void didConnectGamepad(int index, const blink::WebGamepad&) = 0;

    // Notifies blink that a gamepad has been disconnected.
    virtual void didDisconnectGamepad(int index, const blink::WebGamepad&) = 0;

    // Set data to return when registering via Platform::setDeviceMotionListener().
    virtual void setDeviceMotionData(const blink::WebDeviceMotionData&) = 0;
    // Set data to return when registering via Platform::setDeviceOrientationListener().
    virtual void setDeviceOrientationData(const blink::WebDeviceOrientationData&) = 0;

    // Set orientation to set when registering via Platform::setScreenOrientationListener().
    virtual void setScreenOrientation(const blink::WebScreenOrientationType&) = 0;

    // Add a message to the text dump for the layout test.
    virtual void printMessage(const std::string& message) = 0;

    // The delegate takes ownership of the WebTask objects and is responsible
    // for deleting them.
    virtual void postTask(WebTask*) = 0;
    virtual void postDelayedTask(WebTask*, long long ms) = 0;

    // Register a new isolated filesystem with the given files, and return the
    // new filesystem id.
    virtual blink::WebString registerIsolatedFileSystem(const blink::WebVector<blink::WebString>& absoluteFilenames) = 0;

    // Gets the current time in milliseconds since the UNIX epoch.
    virtual long long getCurrentTimeInMillisecond() = 0;

    // Convert the provided relative path into an absolute path.
    virtual blink::WebString getAbsoluteWebStringFromUTF8Path(const std::string& path) = 0;

    // Reads in the given file and returns its contents as data URL.
    virtual blink::WebURL localFileToDataURL(const blink::WebURL&) = 0;

    // Replaces file:///tmp/LayoutTests/ with the actual path to the
    // LayoutTests directory.
    virtual blink::WebURL rewriteLayoutTestsURL(const std::string& utf8URL) = 0;

    // Manages the settings to used for layout tests.
    virtual content::TestPreferences* preferences() = 0;
    virtual void applyPreferences() = 0;

    // Enables or disables synchronous resize mode. When enabled, all window-sizing machinery is
    // short-circuited inside the renderer. This mode is necessary for some tests that were written
    // before browsers had multi-process architecture and rely on window resizes to happen synchronously.
    // The function has "unfortunate" it its name because we must strive to remove all tests
    // that rely on this... well, unfortunate behavior. See http://crbug.com/309760 for the plan.
    virtual void useUnfortunateSynchronousResizeMode(bool) = 0;

    // Controls auto resize mode.
    virtual void enableAutoResizeMode(const blink::WebSize& minSize, const blink::WebSize& maxSize) = 0;
    virtual void disableAutoResizeMode(const blink::WebSize&) = 0;

    // Clears DevTools' localStorage when an inspector test is started.
    virtual void clearDevToolsLocalStorage() = 0;

    // Opens and closes the inspector.
    virtual void showDevTools(const std::string& settings) = 0;
    virtual void closeDevTools() = 0;

    // Evaluate the given script in the DevTools agent.
    virtual void evaluateInWebInspector(long callID, const std::string& script) = 0;

    // Controls WebSQL databases.
    virtual void clearAllDatabases() = 0;
    virtual void setDatabaseQuota(int) = 0;

    // Controls the device scale factor of the main WebView for hidpi tests.
    virtual void setDeviceScaleFactor(float) = 0;

    // Controls which WebView should be focused.
    virtual void setFocus(WebTestProxyBase*, bool) = 0;

    // Controls whether all cookies should be accepted or writing cookies in a
    // third-party context is blocked.
    virtual void setAcceptAllCookies(bool) = 0;

    // The same as rewriteLayoutTestsURL unless the resource is a path starting
    // with /tmp/, then return a file URL to a temporary file.
    virtual std::string pathToLocalResource(const std::string& resource) = 0;

    // Sets the POSIX locale of the current process.
    virtual void setLocale(const std::string&) = 0;

    // Invoked when the test finished.
    virtual void testFinished() = 0;

    // Invoked when the embedder should close all but the main WebView.
    virtual void closeRemainingWindows() = 0;

    virtual void deleteAllCookies() = 0;

    // Returns the length of the back/forward history of the main WebView.
    virtual int navigationEntryCount() = 0;

    // The following trigger navigations on the main WebViwe.
    virtual void goToOffset(int offset) = 0;
    virtual void reload() = 0;
    virtual void loadURLForFrame(const blink::WebURL&, const std::string& frameName) = 0;

    // Returns true if resource requests to external URLs should be permitted.
    virtual bool allowExternalPages() = 0;

    // Returns the back/forward history for the WebView associated with the
    // given WebTestProxyBase as well as the index of the current entry.
    virtual void captureHistoryForWindow(WebTestProxyBase*, blink::WebVector<blink::WebHistoryItem>*, size_t* currentEntryIndex) = 0;
};

}

#endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEBTESTDELEGATE_H_