| 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" | |
| 23 #include "components/test_runner/test_interfaces.h" | 22 #include "components/test_runner/test_interfaces.h" |
| 24 #include "components/test_runner/test_preferences.h" | 23 #include "components/test_runner/test_preferences.h" |
| 25 #include "components/test_runner/web_content_settings.h" | 24 #include "components/test_runner/web_content_settings.h" |
| 26 #include "components/test_runner/web_test_delegate.h" | 25 #include "components/test_runner/web_test_delegate.h" |
| 27 #include "components/test_runner/web_test_proxy.h" | 26 #include "components/test_runner/web_test_proxy.h" |
| 28 #include "gin/arguments.h" | 27 #include "gin/arguments.h" |
| 29 #include "gin/array_buffer.h" | 28 #include "gin/array_buffer.h" |
| 30 #include "gin/handle.h" | 29 #include "gin/handle.h" |
| 31 #include "gin/object_template_builder.h" | 30 #include "gin/object_template_builder.h" |
| 32 #include "gin/wrappable.h" | 31 #include "gin/wrappable.h" |
| (...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 : test_is_running_(false), | 1661 : test_is_running_(false), |
| 1663 close_remaining_windows_(false), | 1662 close_remaining_windows_(false), |
| 1664 work_queue_(this), | 1663 work_queue_(this), |
| 1665 web_history_item_count_(0), | 1664 web_history_item_count_(0), |
| 1666 intercept_post_message_(false), | 1665 intercept_post_message_(false), |
| 1667 test_interfaces_(interfaces), | 1666 test_interfaces_(interfaces), |
| 1668 delegate_(nullptr), | 1667 delegate_(nullptr), |
| 1669 web_view_(nullptr), | 1668 web_view_(nullptr), |
| 1670 web_content_settings_(new WebContentSettings()), | 1669 web_content_settings_(new WebContentSettings()), |
| 1671 mock_screen_orientation_client_(new MockScreenOrientationClient), | 1670 mock_screen_orientation_client_(new MockScreenOrientationClient), |
| 1672 chooser_count_(0), | |
| 1673 weak_factory_(this) {} | 1671 weak_factory_(this) {} |
| 1674 | 1672 |
| 1675 TestRunner::~TestRunner() {} | 1673 TestRunner::~TestRunner() {} |
| 1676 | 1674 |
| 1677 void TestRunner::Install(WebFrame* frame) { | 1675 void TestRunner::Install(WebFrame* frame) { |
| 1678 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1676 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 1679 } | 1677 } |
| 1680 | 1678 |
| 1681 void TestRunner::SetDelegate(WebTestDelegate* delegate) { | 1679 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
| 1682 delegate_ = delegate; | 1680 delegate_ = delegate; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1757 midi_accessor_result_ = true; | 1755 midi_accessor_result_ = true; |
| 1758 should_stay_on_page_after_handling_before_unload_ = false; | 1756 should_stay_on_page_after_handling_before_unload_ = false; |
| 1759 should_dump_resource_priorities_ = false; | 1757 should_dump_resource_priorities_ = false; |
| 1760 has_custom_text_output_ = false; | 1758 has_custom_text_output_ = false; |
| 1761 custom_text_output_.clear(); | 1759 custom_text_output_.clear(); |
| 1762 | 1760 |
| 1763 http_headers_to_clear_.clear(); | 1761 http_headers_to_clear_.clear(); |
| 1764 | 1762 |
| 1765 platform_name_ = "chromium"; | 1763 platform_name_ = "chromium"; |
| 1766 tooltip_text_ = std::string(); | 1764 tooltip_text_ = std::string(); |
| 1767 chooser_count_ = 0; | |
| 1768 web_history_item_count_ = 0; | 1765 web_history_item_count_ = 0; |
| 1769 intercept_post_message_ = false; | 1766 intercept_post_message_ = false; |
| 1770 | 1767 |
| 1771 web_content_settings_->Reset(); | 1768 web_content_settings_->Reset(); |
| 1772 | 1769 |
| 1773 SetUseMockTheme(true); | 1770 SetUseMockTheme(true); |
| 1774 | 1771 |
| 1775 pointer_locked_ = false; | 1772 pointer_locked_ = false; |
| 1776 pointer_lock_planned_result_ = PointerLockWillSucceed; | 1773 pointer_lock_planned_result_ = PointerLockWillSucceed; |
| 1777 | 1774 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 // absolute | 2508 // absolute |
| 2512 orientation.absolute = absolute; | 2509 orientation.absolute = absolute; |
| 2513 | 2510 |
| 2514 delegate_->SetDeviceOrientationData(orientation); | 2511 delegate_->SetDeviceOrientationData(orientation); |
| 2515 } | 2512 } |
| 2516 | 2513 |
| 2517 MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() { | 2514 MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() { |
| 2518 return mock_screen_orientation_client_.get(); | 2515 return mock_screen_orientation_client_.get(); |
| 2519 } | 2516 } |
| 2520 | 2517 |
| 2521 MockWebUserMediaClient* TestRunner::getMockWebUserMediaClient() { | |
| 2522 if (!user_media_client_.get()) | |
| 2523 user_media_client_.reset(new MockWebUserMediaClient(delegate_)); | |
| 2524 return user_media_client_.get(); | |
| 2525 } | |
| 2526 | |
| 2527 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { | 2518 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { |
| 2528 blink::WebScreenOrientationType orientation; | 2519 blink::WebScreenOrientationType orientation; |
| 2529 | 2520 |
| 2530 if (orientation_str == "portrait-primary") { | 2521 if (orientation_str == "portrait-primary") { |
| 2531 orientation = WebScreenOrientationPortraitPrimary; | 2522 orientation = WebScreenOrientationPortraitPrimary; |
| 2532 } else if (orientation_str == "portrait-secondary") { | 2523 } else if (orientation_str == "portrait-secondary") { |
| 2533 orientation = WebScreenOrientationPortraitSecondary; | 2524 orientation = WebScreenOrientationPortraitSecondary; |
| 2534 } else if (orientation_str == "landscape-primary") { | 2525 } else if (orientation_str == "landscape-primary") { |
| 2535 orientation = WebScreenOrientationLandscapePrimary; | 2526 orientation = WebScreenOrientationLandscapePrimary; |
| 2536 } else { | 2527 } else { |
| 2537 DCHECK_EQ("landscape-secondary", orientation_str); | 2528 DCHECK_EQ("landscape-secondary", orientation_str); |
| 2538 orientation = WebScreenOrientationLandscapeSecondary; | 2529 orientation = WebScreenOrientationLandscapeSecondary; |
| 2539 } | 2530 } |
| 2540 | 2531 |
| 2541 // TODO(lukasza): This is broken for OOPIFs. | 2532 // TODO(lukasza): This is broken for OOPIFs. |
| 2542 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); | 2533 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); |
| 2543 mock_screen_orientation_client_->UpdateDeviceOrientation( | 2534 mock_screen_orientation_client_->UpdateDeviceOrientation( |
| 2544 main_frame, orientation); | 2535 main_frame, orientation); |
| 2545 } | 2536 } |
| 2546 | 2537 |
| 2547 void TestRunner::DisableMockScreenOrientation() { | 2538 void TestRunner::DisableMockScreenOrientation() { |
| 2548 mock_screen_orientation_client_->SetDisabled(true); | 2539 mock_screen_orientation_client_->SetDisabled(true); |
| 2549 } | 2540 } |
| 2550 | 2541 |
| 2551 void TestRunner::DidOpenChooser() { | |
| 2552 chooser_count_++; | |
| 2553 } | |
| 2554 | |
| 2555 void TestRunner::DidCloseChooser() { | |
| 2556 chooser_count_--; | |
| 2557 } | |
| 2558 | |
| 2559 void TestRunner::DidAcquirePointerLock() { | 2542 void TestRunner::DidAcquirePointerLock() { |
| 2560 DidAcquirePointerLockInternal(); | 2543 DidAcquirePointerLockInternal(); |
| 2561 } | 2544 } |
| 2562 | 2545 |
| 2563 void TestRunner::DidNotAcquirePointerLock() { | 2546 void TestRunner::DidNotAcquirePointerLock() { |
| 2564 DidNotAcquirePointerLockInternal(); | 2547 DidNotAcquirePointerLockInternal(); |
| 2565 } | 2548 } |
| 2566 | 2549 |
| 2567 void TestRunner::DidLosePointerLock() { | 2550 void TestRunner::DidLosePointerLock() { |
| 2568 DidLosePointerLockInternal(); | 2551 DidLosePointerLockInternal(); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2858 signals->issuedNonGetFetchFromScript() ? "true" : "false"); | 2841 signals->issuedNonGetFetchFromScript() ? "true" : "false"); |
| 2859 if (delegate_) | 2842 if (delegate_) |
| 2860 delegate_->PrintMessage(message); | 2843 delegate_->PrintMessage(message); |
| 2861 } | 2844 } |
| 2862 | 2845 |
| 2863 void TestRunner::CloseWebInspector() { | 2846 void TestRunner::CloseWebInspector() { |
| 2864 delegate_->CloseDevTools(); | 2847 delegate_->CloseDevTools(); |
| 2865 } | 2848 } |
| 2866 | 2849 |
| 2867 bool TestRunner::IsChooserShown() { | 2850 bool TestRunner::IsChooserShown() { |
| 2868 return 0 < chooser_count_; | 2851 return proxy_->IsChooserShown(); |
| 2869 } | 2852 } |
| 2870 | 2853 |
| 2871 void TestRunner::EvaluateInWebInspector(int call_id, | 2854 void TestRunner::EvaluateInWebInspector(int call_id, |
| 2872 const std::string& script) { | 2855 const std::string& script) { |
| 2873 delegate_->EvaluateInWebInspector(call_id, script); | 2856 delegate_->EvaluateInWebInspector(call_id, script); |
| 2874 } | 2857 } |
| 2875 | 2858 |
| 2876 std::string TestRunner::EvaluateInWebInspectorOverlay( | 2859 std::string TestRunner::EvaluateInWebInspectorOverlay( |
| 2877 const std::string& script) { | 2860 const std::string& script) { |
| 2878 return delegate_->EvaluateInWebInspectorOverlay(script); | 2861 return delegate_->EvaluateInWebInspectorOverlay(script); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 } | 3222 } |
| 3240 | 3223 |
| 3241 void TestRunner::DidLosePointerLockInternal() { | 3224 void TestRunner::DidLosePointerLockInternal() { |
| 3242 bool was_locked = pointer_locked_; | 3225 bool was_locked = pointer_locked_; |
| 3243 pointer_locked_ = false; | 3226 pointer_locked_ = false; |
| 3244 if (was_locked) | 3227 if (was_locked) |
| 3245 web_view_->didLosePointerLock(); | 3228 web_view_->didLosePointerLock(); |
| 3246 } | 3229 } |
| 3247 | 3230 |
| 3248 } // namespace test_runner | 3231 } // namespace test_runner |
| OLD | NEW |