| 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" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so | 601 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so |
| 602 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids | 602 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids |
| 603 // having to create deviceorientation events here to unlock it again. | 603 // having to create deviceorientation events here to unlock it again. |
| 604 testing::RunPendingTasks(); | 604 testing::RunPendingTasks(); |
| 605 EXPECT_TRUE(GetVideo().IsFullscreen()); | 605 EXPECT_TRUE(GetVideo().IsFullscreen()); |
| 606 | 606 |
| 607 // Leave video paused (playing is not a requirement to exit fullscreen). | 607 // Leave video paused (playing is not a requirement to exit fullscreen). |
| 608 EXPECT_TRUE(GetVideo().paused()); | 608 EXPECT_TRUE(GetVideo().paused()); |
| 609 EXPECT_FALSE(ObservedVisibility()); | 609 EXPECT_FALSE(ObservedVisibility()); |
| 610 | 610 |
| 611 // Rotate screen to portrait. This relies on the screen orientation no longer | 611 // Rotate screen to portrait. This relies on the screen orientation not being |
| 612 // being locked by MediaControlsOrientationLockDelegate. | 612 // locked by MediaControlsOrientationLockDelegate (which has its own tests). |
| 613 RotateTo(kWebScreenOrientationPortraitPrimary); | 613 RotateTo(kWebScreenOrientationPortraitPrimary); |
| 614 | 614 |
| 615 // Should exit fullscreen. | 615 // Should exit fullscreen. |
| 616 EXPECT_FALSE(GetVideo().IsFullscreen()); | 616 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 617 } | 617 } |
| 618 | 618 |
| 619 TEST_F(MediaControlsRotateToFullscreenDelegateTest, | 619 TEST_F(MediaControlsRotateToFullscreenDelegateTest, |
| 620 ExitSuccessPortraitFullscreenToLandscapeInline) { | 620 ExitSuccessPortraitFullscreenToLandscapeInline) { |
| 621 // Portrait screen, portrait video. | 621 // Portrait screen, portrait video. |
| 622 InitScreenAndVideo(kWebScreenOrientationPortraitPrimary, WebSize(480, 640)); | 622 InitScreenAndVideo(kWebScreenOrientationPortraitPrimary, WebSize(480, 640)); |
| 623 EXPECT_EQ(SimpleOrientation::kPortrait, ObservedScreenOrientation()); | 623 EXPECT_EQ(SimpleOrientation::kPortrait, ObservedScreenOrientation()); |
| 624 EXPECT_EQ(SimpleOrientation::kPortrait, ComputeVideoOrientation()); | 624 EXPECT_EQ(SimpleOrientation::kPortrait, ComputeVideoOrientation()); |
| 625 | 625 |
| 626 // Start in fullscreen. | 626 // Start in fullscreen. |
| 627 { | 627 { |
| 628 UserGestureIndicator gesture( | 628 UserGestureIndicator gesture( |
| 629 DocumentUserGestureToken::Create(&GetDocument())); | 629 DocumentUserGestureToken::Create(&GetDocument())); |
| 630 GetMediaControls().EnterFullscreen(); | 630 GetMediaControls().EnterFullscreen(); |
| 631 } | 631 } |
| 632 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so | 632 // n.b. omit to call Fullscreen::From(GetDocument()).DidEnterFullscreen() so |
| 633 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids | 633 // that MediaControlsOrientationLockDelegate doesn't trigger, which avoids |
| 634 // having to create deviceorientation events here to unlock it again. | 634 // having to create deviceorientation events here to unlock it again. |
| 635 testing::RunPendingTasks(); | 635 testing::RunPendingTasks(); |
| 636 EXPECT_TRUE(GetVideo().IsFullscreen()); | 636 EXPECT_TRUE(GetVideo().IsFullscreen()); |
| 637 | 637 |
| 638 // Leave video paused (playing is not a requirement to exit fullscreen). | 638 // Leave video paused (playing is not a requirement to exit fullscreen). |
| 639 EXPECT_TRUE(GetVideo().paused()); | 639 EXPECT_TRUE(GetVideo().paused()); |
| 640 EXPECT_FALSE(ObservedVisibility()); | 640 EXPECT_FALSE(ObservedVisibility()); |
| 641 | 641 |
| 642 // Rotate screen to portrait. This relies on the screen orientation no longer | 642 // Rotate screen to landscape. This relies on the screen orientation not being |
| 643 // being locked by MediaControlsOrientationLockDelegate. | 643 // locked by MediaControlsOrientationLockDelegate (which has its own tests). |
| 644 RotateTo(kWebScreenOrientationLandscapePrimary); | 644 RotateTo(kWebScreenOrientationLandscapePrimary); |
| 645 | 645 |
| 646 // Should exit fullscreen. | 646 // Should exit fullscreen. |
| 647 EXPECT_FALSE(GetVideo().IsFullscreen()); | 647 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 648 } | 648 } |
| 649 | 649 |
| 650 TEST_F(MediaControlsRotateToFullscreenDelegateTest, | 650 TEST_F(MediaControlsRotateToFullscreenDelegateTest, |
| 651 ExitFailDocumentFullscreen) { | 651 ExitFailDocumentFullscreen) { |
| 652 // Landscape screen, landscape video. | 652 // Landscape screen, landscape video. |
| 653 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); | 653 InitScreenAndVideo(kWebScreenOrientationLandscapePrimary, WebSize(640, 480)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 671 | 671 |
| 672 // Rotate screen to portrait. | 672 // Rotate screen to portrait. |
| 673 RotateTo(kWebScreenOrientationPortraitPrimary); | 673 RotateTo(kWebScreenOrientationPortraitPrimary); |
| 674 | 674 |
| 675 // Should not exit fullscreen, since video was not the fullscreen element. | 675 // Should not exit fullscreen, since video was not the fullscreen element. |
| 676 EXPECT_TRUE(Fullscreen::IsCurrentFullScreenElement(*GetDocument().body())); | 676 EXPECT_TRUE(Fullscreen::IsCurrentFullScreenElement(*GetDocument().body())); |
| 677 EXPECT_FALSE(GetVideo().IsFullscreen()); | 677 EXPECT_FALSE(GetVideo().IsFullscreen()); |
| 678 } | 678 } |
| 679 | 679 |
| 680 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |