Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: components/test_runner/test_runner_for_specific_view.h

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 COMPONENTS_TEST_RUNNER_TEST_RUNNER_FOR_SPECIFIC_VIEW_H_
6 #define COMPONENTS_TEST_RUNNER_TEST_RUNNER_FOR_SPECIFIC_VIEW_H_
7
8 #include <stdint.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/callback_forward.h"
14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h"
16 #include "v8/include/v8.h"
17
18 class SkBitmap;
19
20 namespace blink {
21 class WebLocalFrame;
22 class WebURLResponse;
23 class WebView;
24 }
25
26 namespace gin {
27 class Arguments;
28 }
29
30 namespace test_runner {
31
32 class WebTestDelegate;
33 class WebViewTestProxyBase;
34
35 // TestRunnerForSpecificView implements part of |testRunner| javascript bindings
36 // that work with a view where the javascript call originated from. Examples:
37 // - testRunner.capturePixelsAsyncThen
38 // - testRunner.setPageVisibility
39 // Note that "global" bindings are handled by TestRunner class.
40 class TestRunnerForSpecificView {
41 public:
42 explicit TestRunnerForSpecificView(
43 WebViewTestProxyBase* web_view_test_proxy_base);
44 ~TestRunnerForSpecificView();
45
46 // Installs view-specific bindings (handled by |this|) and *also* global
47 // TestRunner bindings (both kinds of bindings are exposed via a single
48 // |testRunner| object in javascript).
49 void Install(blink::WebLocalFrame* frame);
50
51 void Reset();
52
53 // Pointer lock methods used by WebViewTestClient.
54 bool RequestPointerLock();
55 void RequestPointerUnlock();
56 bool isPointerLocked();
57
58 private:
59 friend class TestRunnerBindings;
60
61 // Helpers for working with base and V8 callbacks.
62 void PostTask(const base::Closure& callback);
63 void PostDelayedTask(long long delay, const base::Closure& callback);
64 void PostV8Callback(const v8::Local<v8::Function>& callback);
65 void PostV8CallbackWithArgs(v8::UniquePersistent<v8::Function> callback,
66 int argc,
67 v8::Local<v8::Value> argv[]);
68 void InvokeV8Callback(const v8::UniquePersistent<v8::Function>& callback);
69 void InvokeV8CallbackWithArgs(
70 const v8::UniquePersistent<v8::Function>& callback,
71 const std::vector<v8::UniquePersistent<v8::Value>>& args);
72 base::Closure CreateClosureThatPostsV8Callback(
73 const v8::Local<v8::Function>& callback);
74
75 void LayoutAndPaintAsync();
76 void LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback);
77
78 // Similar to LayoutAndPaintAsyncThen(), but pass parameters of the captured
79 // snapshot (width, height, snapshot) to the callback. The snapshot is in
80 // uint8_t RGBA format.
81 void CapturePixelsAsyncThen(v8::Local<v8::Function> callback);
82 void CapturePixelsCallback(v8::UniquePersistent<v8::Function> callback,
83 const SkBitmap& snapshot);
84
85 // Similar to CapturePixelsAsyncThen(). Copies to the clipboard the image
86 // located at a particular point in the WebView (if there is such an image),
87 // reads back its pixels, and provides the snapshot to the callback. If there
88 // is no image at that point, calls the callback with (0, 0, empty_snapshot).
89 void CopyImageAtAndCapturePixelsAsyncThen(
90 int x,
91 int y,
92 const v8::Local<v8::Function> callback);
93
94 void GetManifestThen(v8::Local<v8::Function> callback);
95 void GetManifestCallback(v8::UniquePersistent<v8::Function> callback,
96 const blink::WebURLResponse& response,
97 const std::string& data);
98
99 // Calls |callback| with a DOMString[] representing the events recorded since
100 // the last call to this function.
101 void GetBluetoothManualChooserEvents(v8::Local<v8::Function> callback);
102 void GetBluetoothManualChooserEventsCallback(
103 v8::UniquePersistent<v8::Function> callback,
104 const std::vector<std::string>& events);
105
106 // Change the bluetooth test data while running a layout test.
107 void SetBluetoothFakeAdapter(const std::string& adapter_name,
108 v8::Local<v8::Function> callback);
109
110 // If |enable| is true, makes the Bluetooth chooser record its input and wait
111 // for instructions from the test program on how to proceed. Otherwise falls
112 // back to the browser's default chooser.
113 void SetBluetoothManualChooser(bool enable);
114
115 // Calls the BluetoothChooser::EventHandler with the arguments here. Valid
116 // event strings are:
117 // * "cancel" - simulates the user canceling the chooser.
118 // * "select" - simulates the user selecting a device whose device ID is in
119 // |argument|.
120 void SendBluetoothManualChooserEvent(const std::string& event,
121 const std::string& argument);
122
123 // Used to set the device scale factor.
124 void SetBackingScaleFactor(double value, v8::Local<v8::Function> callback);
125
126 // Enable zoom-for-dsf option.
127 // TODO(oshima): Remove this once all platforms migrated.
128 void EnableUseZoomForDSF(v8::Local<v8::Function> callback);
129
130 // Change the device color profile while running a layout test.
131 void SetColorProfile(const std::string& name,
132 v8::Local<v8::Function> callback);
133
134 // Causes the beforeinstallprompt event to be sent to the renderer.
135 void DispatchBeforeInstallPromptEvent(
136 const std::vector<std::string>& event_platforms,
137 v8::Local<v8::Function> callback);
138 void DispatchBeforeInstallPromptCallback(
139 v8::UniquePersistent<v8::Function> callback,
140 bool canceled);
141
142 // Immediately run all pending idle tasks, including all pending
143 // requestIdleCallback calls. Invoke the callback when all
144 // idle tasks are complete.
145 void RunIdleTasks(v8::Local<v8::Function> callback);
146
147 // Method that controls whether pressing Tab key cycles through page elements
148 // or inserts a '\t' char in text area
149 void SetTabKeyCyclesThroughElements(bool tab_key_cycles_through_elements);
150
151 // Executes an internal command (superset of document.execCommand() commands).
152 void ExecCommand(gin::Arguments* args);
153
154 // Checks if an internal command is currently available.
155 bool IsCommandEnabled(const std::string& command);
156
157 // Returns true if the current page box has custom page size style for
158 // printing.
159 bool HasCustomPageSizeStyle(int page_index);
160
161 // Forces the selection colors for testing under Linux.
162 void ForceRedSelectionColors();
163
164 // Switch the visibility of the page.
165 void SetPageVisibility(const std::string& new_visibility);
166
167 // Changes the direction of the focused element.
168 void SetTextDirection(const std::string& direction_name);
169
170 // Dump current PageImportanceSignals for the page.
171 void DumpPageImportanceSignals();
172
173 // Permits the adding and removing of only one opaque overlay.
174 void AddWebPageOverlay();
175 void RemoveWebPageOverlay();
176
177 // Sets a flag causing the next call to WebGLRenderingContext::create to fail.
178 void ForceNextWebGLContextCreationToFail();
179
180 // Sets a flag causing the next call to DrawingBuffer::create to fail.
181 void ForceNextDrawingBufferCreationToFail();
182
183 // Gives focus to the view associated with TestRunnerForSpecificView.
184 void SetWindowIsKey(bool value);
185
186 // Pointer lock handling.
187 void DidAcquirePointerLock();
188 void DidNotAcquirePointerLock();
189 void DidLosePointerLock();
190 void SetPointerLockWillFailSynchronously();
191 void SetPointerLockWillRespondAsynchronously();
192 void DidAcquirePointerLockInternal();
193 void DidNotAcquirePointerLockInternal();
194 void DidLosePointerLockInternal();
195 bool pointer_locked_;
196 enum {
197 PointerLockWillSucceed,
198 PointerLockWillRespondAsync,
199 PointerLockWillFailSync,
200 } pointer_lock_planned_result_;
201
202 bool CallShouldCloseOnWebView();
203 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
204 const std::string& scheme);
205 v8::Local<v8::Value> EvaluateScriptInIsolatedWorldAndReturnValue(
206 int world_id,
207 const std::string& script);
208 void EvaluateScriptInIsolatedWorld(int world_id, const std::string& script);
209 void SetIsolatedWorldSecurityOrigin(int world_id,
210 v8::Local<v8::Value> origin);
211 void SetIsolatedWorldContentSecurityPolicy(int world_id,
212 const std::string& policy);
213 bool FindString(const std::string& search_text,
214 const std::vector<std::string>& options_array);
215 std::string SelectionAsMarkup();
216 void SetViewSourceForFrame(const std::string& name, bool enabled);
217
218 // Helpers for accessing pointers exposed by |web_view_test_proxy_base_|.
219 blink::WebView* web_view();
220 WebTestDelegate* delegate();
221 WebViewTestProxyBase* web_view_test_proxy_base_;
222
223 base::WeakPtrFactory<TestRunnerForSpecificView> weak_factory_;
224
225 DISALLOW_COPY_AND_ASSIGN(TestRunnerForSpecificView);
226 };
227
228 } // namespace test_runner
229
230 #endif // COMPONENTS_TEST_RUNNER_TEST_RUNNER_FOR_SPECIFIC_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698