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/mock_credential_manager_client.h" | 18 #include "components/test_runner/mock_credential_manager_client.h" |
19 #include "components/test_runner/mock_screen_orientation_client.h" | |
19 #include "components/test_runner/mock_web_speech_recognizer.h" | 20 #include "components/test_runner/mock_web_speech_recognizer.h" |
20 #include "components/test_runner/test_interfaces.h" | 21 #include "components/test_runner/test_interfaces.h" |
21 #include "components/test_runner/test_preferences.h" | 22 #include "components/test_runner/test_preferences.h" |
22 #include "components/test_runner/web_content_settings.h" | 23 #include "components/test_runner/web_content_settings.h" |
23 #include "components/test_runner/web_test_delegate.h" | 24 #include "components/test_runner/web_test_delegate.h" |
24 #include "components/test_runner/web_test_proxy.h" | 25 #include "components/test_runner/web_test_proxy.h" |
25 #include "gin/arguments.h" | 26 #include "gin/arguments.h" |
26 #include "gin/array_buffer.h" | 27 #include "gin/array_buffer.h" |
27 #include "gin/handle.h" | 28 #include "gin/handle.h" |
28 #include "gin/object_template_builder.h" | 29 #include "gin/object_template_builder.h" |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 TestRunner::TestRunner(TestInterfaces* interfaces) | 1657 TestRunner::TestRunner(TestInterfaces* interfaces) |
1657 : test_is_running_(false), | 1658 : test_is_running_(false), |
1658 close_remaining_windows_(false), | 1659 close_remaining_windows_(false), |
1659 work_queue_(this), | 1660 work_queue_(this), |
1660 web_history_item_count_(0), | 1661 web_history_item_count_(0), |
1661 intercept_post_message_(false), | 1662 intercept_post_message_(false), |
1662 test_interfaces_(interfaces), | 1663 test_interfaces_(interfaces), |
1663 delegate_(nullptr), | 1664 delegate_(nullptr), |
1664 web_view_(nullptr), | 1665 web_view_(nullptr), |
1665 web_content_settings_(new WebContentSettings()), | 1666 web_content_settings_(new WebContentSettings()), |
1667 mock_screen_orientation_client_(new MockScreenOrientationClient), | |
1666 weak_factory_(this) {} | 1668 weak_factory_(this) {} |
1667 | 1669 |
1668 TestRunner::~TestRunner() {} | 1670 TestRunner::~TestRunner() {} |
1669 | 1671 |
1670 void TestRunner::Install(WebFrame* frame) { | 1672 void TestRunner::Install(WebFrame* frame) { |
1671 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 1673 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
1672 } | 1674 } |
1673 | 1675 |
1674 void TestRunner::SetDelegate(WebTestDelegate* delegate) { | 1676 void TestRunner::SetDelegate(WebTestDelegate* delegate) { |
1675 delegate_ = delegate; | 1677 delegate_ = delegate; |
(...skipping 17 matching lines...) Expand all Loading... | |
1693 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); | 1695 0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232); |
1694 #endif | 1696 #endif |
1695 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); | 1697 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); |
1696 web_view_->mainFrame()->enableViewSourceMode(false); | 1698 web_view_->mainFrame()->enableViewSourceMode(false); |
1697 | 1699 |
1698 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); | 1700 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); |
1699 } | 1701 } |
1700 | 1702 |
1701 top_loading_frame_ = nullptr; | 1703 top_loading_frame_ = nullptr; |
1702 layout_dump_flags_.Reset(); | 1704 layout_dump_flags_.Reset(); |
1705 mock_screen_orientation_client_->ResetData(); | |
Łukasz Anforowicz
2016/03/16 00:16:01
This just copies method body from the deleted Blin
| |
1703 wait_until_external_url_load_ = false; | 1706 wait_until_external_url_load_ = false; |
1704 policy_delegate_enabled_ = false; | 1707 policy_delegate_enabled_ = false; |
1705 policy_delegate_is_permissive_ = false; | 1708 policy_delegate_is_permissive_ = false; |
1706 policy_delegate_should_notify_done_ = false; | 1709 policy_delegate_should_notify_done_ = false; |
1707 | 1710 |
1708 WebSecurityPolicy::resetOriginAccessWhitelists(); | 1711 WebSecurityPolicy::resetOriginAccessWhitelists(); |
1709 #if defined(__linux__) || defined(ANDROID) | 1712 #if defined(__linux__) || defined(ANDROID) |
1710 WebFontRendering::setSubpixelPositioning(false); | 1713 WebFontRendering::setSubpixelPositioning(false); |
1711 #endif | 1714 #endif |
1712 | 1715 |
1713 if (delegate_) { | 1716 if (delegate_) { |
1714 // Reset the default quota for each origin to 5MB | 1717 // Reset the default quota for each origin to 5MB |
1715 delegate_->SetDatabaseQuota(5 * 1024 * 1024); | 1718 delegate_->SetDatabaseQuota(5 * 1024 * 1024); |
1716 delegate_->SetDeviceColorProfile("reset"); | 1719 delegate_->SetDeviceColorProfile("reset"); |
1717 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); | 1720 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor()); |
1718 delegate_->SetAcceptAllCookies(false); | 1721 delegate_->SetAcceptAllCookies(false); |
1719 delegate_->SetLocale(""); | 1722 delegate_->SetLocale(""); |
1720 delegate_->UseUnfortunateSynchronousResizeMode(false); | 1723 delegate_->UseUnfortunateSynchronousResizeMode(false); |
1721 delegate_->DisableAutoResizeMode(WebSize()); | 1724 delegate_->DisableAutoResizeMode(WebSize()); |
1722 delegate_->DeleteAllCookies(); | 1725 delegate_->DeleteAllCookies(); |
1723 delegate_->ResetScreenOrientation(); | |
1724 delegate_->SetBluetoothMockDataSet(""); | 1726 delegate_->SetBluetoothMockDataSet(""); |
1725 delegate_->ClearGeofencingMockProvider(); | 1727 delegate_->ClearGeofencingMockProvider(); |
1726 delegate_->ResetPermissions(); | 1728 delegate_->ResetPermissions(); |
1727 ResetDeviceLight(); | 1729 ResetDeviceLight(); |
1728 } | 1730 } |
1729 | 1731 |
1730 dump_editting_callbacks_ = false; | 1732 dump_editting_callbacks_ = false; |
1731 dump_icon_changes_ = false; | 1733 dump_icon_changes_ = false; |
1732 dump_as_audio_ = false; | 1734 dump_as_audio_ = false; |
1733 dump_frame_load_callbacks_ = false; | 1735 dump_frame_load_callbacks_ = false; |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2493 // gamma | 2495 // gamma |
2494 orientation.hasGamma = has_gamma; | 2496 orientation.hasGamma = has_gamma; |
2495 orientation.gamma = gamma; | 2497 orientation.gamma = gamma; |
2496 | 2498 |
2497 // absolute | 2499 // absolute |
2498 orientation.absolute = absolute; | 2500 orientation.absolute = absolute; |
2499 | 2501 |
2500 delegate_->SetDeviceOrientationData(orientation); | 2502 delegate_->SetDeviceOrientationData(orientation); |
2501 } | 2503 } |
2502 | 2504 |
2505 MockScreenOrientationClient* TestRunner::getMockScreenOrientationClient() { | |
2506 return mock_screen_orientation_client_.get(); | |
2507 } | |
2508 | |
2503 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { | 2509 void TestRunner::SetMockScreenOrientation(const std::string& orientation_str) { |
2504 blink::WebScreenOrientationType orientation; | 2510 blink::WebScreenOrientationType orientation; |
2505 | 2511 |
2506 if (orientation_str == "portrait-primary") { | 2512 if (orientation_str == "portrait-primary") { |
2507 orientation = WebScreenOrientationPortraitPrimary; | 2513 orientation = WebScreenOrientationPortraitPrimary; |
2508 } else if (orientation_str == "portrait-secondary") { | 2514 } else if (orientation_str == "portrait-secondary") { |
2509 orientation = WebScreenOrientationPortraitSecondary; | 2515 orientation = WebScreenOrientationPortraitSecondary; |
2510 } else if (orientation_str == "landscape-primary") { | 2516 } else if (orientation_str == "landscape-primary") { |
2511 orientation = WebScreenOrientationLandscapePrimary; | 2517 orientation = WebScreenOrientationLandscapePrimary; |
2512 } else if (orientation_str == "landscape-secondary") { | 2518 } else { |
2519 DCHECK_EQ("landscape-secondary", orientation_str); | |
Łukasz Anforowicz
2016/03/16 00:16:00
Otherwise |orientation| might not be initialized a
| |
2513 orientation = WebScreenOrientationLandscapeSecondary; | 2520 orientation = WebScreenOrientationLandscapeSecondary; |
2514 } | 2521 } |
2515 | 2522 |
2516 delegate_->SetScreenOrientation(orientation); | 2523 // TODO(lukasza): This is broken for OOPIFs. |
2524 WebLocalFrame* main_frame = web_view_->mainFrame()->toWebLocalFrame(); | |
2525 mock_screen_orientation_client_->UpdateDeviceOrientation( | |
2526 main_frame, orientation); | |
Łukasz Anforowicz
2016/03/16 00:16:00
This just copies method body from the deleted Blin
| |
2517 } | 2527 } |
2518 | 2528 |
2519 void TestRunner::DisableMockScreenOrientation() { | 2529 void TestRunner::DisableMockScreenOrientation() { |
2520 delegate_->DisableMockScreenOrientation(); | 2530 mock_screen_orientation_client_->SetDisabled(true); |
Łukasz Anforowicz
2016/03/16 00:16:01
This just copies method body from the deleted Blin
| |
2521 } | 2531 } |
2522 | 2532 |
2523 void TestRunner::DidAcquirePointerLock() { | 2533 void TestRunner::DidAcquirePointerLock() { |
2524 DidAcquirePointerLockInternal(); | 2534 DidAcquirePointerLockInternal(); |
2525 } | 2535 } |
2526 | 2536 |
2527 void TestRunner::DidNotAcquirePointerLock() { | 2537 void TestRunner::DidNotAcquirePointerLock() { |
2528 DidNotAcquirePointerLockInternal(); | 2538 DidNotAcquirePointerLockInternal(); |
2529 } | 2539 } |
2530 | 2540 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3203 } | 3213 } |
3204 | 3214 |
3205 void TestRunner::DidLosePointerLockInternal() { | 3215 void TestRunner::DidLosePointerLockInternal() { |
3206 bool was_locked = pointer_locked_; | 3216 bool was_locked = pointer_locked_; |
3207 pointer_locked_ = false; | 3217 pointer_locked_ = false; |
3208 if (was_locked) | 3218 if (was_locked) |
3209 web_view_->didLosePointerLock(); | 3219 web_view_->didLosePointerLock(); |
3210 } | 3220 } |
3211 | 3221 |
3212 } // namespace test_runner | 3222 } // namespace test_runner |
OLD | NEW |