Chromium Code Reviews| Index: third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp |
| diff --git a/third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp b/third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp |
| index 3e831ea97dae1ff90b2ef0580a3474f1a1abbeae..789bcb0a94da48a27189a0ed78cade18b04bc71a 100644 |
| --- a/third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp |
| +++ b/third_party/WebKit/Source/modules/media_controls/MediaControlsRotateToFullscreenDelegateTest.cpp |
| @@ -17,15 +17,18 @@ |
| #include "core/loader/EmptyClients.h" |
| #include "core/testing/DummyPageHolder.h" |
| #include "modules/media_controls/MediaControlsImpl.h" |
| +#include "modules/screen_orientation/ScreenOrientationControllerImpl.h" |
| #include "platform/UserGestureIndicator.h" |
| #include "platform/testing/EmptyWebMediaPlayer.h" |
| #include "platform/testing/UnitTestHelpers.h" |
| #include "platform/wtf/text/AtomicString.h" |
| #include "public/platform/WebSize.h" |
| +#include "public/platform/modules/screen_orientation/WebScreenOrientationClient.h" |
| #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +using ::testing::AtLeast; |
| using ::testing::Return; |
| namespace blink { |
| @@ -34,6 +37,14 @@ using namespace HTMLNames; |
| namespace { |
| +class FakeWebScreenOrientationClient : public WebScreenOrientationClient { |
| + public: |
| + // WebScreenOrientationClient overrides: |
| + void LockOrientation(WebScreenOrientationLockType, |
| + std::unique_ptr<WebLockOrientationCallback>) override {} |
| + void UnlockOrientation() override {} |
| +}; |
| + |
| class MockVideoWebMediaPlayer : public EmptyWebMediaPlayer { |
| public: |
| // ChromeClient overrides: |
| @@ -45,6 +56,11 @@ class MockVideoWebMediaPlayer : public EmptyWebMediaPlayer { |
| class MockChromeClient : public EmptyChromeClient { |
| public: |
| // ChromeClient overrides: |
| + void InstallSupplements(LocalFrame& frame) override { |
| + EmptyChromeClient::InstallSupplements(frame); |
| + ScreenOrientationControllerImpl::ProvideTo(frame, |
| + &web_screen_orientation_client); |
| + } |
| void EnterFullscreen(LocalFrame& frame) override { |
| Fullscreen::From(*frame.GetDocument()).DidEnterFullscreen(); |
| } |
| @@ -53,6 +69,9 @@ class MockChromeClient : public EmptyChromeClient { |
| } |
| MOCK_CONST_METHOD0(GetScreenInfo, WebScreenInfo()); |
| + |
| + private: |
| + FakeWebScreenOrientationClient web_screen_orientation_client; |
|
mlamouri (slow - plz ping)
2017/05/24 17:03:41
style: you are missing a _
johnme
2017/05/24 17:17:42
Done.
|
| }; |
| class StubLocalFrameClient : public EmptyLocalFrameClient { |
| @@ -77,7 +96,10 @@ class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { |
| void SetUp() override { |
| previous_video_rotate_to_fullscreen_value_ = |
| RuntimeEnabledFeatures::videoRotateToFullscreenEnabled(); |
| + previous_video_fullscreen_orientation_lock_value_ = |
| + RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled(); |
| RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(true); |
| + RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled(true); |
| chrome_client_ = new MockChromeClient(); |
| @@ -97,6 +119,8 @@ class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { |
| void TearDown() override { |
| RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled( |
| previous_video_rotate_to_fullscreen_value_); |
| + RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled( |
| + previous_video_fullscreen_orientation_lock_value_); |
| } |
| static bool HasDelegate(const MediaControls& media_controls) { |
| @@ -104,11 +128,6 @@ class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { |
| ->rotate_to_fullscreen_delegate_; |
| } |
| - static bool HasOrientationLockDelegate(const MediaControls& media_controls) { |
| - return !!static_cast<const MediaControlsImpl*>(&media_controls) |
| - ->orientation_lock_delegate_; |
| - } |
| - |
| void SimulateVideoReadyState(HTMLMediaElement::ReadyState state) { |
| GetVideo().SetReadyState(state); |
| } |
| @@ -170,6 +189,7 @@ class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { |
| private: |
| bool previous_video_rotate_to_fullscreen_value_; |
| + bool previous_video_fullscreen_orientation_lock_value_; |
| Persistent<MockChromeClient> chrome_client_; |
| std::unique_ptr<DummyPageHolder> page_holder_; |
| Persistent<HTMLVideoElement> video_; |
| @@ -210,8 +230,8 @@ void MediaControlsRotateToFullscreenDelegateTest::RotateTo( |
| WebScreenInfo screen_info; |
| screen_info.orientation_type = new_screen_orientation; |
| EXPECT_CALL(GetChromeClient(), GetScreenInfo()) |
| - .Times(1) |
| - .WillOnce(Return(screen_info)); |
| + .Times(AtLeast(1)) |
| + .WillRepeatedly(Return(screen_info)); |
| DispatchEvent(GetWindow(), EventTypeNames::orientationchange); |
| testing::RunPendingTasks(); |
| } |
| @@ -234,18 +254,6 @@ TEST_F(MediaControlsRotateToFullscreenDelegateTest, DelegateRequiresVideo) { |
| EXPECT_FALSE(HasDelegate(*audio->GetMediaControls())); |
| } |
| -TEST_F(MediaControlsRotateToFullscreenDelegateTest, |
| - OrientationLockIsMutuallyExclusive) { |
| - // Rotate to fullscreen and fullscreen orientation lock are currently |
| - // incompatible, so if both are enabled only one should be active. |
| - RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(true); |
| - RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled(true); |
| - HTMLVideoElement* video = HTMLVideoElement::Create(GetDocument()); |
| - GetDocument().body()->AppendChild(video); |
| - EXPECT_TRUE(HasDelegate(*video->GetMediaControls())); |
| - EXPECT_FALSE(HasOrientationLockDelegate(*video->GetMediaControls())); |
| -} |
| - |
| TEST_F(MediaControlsRotateToFullscreenDelegateTest, ComputeVideoOrientation) { |
| // Set up the WebMediaPlayer instance. |
| GetDocument().body()->AppendChild(&GetVideo()); |