OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/shell/renderer/test_runner/test_runner.h" | 5 #include "content/shell/renderer/test_runner/test_runner.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/shell/common/test_runner/test_preferences.h" | 10 #include "content/shell/common/test_runner/test_preferences.h" |
11 #include "content/shell/renderer/test_runner/MockWebSpeechInputController.h" | |
12 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" | 11 #include "content/shell/renderer/test_runner/MockWebSpeechRecognizer.h" |
13 #include "content/shell/renderer/test_runner/TestInterfaces.h" | 12 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
14 #include "content/shell/renderer/test_runner/WebPermissions.h" | 13 #include "content/shell/renderer/test_runner/WebPermissions.h" |
15 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 14 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
16 #include "content/shell/renderer/test_runner/WebTestProxy.h" | 15 #include "content/shell/renderer/test_runner/WebTestProxy.h" |
17 #include "content/shell/renderer/test_runner/notification_presenter.h" | 16 #include "content/shell/renderer/test_runner/notification_presenter.h" |
18 #include "gin/arguments.h" | 17 #include "gin/arguments.h" |
19 #include "gin/array_buffer.h" | 18 #include "gin/array_buffer.h" |
20 #include "gin/handle.h" | 19 #include "gin/handle.h" |
21 #include "gin/object_template_builder.h" | 20 #include "gin/object_template_builder.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 void SetDatabaseQuota(int quota); | 229 void SetDatabaseQuota(int quota); |
231 void SetAlwaysAcceptCookies(bool accept); | 230 void SetAlwaysAcceptCookies(bool accept); |
232 void SetWindowIsKey(bool value); | 231 void SetWindowIsKey(bool value); |
233 std::string PathToLocalResource(const std::string& path); | 232 std::string PathToLocalResource(const std::string& path); |
234 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); | 233 void SetBackingScaleFactor(double value, v8::Handle<v8::Function> callback); |
235 void SetPOSIXLocale(const std::string& locale); | 234 void SetPOSIXLocale(const std::string& locale); |
236 void SetMIDIAccessorResult(bool result); | 235 void SetMIDIAccessorResult(bool result); |
237 void SetMIDISysexPermission(bool value); | 236 void SetMIDISysexPermission(bool value); |
238 void GrantWebNotificationPermission(gin::Arguments* args); | 237 void GrantWebNotificationPermission(gin::Arguments* args); |
239 bool SimulateWebNotificationClick(const std::string& value); | 238 bool SimulateWebNotificationClick(const std::string& value); |
240 void AddMockSpeechInputResult(const std::string& result, | |
241 double confidence, | |
242 const std::string& language); | |
243 void SetMockSpeechInputDumpRect(bool value); | |
244 void AddMockSpeechRecognitionResult(const std::string& transcript, | 239 void AddMockSpeechRecognitionResult(const std::string& transcript, |
245 double confidence); | 240 double confidence); |
246 void SetMockSpeechRecognitionError(const std::string& error, | 241 void SetMockSpeechRecognitionError(const std::string& error, |
247 const std::string& message); | 242 const std::string& message); |
248 bool WasMockSpeechRecognitionAborted(); | 243 bool WasMockSpeechRecognitionAborted(); |
249 void AddWebPageOverlay(); | 244 void AddWebPageOverlay(); |
250 void RemoveWebPageOverlay(); | 245 void RemoveWebPageOverlay(); |
251 void DisplayAsync(); | 246 void DisplayAsync(); |
252 void DisplayAsyncThen(v8::Handle<v8::Function> callback); | 247 void DisplayAsyncThen(v8::Handle<v8::Function> callback); |
253 | 248 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 &TestRunnerBindings::SetBackingScaleFactor) | 455 &TestRunnerBindings::SetBackingScaleFactor) |
461 .SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale) | 456 .SetMethod("setPOSIXLocale", &TestRunnerBindings::SetPOSIXLocale) |
462 .SetMethod("setMIDIAccessorResult", | 457 .SetMethod("setMIDIAccessorResult", |
463 &TestRunnerBindings::SetMIDIAccessorResult) | 458 &TestRunnerBindings::SetMIDIAccessorResult) |
464 .SetMethod("setMIDISysexPermission", | 459 .SetMethod("setMIDISysexPermission", |
465 &TestRunnerBindings::SetMIDISysexPermission) | 460 &TestRunnerBindings::SetMIDISysexPermission) |
466 .SetMethod("grantWebNotificationPermission", | 461 .SetMethod("grantWebNotificationPermission", |
467 &TestRunnerBindings::GrantWebNotificationPermission) | 462 &TestRunnerBindings::GrantWebNotificationPermission) |
468 .SetMethod("simulateWebNotificationClick", | 463 .SetMethod("simulateWebNotificationClick", |
469 &TestRunnerBindings::SimulateWebNotificationClick) | 464 &TestRunnerBindings::SimulateWebNotificationClick) |
470 .SetMethod("addMockSpeechInputResult", | |
471 &TestRunnerBindings::AddMockSpeechInputResult) | |
472 .SetMethod("setMockSpeechInputDumpRect", | |
473 &TestRunnerBindings::SetMockSpeechInputDumpRect) | |
474 .SetMethod("addMockSpeechRecognitionResult", | 465 .SetMethod("addMockSpeechRecognitionResult", |
475 &TestRunnerBindings::AddMockSpeechRecognitionResult) | 466 &TestRunnerBindings::AddMockSpeechRecognitionResult) |
476 .SetMethod("setMockSpeechRecognitionError", | 467 .SetMethod("setMockSpeechRecognitionError", |
477 &TestRunnerBindings::SetMockSpeechRecognitionError) | 468 &TestRunnerBindings::SetMockSpeechRecognitionError) |
478 .SetMethod("wasMockSpeechRecognitionAborted", | 469 .SetMethod("wasMockSpeechRecognitionAborted", |
479 &TestRunnerBindings::WasMockSpeechRecognitionAborted) | 470 &TestRunnerBindings::WasMockSpeechRecognitionAborted) |
480 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) | 471 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) |
481 .SetMethod("removeWebPageOverlay", | 472 .SetMethod("removeWebPageOverlay", |
482 &TestRunnerBindings::RemoveWebPageOverlay) | 473 &TestRunnerBindings::RemoveWebPageOverlay) |
483 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) | 474 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 } | 1172 } |
1182 } | 1173 } |
1183 | 1174 |
1184 bool TestRunnerBindings::SimulateWebNotificationClick( | 1175 bool TestRunnerBindings::SimulateWebNotificationClick( |
1185 const std::string& value) { | 1176 const std::string& value) { |
1186 if (runner_) | 1177 if (runner_) |
1187 return runner_->SimulateWebNotificationClick(value); | 1178 return runner_->SimulateWebNotificationClick(value); |
1188 return false; | 1179 return false; |
1189 } | 1180 } |
1190 | 1181 |
1191 void TestRunnerBindings::AddMockSpeechInputResult(const std::string& result, | |
1192 double confidence, | |
1193 const std::string& language) { | |
1194 if (runner_) | |
1195 runner_->AddMockSpeechInputResult(result, confidence, language); | |
1196 } | |
1197 | |
1198 void TestRunnerBindings::SetMockSpeechInputDumpRect(bool value) { | |
1199 if (runner_) | |
1200 runner_->SetMockSpeechInputDumpRect(value); | |
1201 } | |
1202 | |
1203 void TestRunnerBindings::AddMockSpeechRecognitionResult( | 1182 void TestRunnerBindings::AddMockSpeechRecognitionResult( |
1204 const std::string& transcript, double confidence) { | 1183 const std::string& transcript, double confidence) { |
1205 if (runner_) | 1184 if (runner_) |
1206 runner_->AddMockSpeechRecognitionResult(transcript, confidence); | 1185 runner_->AddMockSpeechRecognitionResult(transcript, confidence); |
1207 } | 1186 } |
1208 | 1187 |
1209 void TestRunnerBindings::SetMockSpeechRecognitionError( | 1188 void TestRunnerBindings::SetMockSpeechRecognitionError( |
1210 const std::string& error, const std::string& message) { | 1189 const std::string& error, const std::string& message) { |
1211 if (runner_) | 1190 if (runner_) |
1212 runner_->SetMockSpeechRecognitionError(error, message); | 1191 runner_->SetMockSpeechRecognitionError(error, message); |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 | 2495 |
2517 void TestRunner::GrantWebNotificationPermission(const std::string& origin, | 2496 void TestRunner::GrantWebNotificationPermission(const std::string& origin, |
2518 bool permission_granted) { | 2497 bool permission_granted) { |
2519 notification_presenter_->GrantPermission(origin, permission_granted); | 2498 notification_presenter_->GrantPermission(origin, permission_granted); |
2520 } | 2499 } |
2521 | 2500 |
2522 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { | 2501 bool TestRunner::SimulateWebNotificationClick(const std::string& value) { |
2523 return notification_presenter_->SimulateClick(value); | 2502 return notification_presenter_->SimulateClick(value); |
2524 } | 2503 } |
2525 | 2504 |
2526 void TestRunner::AddMockSpeechInputResult(const std::string& result, | |
2527 double confidence, | |
2528 const std::string& language) { | |
2529 #if ENABLE_INPUT_SPEECH | |
2530 proxy_->speechInputControllerMock()->addMockRecognitionResult( | |
2531 WebString::fromUTF8(result), confidence, WebString::fromUTF8(language)); | |
2532 #endif | |
2533 } | |
2534 | |
2535 void TestRunner::SetMockSpeechInputDumpRect(bool value) { | |
2536 #if ENABLE_INPUT_SPEECH | |
2537 proxy_->speechInputControllerMock()->setDumpRect(value); | |
2538 #endif | |
2539 } | |
2540 | |
2541 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, | 2505 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, |
2542 double confidence) { | 2506 double confidence) { |
2543 proxy_->speechRecognizerMock()->addMockResult( | 2507 proxy_->speechRecognizerMock()->addMockResult( |
2544 WebString::fromUTF8(transcript), confidence); | 2508 WebString::fromUTF8(transcript), confidence); |
2545 } | 2509 } |
2546 | 2510 |
2547 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, | 2511 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, |
2548 const std::string& message) { | 2512 const std::string& message) { |
2549 proxy_->speechRecognizerMock()->setError(WebString::fromUTF8(error), | 2513 proxy_->speechRecognizerMock()->setError(WebString::fromUTF8(error), |
2550 WebString::fromUTF8(message)); | 2514 WebString::fromUTF8(message)); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 } | 2592 } |
2629 | 2593 |
2630 void TestRunner::DidLosePointerLockInternal() { | 2594 void TestRunner::DidLosePointerLockInternal() { |
2631 bool was_locked = pointer_locked_; | 2595 bool was_locked = pointer_locked_; |
2632 pointer_locked_ = false; | 2596 pointer_locked_ = false; |
2633 if (was_locked) | 2597 if (was_locked) |
2634 web_view_->didLosePointerLock(); | 2598 web_view_->didLosePointerLock(); |
2635 } | 2599 } |
2636 | 2600 |
2637 } // namespace content | 2601 } // namespace content |
OLD | NEW |