| 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/binding_helpers.h" | 11 #include "content/shell/renderer/binding_helpers.h" |
| 12 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 12 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 13 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" |
| 13 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 14 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
| 14 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 15 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
| 15 #include "content/shell/renderer/test_runner/notification_presenter.h" | 16 #include "content/shell/renderer/test_runner/notification_presenter.h" |
| 16 #include "content/shell/renderer/test_runner/test_interfaces.h" | 17 #include "content/shell/renderer/test_runner/test_interfaces.h" |
| 17 #include "content/shell/renderer/test_runner/web_permissions.h" | 18 #include "content/shell/renderer/test_runner/web_permissions.h" |
| 18 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 19 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
| 19 #include "gin/arguments.h" | 20 #include "gin/arguments.h" |
| 20 #include "gin/array_buffer.h" | 21 #include "gin/array_buffer.h" |
| 21 #include "gin/handle.h" | 22 #include "gin/handle.h" |
| 22 #include "gin/object_template_builder.h" | 23 #include "gin/object_template_builder.h" |
| 23 #include "gin/wrappable.h" | 24 #include "gin/wrappable.h" |
| 24 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 25 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| 25 #include "third_party/WebKit/public/platform/WebBatteryStatus.h" | 26 #include "third_party/WebKit/public/platform/WebBatteryStatus.h" |
| 26 #include "third_party/WebKit/public/platform/WebCanvas.h" | 27 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 27 #include "third_party/WebKit/public/platform/WebData.h" | 28 #include "third_party/WebKit/public/platform/WebData.h" |
| 28 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" | 29 #include "third_party/WebKit/public/platform/WebDeviceMotionData.h" |
| 29 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" | 30 #include "third_party/WebKit/public/platform/WebDeviceOrientationData.h" |
| 31 #include "third_party/WebKit/public/platform/WebLocalCredential.h" |
| 30 #include "third_party/WebKit/public/platform/WebPoint.h" | 32 #include "third_party/WebKit/public/platform/WebPoint.h" |
| 31 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 33 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 32 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" | 34 #include "third_party/WebKit/public/web/WebArrayBufferConverter.h" |
| 33 #include "third_party/WebKit/public/web/WebBindings.h" | 35 #include "third_party/WebKit/public/web/WebBindings.h" |
| 34 #include "third_party/WebKit/public/web/WebDataSource.h" | 36 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 35 #include "third_party/WebKit/public/web/WebDocument.h" | 37 #include "third_party/WebKit/public/web/WebDocument.h" |
| 36 #include "third_party/WebKit/public/web/WebFindOptions.h" | 38 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 37 #include "third_party/WebKit/public/web/WebFrame.h" | 39 #include "third_party/WebKit/public/web/WebFrame.h" |
| 38 #include "third_party/WebKit/public/web/WebInputElement.h" | 40 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 39 #include "third_party/WebKit/public/web/WebKit.h" | 41 #include "third_party/WebKit/public/web/WebKit.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 void SetMIDIAccessorResult(bool result); | 273 void SetMIDIAccessorResult(bool result); |
| 272 void SetMIDISysexPermission(bool value); | 274 void SetMIDISysexPermission(bool value); |
| 273 void GrantWebNotificationPermission(gin::Arguments* args); | 275 void GrantWebNotificationPermission(gin::Arguments* args); |
| 274 void ClearWebNotificationPermissions(); | 276 void ClearWebNotificationPermissions(); |
| 275 bool SimulateWebNotificationClick(const std::string& value); | 277 bool SimulateWebNotificationClick(const std::string& value); |
| 276 void AddMockSpeechRecognitionResult(const std::string& transcript, | 278 void AddMockSpeechRecognitionResult(const std::string& transcript, |
| 277 double confidence); | 279 double confidence); |
| 278 void SetMockSpeechRecognitionError(const std::string& error, | 280 void SetMockSpeechRecognitionError(const std::string& error, |
| 279 const std::string& message); | 281 const std::string& message); |
| 280 bool WasMockSpeechRecognitionAborted(); | 282 bool WasMockSpeechRecognitionAborted(); |
| 283 void AddMockCredentialManagerResponse(const std::string& id, |
| 284 const std::string& name, |
| 285 const std::string& avatar, |
| 286 const std::string& password); |
| 281 void AddWebPageOverlay(); | 287 void AddWebPageOverlay(); |
| 282 void RemoveWebPageOverlay(); | 288 void RemoveWebPageOverlay(); |
| 283 void DisplayAsync(); | 289 void DisplayAsync(); |
| 284 void DisplayAsyncThen(v8::Handle<v8::Function> callback); | 290 void DisplayAsyncThen(v8::Handle<v8::Function> callback); |
| 285 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); | 291 void CapturePixelsAsyncThen(v8::Handle<v8::Function> callback); |
| 286 void CopyImageAtAndCapturePixelsAsyncThen(int x, | 292 void CopyImageAtAndCapturePixelsAsyncThen(int x, |
| 287 int y, | 293 int y, |
| 288 v8::Handle<v8::Function> callback); | 294 v8::Handle<v8::Function> callback); |
| 289 void SetCustomTextOutput(std::string output); | 295 void SetCustomTextOutput(std::string output); |
| 290 void SetViewSourceForFrame(const std::string& name, bool enabled); | 296 void SetViewSourceForFrame(const std::string& name, bool enabled); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 .SetMethod("clearWebNotificationPermissions", | 514 .SetMethod("clearWebNotificationPermissions", |
| 509 &TestRunnerBindings::ClearWebNotificationPermissions) | 515 &TestRunnerBindings::ClearWebNotificationPermissions) |
| 510 .SetMethod("simulateWebNotificationClick", | 516 .SetMethod("simulateWebNotificationClick", |
| 511 &TestRunnerBindings::SimulateWebNotificationClick) | 517 &TestRunnerBindings::SimulateWebNotificationClick) |
| 512 .SetMethod("addMockSpeechRecognitionResult", | 518 .SetMethod("addMockSpeechRecognitionResult", |
| 513 &TestRunnerBindings::AddMockSpeechRecognitionResult) | 519 &TestRunnerBindings::AddMockSpeechRecognitionResult) |
| 514 .SetMethod("setMockSpeechRecognitionError", | 520 .SetMethod("setMockSpeechRecognitionError", |
| 515 &TestRunnerBindings::SetMockSpeechRecognitionError) | 521 &TestRunnerBindings::SetMockSpeechRecognitionError) |
| 516 .SetMethod("wasMockSpeechRecognitionAborted", | 522 .SetMethod("wasMockSpeechRecognitionAborted", |
| 517 &TestRunnerBindings::WasMockSpeechRecognitionAborted) | 523 &TestRunnerBindings::WasMockSpeechRecognitionAborted) |
| 524 .SetMethod("addMockCredentialManagerResponse", |
| 525 &TestRunnerBindings::AddMockCredentialManagerResponse) |
| 518 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) | 526 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) |
| 519 .SetMethod("removeWebPageOverlay", | 527 .SetMethod("removeWebPageOverlay", |
| 520 &TestRunnerBindings::RemoveWebPageOverlay) | 528 &TestRunnerBindings::RemoveWebPageOverlay) |
| 521 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) | 529 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) |
| 522 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) | 530 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) |
| 523 .SetMethod("capturePixelsAsyncThen", | 531 .SetMethod("capturePixelsAsyncThen", |
| 524 &TestRunnerBindings::CapturePixelsAsyncThen) | 532 &TestRunnerBindings::CapturePixelsAsyncThen) |
| 525 .SetMethod("copyImageAtAndCapturePixelsAsyncThen", | 533 .SetMethod("copyImageAtAndCapturePixelsAsyncThen", |
| 526 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) | 534 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) |
| 527 .SetMethod("setCustomTextOutput", | 535 .SetMethod("setCustomTextOutput", |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 if (runner_) | 1324 if (runner_) |
| 1317 runner_->SetMockSpeechRecognitionError(error, message); | 1325 runner_->SetMockSpeechRecognitionError(error, message); |
| 1318 } | 1326 } |
| 1319 | 1327 |
| 1320 bool TestRunnerBindings::WasMockSpeechRecognitionAborted() { | 1328 bool TestRunnerBindings::WasMockSpeechRecognitionAborted() { |
| 1321 if (runner_) | 1329 if (runner_) |
| 1322 return runner_->WasMockSpeechRecognitionAborted(); | 1330 return runner_->WasMockSpeechRecognitionAborted(); |
| 1323 return false; | 1331 return false; |
| 1324 } | 1332 } |
| 1325 | 1333 |
| 1334 void TestRunnerBindings::AddMockCredentialManagerResponse( |
| 1335 const std::string& id, |
| 1336 const std::string& name, |
| 1337 const std::string& avatar, |
| 1338 const std::string& password) { |
| 1339 if (runner_) |
| 1340 runner_->AddMockCredentialManagerResponse(id, name, avatar, password); |
| 1341 } |
| 1342 |
| 1326 void TestRunnerBindings::AddWebPageOverlay() { | 1343 void TestRunnerBindings::AddWebPageOverlay() { |
| 1327 if (runner_) | 1344 if (runner_) |
| 1328 runner_->AddWebPageOverlay(); | 1345 runner_->AddWebPageOverlay(); |
| 1329 } | 1346 } |
| 1330 | 1347 |
| 1331 void TestRunnerBindings::RemoveWebPageOverlay() { | 1348 void TestRunnerBindings::RemoveWebPageOverlay() { |
| 1332 if (runner_) | 1349 if (runner_) |
| 1333 runner_->RemoveWebPageOverlay(); | 1350 runner_->RemoveWebPageOverlay(); |
| 1334 } | 1351 } |
| 1335 | 1352 |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, | 2761 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, |
| 2745 const std::string& message) { | 2762 const std::string& message) { |
| 2746 proxy_->GetSpeechRecognizerMock()->SetError(WebString::fromUTF8(error), | 2763 proxy_->GetSpeechRecognizerMock()->SetError(WebString::fromUTF8(error), |
| 2747 WebString::fromUTF8(message)); | 2764 WebString::fromUTF8(message)); |
| 2748 } | 2765 } |
| 2749 | 2766 |
| 2750 bool TestRunner::WasMockSpeechRecognitionAborted() { | 2767 bool TestRunner::WasMockSpeechRecognitionAborted() { |
| 2751 return proxy_->GetSpeechRecognizerMock()->WasAborted(); | 2768 return proxy_->GetSpeechRecognizerMock()->WasAborted(); |
| 2752 } | 2769 } |
| 2753 | 2770 |
| 2771 void TestRunner::AddMockCredentialManagerResponse(const std::string& id, |
| 2772 const std::string& name, |
| 2773 const std::string& avatar, |
| 2774 const std::string& password) { |
| 2775 proxy_->GetCredentialManagerClientMock()->SetResponse( |
| 2776 new WebLocalCredential(WebString::fromUTF8(id), |
| 2777 WebString::fromUTF8(name), |
| 2778 WebURL(GURL(avatar)), |
| 2779 WebString::fromUTF8(password))); |
| 2780 } |
| 2781 |
| 2754 void TestRunner::AddWebPageOverlay() { | 2782 void TestRunner::AddWebPageOverlay() { |
| 2755 if (web_view_ && !page_overlay_) { | 2783 if (web_view_ && !page_overlay_) { |
| 2756 page_overlay_ = new TestPageOverlay(web_view_); | 2784 page_overlay_ = new TestPageOverlay(web_view_); |
| 2757 web_view_->addPageOverlay(page_overlay_, 0); | 2785 web_view_->addPageOverlay(page_overlay_, 0); |
| 2758 } | 2786 } |
| 2759 } | 2787 } |
| 2760 | 2788 |
| 2761 void TestRunner::RemoveWebPageOverlay() { | 2789 void TestRunner::RemoveWebPageOverlay() { |
| 2762 if (web_view_ && page_overlay_) { | 2790 if (web_view_ && page_overlay_) { |
| 2763 web_view_->removePageOverlay(page_overlay_); | 2791 web_view_->removePageOverlay(page_overlay_); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2896 } | 2924 } |
| 2897 | 2925 |
| 2898 void TestRunner::DidLosePointerLockInternal() { | 2926 void TestRunner::DidLosePointerLockInternal() { |
| 2899 bool was_locked = pointer_locked_; | 2927 bool was_locked = pointer_locked_; |
| 2900 pointer_locked_ = false; | 2928 pointer_locked_ = false; |
| 2901 if (was_locked) | 2929 if (was_locked) |
| 2902 web_view_->didLosePointerLock(); | 2930 web_view_->didLosePointerLock(); |
| 2903 } | 2931 } |
| 2904 | 2932 |
| 2905 } // namespace content | 2933 } // namespace content |
| OLD | NEW |