| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" | 5 #include "modules/media_controls/MediaControlsRotateToFullscreenDelegate.h" |
| 6 | 6 |
| 7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
| 8 #include "core/css/CSSStyleDeclaration.h" | 8 #include "core/css/CSSStyleDeclaration.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/DocumentUserGestureToken.h" | 10 #include "core/dom/DocumentUserGestureToken.h" |
| 11 #include "core/dom/Fullscreen.h" | 11 #include "core/dom/Fullscreen.h" |
| 12 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
| 13 #include "core/frame/LocalDOMWindow.h" | 13 #include "core/frame/LocalDOMWindow.h" |
| 14 #include "core/frame/Settings.h" | 14 #include "core/frame/Settings.h" |
| 15 #include "core/html/HTMLAudioElement.h" | 15 #include "core/html/HTMLAudioElement.h" |
| 16 #include "core/html/HTMLVideoElement.h" | 16 #include "core/html/HTMLVideoElement.h" |
| 17 #include "core/loader/EmptyClients.h" | 17 #include "core/loader/EmptyClients.h" |
| 18 #include "core/testing/DummyPageHolder.h" | 18 #include "core/testing/DummyPageHolder.h" |
| 19 #include "modules/media_controls/MediaControlsImpl.h" | 19 #include "modules/media_controls/MediaControlsImpl.h" |
| 20 #include "modules/screen_orientation/ScreenOrientationControllerImpl.h" |
| 20 #include "platform/UserGestureIndicator.h" | 21 #include "platform/UserGestureIndicator.h" |
| 21 #include "platform/testing/EmptyWebMediaPlayer.h" | 22 #include "platform/testing/EmptyWebMediaPlayer.h" |
| 22 #include "platform/testing/UnitTestHelpers.h" | 23 #include "platform/testing/UnitTestHelpers.h" |
| 23 #include "platform/wtf/text/AtomicString.h" | 24 #include "platform/wtf/text/AtomicString.h" |
| 24 #include "public/platform/WebSize.h" | 25 #include "public/platform/WebSize.h" |
| 26 #include "public/platform/modules/screen_orientation/WebScreenOrientationClient.
h" |
| 25 #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h" | 27 #include "public/platform/modules/screen_orientation/WebScreenOrientationType.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 30 |
| 31 using ::testing::AtLeast; |
| 29 using ::testing::Return; | 32 using ::testing::Return; |
| 30 | 33 |
| 31 namespace blink { | 34 namespace blink { |
| 32 | 35 |
| 33 using namespace HTMLNames; | 36 using namespace HTMLNames; |
| 34 | 37 |
| 35 namespace { | 38 namespace { |
| 36 | 39 |
| 40 class FakeWebScreenOrientationClient : public WebScreenOrientationClient { |
| 41 public: |
| 42 // WebScreenOrientationClient overrides: |
| 43 void LockOrientation(WebScreenOrientationLockType, |
| 44 std::unique_ptr<WebLockOrientationCallback>) override {} |
| 45 void UnlockOrientation() override {} |
| 46 }; |
| 47 |
| 37 class MockVideoWebMediaPlayer : public EmptyWebMediaPlayer { | 48 class MockVideoWebMediaPlayer : public EmptyWebMediaPlayer { |
| 38 public: | 49 public: |
| 39 // ChromeClient overrides: | 50 // EmptyWebMediaPlayer overrides: |
| 40 bool HasVideo() const override { return true; } | 51 bool HasVideo() const override { return true; } |
| 41 | 52 |
| 42 MOCK_CONST_METHOD0(NaturalSize, WebSize()); | 53 MOCK_CONST_METHOD0(NaturalSize, WebSize()); |
| 43 }; | 54 }; |
| 44 | 55 |
| 45 class MockChromeClient : public EmptyChromeClient { | 56 class MockChromeClient : public EmptyChromeClient { |
| 46 public: | 57 public: |
| 47 // ChromeClient overrides: | 58 // ChromeClient overrides: |
| 59 void InstallSupplements(LocalFrame& frame) override { |
| 60 EmptyChromeClient::InstallSupplements(frame); |
| 61 ScreenOrientationControllerImpl::ProvideTo(frame, |
| 62 &web_screen_orientation_client_); |
| 63 } |
| 48 void EnterFullscreen(LocalFrame& frame) override { | 64 void EnterFullscreen(LocalFrame& frame) override { |
| 49 Fullscreen::From(*frame.GetDocument()).DidEnterFullscreen(); | 65 Fullscreen::From(*frame.GetDocument()).DidEnterFullscreen(); |
| 50 } | 66 } |
| 51 void ExitFullscreen(LocalFrame& frame) override { | 67 void ExitFullscreen(LocalFrame& frame) override { |
| 52 Fullscreen::From(*frame.GetDocument()).DidExitFullscreen(); | 68 Fullscreen::From(*frame.GetDocument()).DidExitFullscreen(); |
| 53 } | 69 } |
| 54 | 70 |
| 55 MOCK_CONST_METHOD0(GetScreenInfo, WebScreenInfo()); | 71 MOCK_CONST_METHOD0(GetScreenInfo, WebScreenInfo()); |
| 72 |
| 73 private: |
| 74 FakeWebScreenOrientationClient web_screen_orientation_client_; |
| 56 }; | 75 }; |
| 57 | 76 |
| 58 class StubLocalFrameClient : public EmptyLocalFrameClient { | 77 class StubLocalFrameClient : public EmptyLocalFrameClient { |
| 59 public: | 78 public: |
| 60 static StubLocalFrameClient* Create() { return new StubLocalFrameClient; } | 79 static StubLocalFrameClient* Create() { return new StubLocalFrameClient; } |
| 61 | 80 |
| 62 std::unique_ptr<WebMediaPlayer> CreateWebMediaPlayer( | 81 std::unique_ptr<WebMediaPlayer> CreateWebMediaPlayer( |
| 63 HTMLMediaElement&, | 82 HTMLMediaElement&, |
| 64 const WebMediaPlayerSource&, | 83 const WebMediaPlayerSource&, |
| 65 WebMediaPlayerClient*) override { | 84 WebMediaPlayerClient*) override { |
| 66 return WTF::MakeUnique<MockVideoWebMediaPlayer>(); | 85 return WTF::MakeUnique<MockVideoWebMediaPlayer>(); |
| 67 } | 86 } |
| 68 }; | 87 }; |
| 69 | 88 |
| 70 } // anonymous namespace | 89 } // anonymous namespace |
| 71 | 90 |
| 72 class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { | 91 class MediaControlsRotateToFullscreenDelegateTest : public ::testing::Test { |
| 73 protected: | 92 protected: |
| 74 using SimpleOrientation = | 93 using SimpleOrientation = |
| 75 MediaControlsRotateToFullscreenDelegate::SimpleOrientation; | 94 MediaControlsRotateToFullscreenDelegate::SimpleOrientation; |
| 76 | 95 |
| 77 void SetUp() override { | 96 void SetUp() override { |
| 97 previous_video_fullscreen_orientation_lock_value_ = |
| 98 RuntimeEnabledFeatures::videoFullscreenOrientationLockEnabled(); |
| 78 previous_video_rotate_to_fullscreen_value_ = | 99 previous_video_rotate_to_fullscreen_value_ = |
| 79 RuntimeEnabledFeatures::videoRotateToFullscreenEnabled(); | 100 RuntimeEnabledFeatures::videoRotateToFullscreenEnabled(); |
| 101 RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled(true); |
| 80 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(true); | 102 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(true); |
| 81 | 103 |
| 82 chrome_client_ = new MockChromeClient(); | 104 chrome_client_ = new MockChromeClient(); |
| 83 | 105 |
| 84 Page::PageClients clients; | 106 Page::PageClients clients; |
| 85 FillWithEmptyClients(clients); | 107 FillWithEmptyClients(clients); |
| 86 clients.chrome_client = chrome_client_.Get(); | 108 clients.chrome_client = chrome_client_.Get(); |
| 87 | 109 |
| 88 page_holder_ = DummyPageHolder::Create(IntSize(800, 600), &clients, | 110 page_holder_ = DummyPageHolder::Create(IntSize(800, 600), &clients, |
| 89 StubLocalFrameClient::Create()); | 111 StubLocalFrameClient::Create()); |
| 90 | 112 |
| 91 video_ = HTMLVideoElement::Create(GetDocument()); | 113 video_ = HTMLVideoElement::Create(GetDocument()); |
| 92 GetVideo().setAttribute(controlsAttr, g_empty_atom); | 114 GetVideo().setAttribute(controlsAttr, g_empty_atom); |
| 93 // Most tests should call GetDocument().body()->AppendChild(&GetVideo()); | 115 // Most tests should call GetDocument().body()->AppendChild(&GetVideo()); |
| 94 // This is not done automatically, so that tests control timing of `Attach`. | 116 // This is not done automatically, so that tests control timing of `Attach`. |
| 95 } | 117 } |
| 96 | 118 |
| 97 void TearDown() override { | 119 void TearDown() override { |
| 120 RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled( |
| 121 previous_video_fullscreen_orientation_lock_value_); |
| 98 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled( | 122 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled( |
| 99 previous_video_rotate_to_fullscreen_value_); | 123 previous_video_rotate_to_fullscreen_value_); |
| 100 } | 124 } |
| 101 | 125 |
| 102 static bool HasDelegate(const MediaControls& media_controls) { | 126 static bool HasDelegate(const MediaControls& media_controls) { |
| 103 return !!static_cast<const MediaControlsImpl*>(&media_controls) | 127 return !!static_cast<const MediaControlsImpl*>(&media_controls) |
| 104 ->rotate_to_fullscreen_delegate_; | 128 ->rotate_to_fullscreen_delegate_; |
| 105 } | 129 } |
| 106 | 130 |
| 107 static bool HasOrientationLockDelegate(const MediaControls& media_controls) { | |
| 108 return !!static_cast<const MediaControlsImpl*>(&media_controls) | |
| 109 ->orientation_lock_delegate_; | |
| 110 } | |
| 111 | |
| 112 void SimulateVideoReadyState(HTMLMediaElement::ReadyState state) { | 131 void SimulateVideoReadyState(HTMLMediaElement::ReadyState state) { |
| 113 GetVideo().SetReadyState(state); | 132 GetVideo().SetReadyState(state); |
| 114 } | 133 } |
| 115 | 134 |
| 116 SimpleOrientation ObservedScreenOrientation() const { | 135 SimpleOrientation ObservedScreenOrientation() const { |
| 117 return GetMediaControls() | 136 return GetMediaControls() |
| 118 .rotate_to_fullscreen_delegate_->current_screen_orientation_; | 137 .rotate_to_fullscreen_delegate_->current_screen_orientation_; |
| 119 } | 138 } |
| 120 | 139 |
| 121 SimpleOrientation ComputeVideoOrientation() const { | 140 SimpleOrientation ComputeVideoOrientation() const { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 HTMLVideoElement& GetVideo() const { return *video_; } | 181 HTMLVideoElement& GetVideo() const { return *video_; } |
| 163 MediaControlsImpl& GetMediaControls() const { | 182 MediaControlsImpl& GetMediaControls() const { |
| 164 return *static_cast<MediaControlsImpl*>(GetVideo().GetMediaControls()); | 183 return *static_cast<MediaControlsImpl*>(GetVideo().GetMediaControls()); |
| 165 } | 184 } |
| 166 MockVideoWebMediaPlayer& GetWebMediaPlayer() const { | 185 MockVideoWebMediaPlayer& GetWebMediaPlayer() const { |
| 167 return *static_cast<MockVideoWebMediaPlayer*>( | 186 return *static_cast<MockVideoWebMediaPlayer*>( |
| 168 GetVideo().GetWebMediaPlayer()); | 187 GetVideo().GetWebMediaPlayer()); |
| 169 } | 188 } |
| 170 | 189 |
| 171 private: | 190 private: |
| 191 bool previous_video_fullscreen_orientation_lock_value_; |
| 172 bool previous_video_rotate_to_fullscreen_value_; | 192 bool previous_video_rotate_to_fullscreen_value_; |
| 173 Persistent<MockChromeClient> chrome_client_; | 193 Persistent<MockChromeClient> chrome_client_; |
| 174 std::unique_ptr<DummyPageHolder> page_holder_; | 194 std::unique_ptr<DummyPageHolder> page_holder_; |
| 175 Persistent<HTMLVideoElement> video_; | 195 Persistent<HTMLVideoElement> video_; |
| 176 }; | 196 }; |
| 177 | 197 |
| 178 void MediaControlsRotateToFullscreenDelegateTest::InitScreenAndVideo( | 198 void MediaControlsRotateToFullscreenDelegateTest::InitScreenAndVideo( |
| 179 WebScreenOrientationType initial_screen_orientation, | 199 WebScreenOrientationType initial_screen_orientation, |
| 180 WebSize video_size) { | 200 WebSize video_size) { |
| 181 // Set initial screen orientation (called by `Attach` during `AppendChild`). | 201 // Set initial screen orientation (called by `Attach` during `AppendChild`). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 202 DocumentUserGestureToken::Create(&GetDocument())); | 222 DocumentUserGestureToken::Create(&GetDocument())); |
| 203 GetVideo().Play(); | 223 GetVideo().Play(); |
| 204 } | 224 } |
| 205 testing::RunPendingTasks(); | 225 testing::RunPendingTasks(); |
| 206 } | 226 } |
| 207 | 227 |
| 208 void MediaControlsRotateToFullscreenDelegateTest::RotateTo( | 228 void MediaControlsRotateToFullscreenDelegateTest::RotateTo( |
| 209 WebScreenOrientationType new_screen_orientation) { | 229 WebScreenOrientationType new_screen_orientation) { |
| 210 WebScreenInfo screen_info; | 230 WebScreenInfo screen_info; |
| 211 screen_info.orientation_type = new_screen_orientation; | 231 screen_info.orientation_type = new_screen_orientation; |
| 232 ::testing::Mock::VerifyAndClearExpectations(&GetChromeClient()); |
| 212 EXPECT_CALL(GetChromeClient(), GetScreenInfo()) | 233 EXPECT_CALL(GetChromeClient(), GetScreenInfo()) |
| 213 .Times(1) | 234 .Times(AtLeast(1)) |
| 214 .WillOnce(Return(screen_info)); | 235 .WillRepeatedly(Return(screen_info)); |
| 215 DispatchEvent(GetWindow(), EventTypeNames::orientationchange); | 236 DispatchEvent(GetWindow(), EventTypeNames::orientationchange); |
| 216 testing::RunPendingTasks(); | 237 testing::RunPendingTasks(); |
| 217 } | 238 } |
| 218 | 239 |
| 219 TEST_F(MediaControlsRotateToFullscreenDelegateTest, DelegateRequiresFlag) { | 240 TEST_F(MediaControlsRotateToFullscreenDelegateTest, DelegateRequiresFlag) { |
| 220 // SetUp turns the flag on by default. | 241 // SetUp turns the flag on by default. |
| 221 GetDocument().body()->AppendChild(&GetVideo()); | 242 GetDocument().body()->AppendChild(&GetVideo()); |
| 222 EXPECT_TRUE(HasDelegate(GetMediaControls())); | 243 EXPECT_TRUE(HasDelegate(GetMediaControls())); |
| 223 | 244 |
| 224 // No delegate when flag is off. | 245 // No delegate when flag is off. |
| 225 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(false); | 246 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(false); |
| 226 HTMLVideoElement* video = HTMLVideoElement::Create(GetDocument()); | 247 HTMLVideoElement* video = HTMLVideoElement::Create(GetDocument()); |
| 227 GetDocument().body()->AppendChild(video); | 248 GetDocument().body()->AppendChild(video); |
| 228 EXPECT_FALSE(HasDelegate(*video->GetMediaControls())); | 249 EXPECT_FALSE(HasDelegate(*video->GetMediaControls())); |
| 229 } | 250 } |
| 230 | 251 |
| 231 TEST_F(MediaControlsRotateToFullscreenDelegateTest, DelegateRequiresVideo) { | 252 TEST_F(MediaControlsRotateToFullscreenDelegateTest, DelegateRequiresVideo) { |
| 232 HTMLAudioElement* audio = HTMLAudioElement::Create(GetDocument()); | 253 HTMLAudioElement* audio = HTMLAudioElement::Create(GetDocument()); |
| 233 GetDocument().body()->AppendChild(audio); | 254 GetDocument().body()->AppendChild(audio); |
| 234 EXPECT_FALSE(HasDelegate(*audio->GetMediaControls())); | 255 EXPECT_FALSE(HasDelegate(*audio->GetMediaControls())); |
| 235 } | 256 } |
| 236 | 257 |
| 237 TEST_F(MediaControlsRotateToFullscreenDelegateTest, | |
| 238 OrientationLockIsMutuallyExclusive) { | |
| 239 // Rotate to fullscreen and fullscreen orientation lock are currently | |
| 240 // incompatible, so if both are enabled only one should be active. | |
| 241 RuntimeEnabledFeatures::setVideoRotateToFullscreenEnabled(true); | |
| 242 RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled(true); | |
| 243 HTMLVideoElement* video = HTMLVideoElement::Create(GetDocument()); | |
| 244 GetDocument().body()->AppendChild(video); | |
| 245 EXPECT_TRUE(HasDelegate(*video->GetMediaControls())); | |
| 246 EXPECT_FALSE(HasOrientationLockDelegate(*video->GetMediaControls())); | |
| 247 } | |
| 248 | |
| 249 TEST_F(MediaControlsRotateToFullscreenDelegateTest, ComputeVideoOrientation) { | 258 TEST_F(MediaControlsRotateToFullscreenDelegateTest, ComputeVideoOrientation) { |
| 250 // Set up the WebMediaPlayer instance. | 259 // Set up the WebMediaPlayer instance. |
| 251 GetDocument().body()->AppendChild(&GetVideo()); | 260 GetDocument().body()->AppendChild(&GetVideo()); |
| 252 GetVideo().SetSrc("https://example.com"); | 261 GetVideo().SetSrc("https://example.com"); |
| 253 testing::RunPendingTasks(); | 262 testing::RunPendingTasks(); |
| 254 | 263 |
| 255 // Each `ComputeVideoOrientation` calls `NaturalSize` twice, except the first | 264 // Each `ComputeVideoOrientation` calls `NaturalSize` twice, except the first |
| 256 // one where the video is not yet ready. | 265 // one where the video is not yet ready. |
| 257 EXPECT_CALL(GetWebMediaPlayer(), NaturalSize()) | 266 EXPECT_CALL(GetWebMediaPlayer(), NaturalSize()) |
| 258 .Times(12) | 267 .Times(12) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); | 591 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); |
| 583 EXPECT_EQ(SimpleOrientation::kLandscape, ObservedScreenOrientation()); | 592 EXPECT_EQ(SimpleOrientation::kLandscape, ObservedScreenOrientation()); |
| 584 EXPECT_EQ(SimpleOrientation::kLandscape, ComputeVideoOrientation()); | 593 EXPECT_EQ(SimpleOrientation::kLandscape, ComputeVideoOrientation()); |
| 585 | 594 |
| 586 // Start in fullscreen. | 595 // Start in fullscreen. |
| 587 { | 596 { |
| 588 UserGestureIndicator gesture( | 597 UserGestureIndicator gesture( |
| 589 DocumentUserGestureToken::Create(&GetDocument())); | 598 DocumentUserGestureToken::Create(&GetDocument())); |
| 590 GetMediaControls().EnterFullscreen(); | 599 GetMediaControls().EnterFullscreen(); |
| 591 } | 600 } |
| 601 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so |
| 602 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids |
| 603 // having to create deviceorientation events here to unlock it again. |
| 592 testing::RunPendingTasks(); | 604 testing::RunPendingTasks(); |
| 593 EXPECT_TRUE(GetVideo().IsFullscreen()); | 605 EXPECT_TRUE(GetVideo().IsFullscreen()); |
| 594 | 606 |
| 595 // Leave video paused (playing is not a requirement to exit fullscreen). | 607 // Leave video paused (playing is not a requirement to exit fullscreen). |
| 596 EXPECT_TRUE(GetVideo().paused()); | 608 EXPECT_TRUE(GetVideo().paused()); |
| 597 EXPECT_FALSE(ObservedVisibility()); | 609 EXPECT_FALSE(ObservedVisibility()); |
| 598 | 610 |
| 599 // Rotate screen to portrait. | 611 // Rotate screen to portrait. This relies on the screen orientation no longer |
| 612 // being locked by MediaControlsOrientationLockDelegate. |
| 600 RotateTo(kWebScreenOrientationPortraitPrimary); | 613 RotateTo(kWebScreenOrientationPortraitPrimary); |
| 601 | 614 |
| 602 // Should exit fullscreen. | 615 // Should exit fullscreen. |
| 603 EXPECT_FALSE(GetVideo().IsFullscreen()); | 616 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 604 } | 617 } |
| 605 | 618 |
| 606 TEST_F(MediaControlsRotateToFullscreenDelegateTest, | 619 TEST_F(MediaControlsRotateToFullscreenDelegateTest, |
| 607 ExitSuccessPortraitFullscreenToLandscapeInline) { | 620 ExitSuccessPortraitFullscreenToLandscapeInline) { |
| 608 // Portrait screen, portrait video. | 621 // Portrait screen, portrait video. |
| 609 InitScreenAndVideo(kWebScreenOrientationPortraitPrimary, WebSize(480, 640)); | 622 InitScreenAndVideo(kWebScreenOrientationPortraitPrimary, WebSize(480, 640)); |
| 610 EXPECT_EQ(SimpleOrientation::kPortrait, ObservedScreenOrientation()); | 623 EXPECT_EQ(SimpleOrientation::kPortrait, ObservedScreenOrientation()); |
| 611 EXPECT_EQ(SimpleOrientation::kPortrait, ComputeVideoOrientation()); | 624 EXPECT_EQ(SimpleOrientation::kPortrait, ComputeVideoOrientation()); |
| 612 | 625 |
| 613 // Start in fullscreen. | 626 // Start in fullscreen. |
| 614 { | 627 { |
| 615 UserGestureIndicator gesture( | 628 UserGestureIndicator gesture( |
| 616 DocumentUserGestureToken::Create(&GetDocument())); | 629 DocumentUserGestureToken::Create(&GetDocument())); |
| 617 GetMediaControls().EnterFullscreen(); | 630 GetMediaControls().EnterFullscreen(); |
| 618 } | 631 } |
| 632 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so |
| 633 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids |
| 634 // having to create deviceorientation events here to unlock it again. |
| 619 testing::RunPendingTasks(); | 635 testing::RunPendingTasks(); |
| 620 EXPECT_TRUE(GetVideo().IsFullscreen()); | 636 EXPECT_TRUE(GetVideo().IsFullscreen()); |
| 621 | 637 |
| 622 // Leave video paused (playing is not a requirement to exit fullscreen). | 638 // Leave video paused (playing is not a requirement to exit fullscreen). |
| 623 EXPECT_TRUE(GetVideo().paused()); | 639 EXPECT_TRUE(GetVideo().paused()); |
| 624 EXPECT_FALSE(ObservedVisibility()); | 640 EXPECT_FALSE(ObservedVisibility()); |
| 625 | 641 |
| 626 // Rotate screen to landscape. | 642 // Rotate screen to portrait. This relies on the screen orientation no longer |
| 643 // being locked by MediaControlsOrientationLockDelegate. |
| 627 RotateTo(kWebScreenOrientationLandscapePrimary); | 644 RotateTo(kWebScreenOrientationLandscapePrimary); |
| 628 | 645 |
| 629 // Should exit fullscreen. | 646 // Should exit fullscreen. |
| 630 EXPECT_FALSE(GetVideo().IsFullscreen()); | 647 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 631 } | 648 } |
| 632 | 649 |
| 633 TEST_F(MediaControlsRotateToFullscreenDelegateTest, | 650 TEST_F(MediaControlsRotateToFullscreenDelegateTest, |
| 634 ExitFailDocumentFullscreen) { | 651 ExitFailDocumentFullscreen) { |
| 635 // Landscape screen, landscape video. | 652 // Landscape screen, landscape video. |
| 636 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); | 653 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 654 | 671 |
| 655 // Rotate screen to portrait. | 672 // Rotate screen to portrait. |
| 656 RotateTo(kWebScreenOrientationPortraitPrimary); | 673 RotateTo(kWebScreenOrientationPortraitPrimary); |
| 657 | 674 |
| 658 // Should not exit fullscreen, since video was not the fullscreen element. | 675 // Should not exit fullscreen, since video was not the fullscreen element. |
| 659 EXPECT_TRUE(Fullscreen::IsCurrentFullScreenElement(*GetDocument().body())); | 676 EXPECT_TRUE(Fullscreen::IsCurrentFullScreenElement(*GetDocument().body())); |
| 660 EXPECT_FALSE(GetVideo().IsFullscreen()); | 677 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 661 } | 678 } |
| 662 | 679 |
| 663 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |