| 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/public/test/layouttest_support.h" | 10 #include "content/public/test/layouttest_support.h" |
| 11 #include "content/shell/common/test_runner/test_preferences.h" | 11 #include "content/shell/common/test_runner/test_preferences.h" |
| 12 #include "content/shell/renderer/binding_helpers.h" | 12 #include "content/shell/renderer/binding_helpers.h" |
| 13 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" | 13 #include "content/shell/renderer/test_runner/mock_credential_manager_client.h" |
| 14 #include "content/shell/renderer/test_runner/mock_web_push_client.h" | 14 #include "content/shell/renderer/test_runner/mock_web_push_client.h" |
| 15 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" | 15 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h" |
| 16 #include "content/shell/renderer/test_runner/notification_presenter.h" | |
| 17 #include "content/shell/renderer/test_runner/test_interfaces.h" | 16 #include "content/shell/renderer/test_runner/test_interfaces.h" |
| 18 #include "content/shell/renderer/test_runner/web_permissions.h" | 17 #include "content/shell/renderer/test_runner/web_permissions.h" |
| 19 #include "content/shell/renderer/test_runner/web_test_delegate.h" | 18 #include "content/shell/renderer/test_runner/web_test_delegate.h" |
| 20 #include "content/shell/renderer/test_runner/web_test_proxy.h" | 19 #include "content/shell/renderer/test_runner/web_test_proxy.h" |
| 21 #include "gin/arguments.h" | 20 #include "gin/arguments.h" |
| 22 #include "gin/array_buffer.h" | 21 #include "gin/array_buffer.h" |
| 23 #include "gin/handle.h" | 22 #include "gin/handle.h" |
| 24 #include "gin/object_template_builder.h" | 23 #include "gin/object_template_builder.h" |
| 25 #include "gin/wrappable.h" | 24 #include "gin/wrappable.h" |
| 26 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 25 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 close_remaining_windows_(false), | 1539 close_remaining_windows_(false), |
| 1541 work_queue_(this), | 1540 work_queue_(this), |
| 1542 disable_notify_done_(false), | 1541 disable_notify_done_(false), |
| 1543 web_history_item_count_(0), | 1542 web_history_item_count_(0), |
| 1544 intercept_post_message_(false), | 1543 intercept_post_message_(false), |
| 1545 test_interfaces_(interfaces), | 1544 test_interfaces_(interfaces), |
| 1546 delegate_(nullptr), | 1545 delegate_(nullptr), |
| 1547 web_view_(nullptr), | 1546 web_view_(nullptr), |
| 1548 page_overlay_(nullptr), | 1547 page_overlay_(nullptr), |
| 1549 web_permissions_(new WebPermissions()), | 1548 web_permissions_(new WebPermissions()), |
| 1550 notification_presenter_(new NotificationPresenter()), | |
| 1551 weak_factory_(this) {} | 1549 weak_factory_(this) {} |
| 1552 | 1550 |
| 1553 TestRunner::~TestRunner() {} | 1551 TestRunner::~TestRunner() {} |
| 1554 | 1552 |
| 1555 void TestRunner::Install(WebFrame* frame) { | 1553 void TestRunner::Install(WebFrame* frame) { |
| 1556 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1554 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 1557 } | 1555 } |
| 1558 | 1556 |
| 1559 void TestRunner::SetDelegate(WebTestDelegate* delegate) { | 1557 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
| 1560 delegate_ = delegate; | 1558 delegate_ = delegate; |
| 1561 web_permissions_->SetDelegate(delegate); | 1559 web_permissions_->SetDelegate(delegate); |
| 1562 notification_presenter_->set_delegate(delegate); | |
| 1563 } | 1560 } |
| 1564 | 1561 |
| 1565 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { | 1562 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { |
| 1566 web_view_ = webView; | 1563 web_view_ = webView; |
| 1567 proxy_ = proxy; | 1564 proxy_ = proxy; |
| 1568 } | 1565 } |
| 1569 | 1566 |
| 1570 void TestRunner::Reset() { | 1567 void TestRunner::Reset() { |
| 1571 if (web_view_) { | 1568 if (web_view_) { |
| 1572 web_view_->setZoomLevel(0); | 1569 web_view_->setZoomLevel(0); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 http_headers_to_clear_.clear(); | 1649 http_headers_to_clear_.clear(); |
| 1653 | 1650 |
| 1654 platform_name_ = "chromium"; | 1651 platform_name_ = "chromium"; |
| 1655 tooltip_text_ = std::string(); | 1652 tooltip_text_ = std::string(); |
| 1656 disable_notify_done_ = false; | 1653 disable_notify_done_ = false; |
| 1657 web_history_item_count_ = 0; | 1654 web_history_item_count_ = 0; |
| 1658 intercept_post_message_ = false; | 1655 intercept_post_message_ = false; |
| 1659 | 1656 |
| 1660 web_permissions_->Reset(); | 1657 web_permissions_->Reset(); |
| 1661 | 1658 |
| 1662 notification_presenter_->Reset(); | |
| 1663 use_mock_theme_ = true; | 1659 use_mock_theme_ = true; |
| 1664 pointer_locked_ = false; | 1660 pointer_locked_ = false; |
| 1665 pointer_lock_planned_result_ = PointerLockWillSucceed; | 1661 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 1666 | 1662 |
| 1667 task_list_.RevokeAll(); | 1663 task_list_.RevokeAll(); |
| 1668 work_queue_.Reset(); | 1664 work_queue_.Reset(); |
| 1669 | 1665 |
| 1670 if (close_remaining_windows_ && delegate_) | 1666 if (close_remaining_windows_ && delegate_) |
| 1671 delegate_->CloseRemainingWindows(); | 1667 delegate_->CloseRemainingWindows(); |
| 1672 else | 1668 else |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1872 } | 1868 } |
| 1873 | 1869 |
| 1874 bool TestRunner::shouldInterceptPostMessage() const { | 1870 bool TestRunner::shouldInterceptPostMessage() const { |
| 1875 return intercept_post_message_; | 1871 return intercept_post_message_; |
| 1876 } | 1872 } |
| 1877 | 1873 |
| 1878 bool TestRunner::shouldDumpResourcePriorities() const { | 1874 bool TestRunner::shouldDumpResourcePriorities() const { |
| 1879 return should_dump_resource_priorities_; | 1875 return should_dump_resource_priorities_; |
| 1880 } | 1876 } |
| 1881 | 1877 |
| 1882 WebNotificationPresenter* TestRunner::notification_presenter() const { | |
| 1883 return notification_presenter_.get(); | |
| 1884 } | |
| 1885 | |
| 1886 bool TestRunner::RequestPointerLock() { | 1878 bool TestRunner::RequestPointerLock() { |
| 1887 switch (pointer_lock_planned_result_) { | 1879 switch (pointer_lock_planned_result_) { |
| 1888 case PointerLockWillSucceed: | 1880 case PointerLockWillSucceed: |
| 1889 delegate_->PostDelayedTask( | 1881 delegate_->PostDelayedTask( |
| 1890 new HostMethodTask(this, &TestRunner::DidAcquirePointerLockInternal), | 1882 new HostMethodTask(this, &TestRunner::DidAcquirePointerLockInternal), |
| 1891 0); | 1883 0); |
| 1892 return true; | 1884 return true; |
| 1893 case PointerLockWillRespondAsync: | 1885 case PointerLockWillRespondAsync: |
| 1894 DCHECK(!pointer_locked_); | 1886 DCHECK(!pointer_locked_); |
| 1895 return true; | 1887 return true; |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2769 bool permission_granted) { | 2761 bool permission_granted) { |
| 2770 delegate_->GrantWebNotificationPermission(origin, permission_granted); | 2762 delegate_->GrantWebNotificationPermission(origin, permission_granted); |
| 2771 } | 2763 } |
| 2772 | 2764 |
| 2773 void TestRunner::ClearWebNotificationPermissions() { | 2765 void TestRunner::ClearWebNotificationPermissions() { |
| 2774 delegate_->ClearWebNotificationPermissions(); | 2766 delegate_->ClearWebNotificationPermissions(); |
| 2775 } | 2767 } |
| 2776 | 2768 |
| 2777 void TestRunner::SimulateWebNotificationClick(const std::string& title) { | 2769 void TestRunner::SimulateWebNotificationClick(const std::string& title) { |
| 2778 delegate_->SimulateWebNotificationClick(title); | 2770 delegate_->SimulateWebNotificationClick(title); |
| 2779 | |
| 2780 // TODO(peter): Remove this call once Web Notifications switch away from the | |
| 2781 // WebFrame-based code path. | |
| 2782 notification_presenter_->SimulateClick(title); | |
| 2783 } | 2771 } |
| 2784 | 2772 |
| 2785 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, | 2773 void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript, |
| 2786 double confidence) { | 2774 double confidence) { |
| 2787 proxy_->GetSpeechRecognizerMock()->AddMockResult( | 2775 proxy_->GetSpeechRecognizerMock()->AddMockResult( |
| 2788 WebString::fromUTF8(transcript), confidence); | 2776 WebString::fromUTF8(transcript), confidence); |
| 2789 } | 2777 } |
| 2790 | 2778 |
| 2791 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, | 2779 void TestRunner::SetMockSpeechRecognitionError(const std::string& error, |
| 2792 const std::string& message) { | 2780 const std::string& message) { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2975 } | 2963 } |
| 2976 | 2964 |
| 2977 void TestRunner::DidLosePointerLockInternal() { | 2965 void TestRunner::DidLosePointerLockInternal() { |
| 2978 bool was_locked = pointer_locked_; | 2966 bool was_locked = pointer_locked_; |
| 2979 pointer_locked_ = false; | 2967 pointer_locked_ = false; |
| 2980 if (was_locked) | 2968 if (was_locked) |
| 2981 web_view_->didLosePointerLock(); | 2969 web_view_->didLosePointerLock(); |
| 2982 } | 2970 } |
| 2983 | 2971 |
| 2984 } // namespace content | 2972 } // namespace content |
| OLD | NEW |