OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 #include "components/html_viewer/web_test_delegate_impl.h" | |
6 | |
7 #include <iostream> | |
8 #include <utility> | |
9 | |
10 #include "base/time/time.h" | |
11 #include "cc/layers/texture_layer.h" | |
12 #include "components/test_runner/web_task.h" | |
13 #include "components/test_runner/web_test_interfaces.h" | |
14 #include "components/test_runner/web_test_proxy.h" | |
15 #include "third_party/WebKit/public/platform/Platform.h" | |
16 #include "third_party/WebKit/public/platform/WebString.h" | |
17 #include "third_party/WebKit/public/platform/WebTaskRunner.h" | |
18 #include "third_party/WebKit/public/platform/WebThread.h" | |
19 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | |
20 #include "third_party/WebKit/public/platform/WebURL.h" | |
21 #include "url/gurl.h" | |
22 | |
23 namespace html_viewer { | |
24 | |
25 namespace { | |
26 | |
27 class InvokeTaskHelper : public blink::WebTaskRunner::Task { | |
28 public: | |
29 InvokeTaskHelper(scoped_ptr<test_runner::WebTask> task) | |
30 : task_(std::move(task)) {} | |
31 | |
32 // WebThread::Task implementation: | |
33 void run() override { task_->run(); } | |
34 | |
35 private: | |
36 scoped_ptr<test_runner::WebTask> task_; | |
37 }; | |
38 | |
39 } // namespace | |
40 | |
41 WebTestDelegateImpl::WebTestDelegateImpl() | |
42 : test_interfaces_(nullptr), proxy_(nullptr) { | |
43 } | |
44 | |
45 WebTestDelegateImpl::~WebTestDelegateImpl() { | |
46 } | |
47 | |
48 void WebTestDelegateImpl::ClearEditCommand() { | |
49 NOTIMPLEMENTED(); | |
50 } | |
51 | |
52 void WebTestDelegateImpl::SetEditCommand(const std::string& name, | |
53 const std::string& value) { | |
54 NOTIMPLEMENTED(); | |
55 } | |
56 | |
57 void WebTestDelegateImpl::SetGamepadProvider( | |
58 test_runner::GamepadController* controller) { | |
59 NOTIMPLEMENTED(); | |
60 } | |
61 | |
62 void WebTestDelegateImpl::SetDeviceLightData(const double data) { | |
63 NOTIMPLEMENTED(); | |
64 } | |
65 | |
66 void WebTestDelegateImpl::SetDeviceMotionData( | |
67 const blink::WebDeviceMotionData& data) { | |
68 NOTIMPLEMENTED(); | |
69 } | |
70 | |
71 void WebTestDelegateImpl::SetDeviceOrientationData( | |
72 const blink::WebDeviceOrientationData& data) { | |
73 NOTIMPLEMENTED(); | |
74 } | |
75 | |
76 void WebTestDelegateImpl::SetScreenOrientation( | |
77 const blink::WebScreenOrientationType& orientation) { | |
78 NOTIMPLEMENTED(); | |
79 } | |
80 | |
81 void WebTestDelegateImpl::ResetScreenOrientation() { | |
82 NOTIMPLEMENTED(); | |
83 } | |
84 | |
85 void WebTestDelegateImpl::DidChangeBatteryStatus( | |
86 const blink::WebBatteryStatus& status) { | |
87 NOTIMPLEMENTED(); | |
88 } | |
89 | |
90 void WebTestDelegateImpl::PrintMessage(const std::string& message) { | |
91 std::cout << message; | |
92 } | |
93 | |
94 void WebTestDelegateImpl::PostTask(test_runner::WebTask* task) { | |
95 blink::Platform::current()->currentThread()->taskRunner()->postTask( | |
96 blink::WebTraceLocation(__FUNCTION__, __FILE__), | |
97 new InvokeTaskHelper(make_scoped_ptr(task))); | |
98 } | |
99 | |
100 void WebTestDelegateImpl::PostDelayedTask(test_runner::WebTask* task, | |
101 long long ms) { | |
102 blink::Platform::current()->currentThread()->taskRunner()->postDelayedTask( | |
103 blink::WebTraceLocation(__FUNCTION__, __FILE__), | |
104 new InvokeTaskHelper(make_scoped_ptr(task)), ms); | |
105 } | |
106 | |
107 blink::WebString WebTestDelegateImpl::RegisterIsolatedFileSystem( | |
108 const blink::WebVector<blink::WebString>& absolute_filenames) { | |
109 NOTIMPLEMENTED(); | |
110 return blink::WebString(); | |
111 } | |
112 | |
113 long long WebTestDelegateImpl::GetCurrentTimeInMillisecond() { | |
114 return base::TimeDelta(base::Time::Now() - base::Time::UnixEpoch()) | |
115 .ToInternalValue() / | |
116 base::Time::kMicrosecondsPerMillisecond; | |
117 } | |
118 | |
119 blink::WebString WebTestDelegateImpl::GetAbsoluteWebStringFromUTF8Path( | |
120 const std::string& path) { | |
121 NOTIMPLEMENTED(); | |
122 return blink::WebString::fromUTF8(path); | |
123 } | |
124 | |
125 blink::WebURL WebTestDelegateImpl::LocalFileToDataURL( | |
126 const blink::WebURL& file_url) { | |
127 NOTIMPLEMENTED(); | |
128 return blink::WebURL(); | |
129 } | |
130 | |
131 blink::WebURL WebTestDelegateImpl::RewriteLayoutTestsURL( | |
132 const std::string& utf8_url) { | |
133 return blink::WebURL(GURL(utf8_url)); | |
134 } | |
135 | |
136 test_runner::TestPreferences* WebTestDelegateImpl::Preferences() { | |
137 if (!prefs_) | |
138 prefs_.reset(new test_runner::TestPreferences); | |
139 return prefs_.get(); | |
140 } | |
141 | |
142 void WebTestDelegateImpl::ApplyPreferences() { | |
143 NOTIMPLEMENTED(); | |
144 } | |
145 | |
146 void WebTestDelegateImpl::UseUnfortunateSynchronousResizeMode(bool enable) { | |
147 NOTIMPLEMENTED(); | |
148 } | |
149 | |
150 void WebTestDelegateImpl::EnableAutoResizeMode(const blink::WebSize& min_size, | |
151 const blink::WebSize& max_size) { | |
152 NOTIMPLEMENTED(); | |
153 } | |
154 | |
155 void WebTestDelegateImpl::DisableAutoResizeMode( | |
156 const blink::WebSize& new_size) { | |
157 NOTIMPLEMENTED(); | |
158 } | |
159 | |
160 void WebTestDelegateImpl::ClearDevToolsLocalStorage() { | |
161 NOTIMPLEMENTED(); | |
162 } | |
163 | |
164 void WebTestDelegateImpl::ShowDevTools(const std::string& settings, | |
165 const std::string& frontend_url) { | |
166 NOTIMPLEMENTED(); | |
167 } | |
168 | |
169 void WebTestDelegateImpl::CloseDevTools() { | |
170 NOTIMPLEMENTED(); | |
171 } | |
172 | |
173 void WebTestDelegateImpl::EvaluateInWebInspector(long call_id, | |
174 const std::string& script) { | |
175 NOTIMPLEMENTED(); | |
176 } | |
177 | |
178 std::string WebTestDelegateImpl::EvaluateInWebInspectorOverlay( | |
179 const std::string& script) { | |
180 NOTIMPLEMENTED(); | |
181 return std::string(); | |
182 } | |
183 | |
184 void WebTestDelegateImpl::ClearAllDatabases() { | |
185 NOTIMPLEMENTED(); | |
186 } | |
187 | |
188 void WebTestDelegateImpl::SetDatabaseQuota(int quota) { | |
189 NOTIMPLEMENTED(); | |
190 } | |
191 | |
192 void WebTestDelegateImpl::SimulateWebNotificationClick( | |
193 const std::string& title, int action_index) { | |
194 NOTIMPLEMENTED(); | |
195 } | |
196 | |
197 void WebTestDelegateImpl::SetDeviceScaleFactor(float factor) { | |
198 NOTIMPLEMENTED(); | |
199 } | |
200 | |
201 void WebTestDelegateImpl::EnableUseZoomForDSF() { | |
202 NOTIMPLEMENTED(); | |
203 } | |
204 | |
205 void WebTestDelegateImpl::SetDeviceColorProfile(const std::string& name) { | |
206 NOTIMPLEMENTED(); | |
207 } | |
208 | |
209 void WebTestDelegateImpl::SetBluetoothMockDataSet(const std::string& data_set) { | |
210 NOTIMPLEMENTED(); | |
211 } | |
212 | |
213 void WebTestDelegateImpl::SetBluetoothManualChooser() { | |
214 NOTIMPLEMENTED(); | |
215 } | |
216 | |
217 void WebTestDelegateImpl::GetBluetoothManualChooserEvents( | |
218 const base::Callback<void(const std::vector<std::string>&)>& callback) { | |
219 NOTIMPLEMENTED(); | |
220 } | |
221 | |
222 void WebTestDelegateImpl::SendBluetoothManualChooserEvent( | |
223 const std::string& event, | |
224 const std::string& argument) { | |
225 NOTIMPLEMENTED(); | |
226 } | |
227 | |
228 void WebTestDelegateImpl::SetGeofencingMockProvider(bool service_available) { | |
229 NOTIMPLEMENTED(); | |
230 } | |
231 | |
232 void WebTestDelegateImpl::ClearGeofencingMockProvider() { | |
233 NOTIMPLEMENTED(); | |
234 } | |
235 | |
236 void WebTestDelegateImpl::SetGeofencingMockPosition(double latitude, | |
237 double longitude) { | |
238 NOTIMPLEMENTED(); | |
239 } | |
240 | |
241 void WebTestDelegateImpl::SetFocus(test_runner::WebTestProxyBase* proxy, | |
242 bool focus) { | |
243 NOTIMPLEMENTED(); | |
244 } | |
245 | |
246 void WebTestDelegateImpl::SetAcceptAllCookies(bool accept) { | |
247 NOTIMPLEMENTED(); | |
248 } | |
249 | |
250 std::string WebTestDelegateImpl::PathToLocalResource( | |
251 const std::string& resource) { | |
252 NOTIMPLEMENTED(); | |
253 return std::string(); | |
254 } | |
255 | |
256 void WebTestDelegateImpl::SetLocale(const std::string& locale) { | |
257 NOTIMPLEMENTED(); | |
258 } | |
259 | |
260 void WebTestDelegateImpl::TestFinished() { | |
261 std::cout << "Content-Type: text/plain\n"; | |
262 std::cout << proxy_->CaptureTree(false, false); | |
263 std::cout << "#EOF\n"; | |
264 | |
265 test_interfaces_->SetTestIsRunning(false); | |
266 if (!completion_callback_.is_null()) | |
267 completion_callback_.Run(); | |
268 } | |
269 | |
270 void WebTestDelegateImpl::CloseRemainingWindows() { | |
271 NOTIMPLEMENTED(); | |
272 } | |
273 | |
274 void WebTestDelegateImpl::DeleteAllCookies() { | |
275 NOTIMPLEMENTED(); | |
276 } | |
277 | |
278 int WebTestDelegateImpl::NavigationEntryCount() { | |
279 NOTIMPLEMENTED(); | |
280 return 0; | |
281 } | |
282 | |
283 void WebTestDelegateImpl::GoToOffset(int offset) { | |
284 NOTIMPLEMENTED(); | |
285 } | |
286 | |
287 void WebTestDelegateImpl::Reload() { | |
288 NOTIMPLEMENTED(); | |
289 } | |
290 | |
291 void WebTestDelegateImpl::LoadURLForFrame(const blink::WebURL& url, | |
292 const std::string& frame_name) { | |
293 NOTIMPLEMENTED(); | |
294 } | |
295 | |
296 bool WebTestDelegateImpl::AllowExternalPages() { | |
297 NOTIMPLEMENTED(); | |
298 return false; | |
299 } | |
300 | |
301 std::string WebTestDelegateImpl::DumpHistoryForWindow( | |
302 test_runner::WebTestProxyBase* proxy) { | |
303 NOTIMPLEMENTED(); | |
304 return std::string(); | |
305 } | |
306 | |
307 void WebTestDelegateImpl::FetchManifest( | |
308 blink::WebView* view, | |
309 const GURL& url, | |
310 const base::Callback<void(const blink::WebURLResponse& response, | |
311 const std::string& data)>& callback) { | |
312 NOTIMPLEMENTED(); | |
313 } | |
314 | |
315 void WebTestDelegateImpl::SetPermission(const std::string& permission_name, | |
316 const std::string& permission_value, | |
317 const GURL& origin, | |
318 const GURL& embedding_origin) { | |
319 NOTIMPLEMENTED(); | |
320 } | |
321 | |
322 void WebTestDelegateImpl::ResetPermissions() { | |
323 NOTIMPLEMENTED(); | |
324 } | |
325 | |
326 bool WebTestDelegateImpl::AddMediaStreamVideoSourceAndTrack( | |
327 blink::WebMediaStream* stream) { | |
328 NOTIMPLEMENTED(); | |
329 return false; | |
330 } | |
331 | |
332 bool WebTestDelegateImpl::AddMediaStreamAudioSourceAndTrack( | |
333 blink::WebMediaStream* stream) { | |
334 NOTIMPLEMENTED(); | |
335 return false; | |
336 } | |
337 | |
338 cc::SharedBitmapManager* WebTestDelegateImpl::GetSharedBitmapManager() { | |
339 NOTIMPLEMENTED(); | |
340 return nullptr; | |
341 } | |
342 | |
343 void WebTestDelegateImpl::DispatchBeforeInstallPromptEvent( | |
344 int request_id, | |
345 const std::vector<std::string>& event_platforms, | |
346 const base::Callback<void(bool)>& callback) { | |
347 NOTIMPLEMENTED(); | |
348 } | |
349 | |
350 void WebTestDelegateImpl::ResolveBeforeInstallPromptPromise(int request_id, | |
351 const std::string& platform) { | |
352 NOTIMPLEMENTED(); | |
353 } | |
354 | |
355 blink::WebPlugin* WebTestDelegateImpl::CreatePluginPlaceholder( | |
356 blink::WebLocalFrame* frame, | |
357 const blink::WebPluginParams& params) { | |
358 NOTIMPLEMENTED(); | |
359 return nullptr; | |
360 } | |
361 | |
362 void WebTestDelegateImpl::OnWebTestProxyBaseDestroy( | |
363 test_runner::WebTestProxyBase* base) { | |
364 } | |
365 | |
366 blink::WebPoint WebTestDelegateImpl::ConvertDIPToNative( | |
367 const blink::WebPoint& point_in_dip) const { | |
368 NOTIMPLEMENTED(); | |
369 return point_in_dip; | |
370 } | |
371 | |
372 } // namespace html_viewer | |
OLD | NEW |