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