| 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 "components/test_runner/test_runner.h" | 5 #include "components/test_runner/test_runner.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "components/test_runner/app_banner_client.h" | 17 #include "components/test_runner/app_banner_client.h" |
| 18 #include "components/test_runner/layout_dump.h" | 18 #include "components/test_runner/layout_dump.h" |
| 19 #include "components/test_runner/mock_credential_manager_client.h" | 19 #include "components/test_runner/mock_credential_manager_client.h" |
| 20 #include "components/test_runner/mock_screen_orientation_client.h" | 20 #include "components/test_runner/mock_screen_orientation_client.h" |
| 21 #include "components/test_runner/mock_web_speech_recognizer.h" | 21 #include "components/test_runner/mock_web_speech_recognizer.h" |
| 22 #include "components/test_runner/mock_web_user_media_client.h" | 22 #include "components/test_runner/mock_web_user_media_client.h" |
| 23 #include "components/test_runner/pixel_dump.h" | 23 #include "components/test_runner/pixel_dump.h" |
| 24 #include "components/test_runner/spell_check_client.h" |
| 24 #include "components/test_runner/test_interfaces.h" | 25 #include "components/test_runner/test_interfaces.h" |
| 25 #include "components/test_runner/test_preferences.h" | 26 #include "components/test_runner/test_preferences.h" |
| 26 #include "components/test_runner/web_content_settings.h" | 27 #include "components/test_runner/web_content_settings.h" |
| 27 #include "components/test_runner/web_test_delegate.h" | 28 #include "components/test_runner/web_test_delegate.h" |
| 28 #include "components/test_runner/web_test_proxy.h" | 29 #include "components/test_runner/web_test_proxy.h" |
| 29 #include "gin/arguments.h" | 30 #include "gin/arguments.h" |
| 30 #include "gin/array_buffer.h" | 31 #include "gin/array_buffer.h" |
| 31 #include "gin/handle.h" | 32 #include "gin/handle.h" |
| 32 #include "gin/object_template_builder.h" | 33 #include "gin/object_template_builder.h" |
| 33 #include "gin/wrappable.h" | 34 #include "gin/wrappable.h" |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 TestRunner::TestRunner(TestInterfaces* interfaces) | 1664 TestRunner::TestRunner(TestInterfaces* interfaces) |
| 1664 : test_is_running_(false), | 1665 : test_is_running_(false), |
| 1665 close_remaining_windows_(false), | 1666 close_remaining_windows_(false), |
| 1666 work_queue_(this), | 1667 work_queue_(this), |
| 1667 web_history_item_count_(0), | 1668 web_history_item_count_(0), |
| 1668 intercept_post_message_(false), | 1669 intercept_post_message_(false), |
| 1669 test_interfaces_(interfaces), | 1670 test_interfaces_(interfaces), |
| 1670 delegate_(nullptr), | 1671 delegate_(nullptr), |
| 1671 web_view_(nullptr), | 1672 web_view_(nullptr), |
| 1672 web_content_settings_(new WebContentSettings()), | 1673 web_content_settings_(new WebContentSettings()), |
| 1674 credential_manager_client_(new MockCredentialManagerClient), |
| 1673 mock_screen_orientation_client_(new MockScreenOrientationClient), | 1675 mock_screen_orientation_client_(new MockScreenOrientationClient), |
| 1676 spellcheck_(new SpellCheckClient(this)), |
| 1674 chooser_count_(0), | 1677 chooser_count_(0), |
| 1675 weak_factory_(this) {} | 1678 weak_factory_(this) {} |
| 1676 | 1679 |
| 1677 TestRunner::~TestRunner() {} | 1680 TestRunner::~TestRunner() {} |
| 1678 | 1681 |
| 1679 void TestRunner::Install(WebFrame* frame) { | 1682 void TestRunner::Install(WebFrame* frame) { |
| 1680 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1683 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 1681 } | 1684 } |
| 1682 | 1685 |
| 1683 void TestRunner::SetDelegate(WebTestDelegate* delegate) { | 1686 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
| 1684 delegate_ = delegate; | 1687 delegate_ = delegate; |
| 1685 web_content_settings_->SetDelegate(delegate); | 1688 web_content_settings_->SetDelegate(delegate); |
| 1689 spellcheck_->SetDelegate(delegate); |
| 1686 if (speech_recognizer_) | 1690 if (speech_recognizer_) |
| 1687 speech_recognizer_->SetDelegate(delegate); | 1691 speech_recognizer_->SetDelegate(delegate); |
| 1688 } | 1692 } |
| 1689 | 1693 |
| 1690 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { | 1694 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { |
| 1691 web_view_ = webView; | 1695 web_view_ = webView; |
| 1692 proxy_ = proxy; | 1696 proxy_ = proxy; |
| 1693 } | 1697 } |
| 1694 | 1698 |
| 1695 void TestRunner::Reset() { | 1699 void TestRunner::Reset() { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1942 } | 1946 } |
| 1943 | 1947 |
| 1944 bool TestRunner::shouldDumpResourceResponseMIMETypes() const { | 1948 bool TestRunner::shouldDumpResourceResponseMIMETypes() const { |
| 1945 return test_is_running_ && dump_resource_response_mime_types_; | 1949 return test_is_running_ && dump_resource_response_mime_types_; |
| 1946 } | 1950 } |
| 1947 | 1951 |
| 1948 WebContentSettingsClient* TestRunner::GetWebContentSettings() const { | 1952 WebContentSettingsClient* TestRunner::GetWebContentSettings() const { |
| 1949 return web_content_settings_.get(); | 1953 return web_content_settings_.get(); |
| 1950 } | 1954 } |
| 1951 | 1955 |
| 1956 void TestRunner::InitializeWebViewWithMocks(blink::WebView* web_view) { |
| 1957 web_view->setSpellCheckClient(spellcheck_.get()); |
| 1958 web_view->setCredentialManagerClient(credential_manager_client_.get()); |
| 1959 } |
| 1960 |
| 1952 bool TestRunner::shouldDumpStatusCallbacks() const { | 1961 bool TestRunner::shouldDumpStatusCallbacks() const { |
| 1953 return dump_window_status_changes_; | 1962 return dump_window_status_changes_; |
| 1954 } | 1963 } |
| 1955 | 1964 |
| 1956 bool TestRunner::shouldDumpSpellCheckCallbacks() const { | 1965 bool TestRunner::shouldDumpSpellCheckCallbacks() const { |
| 1957 return dump_spell_check_callbacks_; | 1966 return dump_spell_check_callbacks_; |
| 1958 } | 1967 } |
| 1959 | 1968 |
| 1960 bool TestRunner::ShouldDumpBackForwardList() const { | 1969 bool TestRunner::ShouldDumpBackForwardList() const { |
| 1961 return dump_back_forward_list_; | 1970 return dump_back_forward_list_; |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3072 } | 3081 } |
| 3073 | 3082 |
| 3074 bool TestRunner::WasMockSpeechRecognitionAborted() { | 3083 bool TestRunner::WasMockSpeechRecognitionAborted() { |
| 3075 return getMockWebSpeechRecognizer()->WasAborted(); | 3084 return getMockWebSpeechRecognizer()->WasAborted(); |
| 3076 } | 3085 } |
| 3077 | 3086 |
| 3078 void TestRunner::AddMockCredentialManagerResponse(const std::string& id, | 3087 void TestRunner::AddMockCredentialManagerResponse(const std::string& id, |
| 3079 const std::string& name, | 3088 const std::string& name, |
| 3080 const std::string& avatar, | 3089 const std::string& avatar, |
| 3081 const std::string& password) { | 3090 const std::string& password) { |
| 3082 proxy_->GetCredentialManagerClientMock()->SetResponse( | 3091 credential_manager_client_->SetResponse(new WebPasswordCredential( |
| 3083 new WebPasswordCredential(WebString::fromUTF8(id), | 3092 WebString::fromUTF8(id), WebString::fromUTF8(password), |
| 3084 WebString::fromUTF8(password), | 3093 WebString::fromUTF8(name), WebURL(GURL(avatar)))); |
| 3085 WebString::fromUTF8(name), | |
| 3086 WebURL(GURL(avatar)))); | |
| 3087 } | 3094 } |
| 3088 | 3095 |
| 3089 void TestRunner::AddMockCredentialManagerError(const std::string& error) { | 3096 void TestRunner::AddMockCredentialManagerError(const std::string& error) { |
| 3090 proxy_->GetCredentialManagerClientMock()->SetError(error); | 3097 credential_manager_client_->SetError(error); |
| 3091 } | 3098 } |
| 3092 | 3099 |
| 3093 void TestRunner::AddWebPageOverlay() { | 3100 void TestRunner::AddWebPageOverlay() { |
| 3094 if (web_view_) | 3101 if (web_view_) |
| 3095 web_view_->setPageOverlayColor(SK_ColorCYAN); | 3102 web_view_->setPageOverlayColor(SK_ColorCYAN); |
| 3096 } | 3103 } |
| 3097 | 3104 |
| 3098 void TestRunner::RemoveWebPageOverlay() { | 3105 void TestRunner::RemoveWebPageOverlay() { |
| 3099 if (web_view_) | 3106 if (web_view_) |
| 3100 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); | 3107 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3305 } | 3312 } |
| 3306 | 3313 |
| 3307 void TestRunner::DidLosePointerLockInternal() { | 3314 void TestRunner::DidLosePointerLockInternal() { |
| 3308 bool was_locked = pointer_locked_; | 3315 bool was_locked = pointer_locked_; |
| 3309 pointer_locked_ = false; | 3316 pointer_locked_ = false; |
| 3310 if (was_locked) | 3317 if (was_locked) |
| 3311 web_view_->didLosePointerLock(); | 3318 web_view_->didLosePointerLock(); |
| 3312 } | 3319 } |
| 3313 | 3320 |
| 3314 } // namespace test_runner | 3321 } // namespace test_runner |
| OLD | NEW |