| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "content/public/renderer/media_stream_renderer_factory.h" | 9 #include "content/public/renderer/media_stream_renderer_factory.h" |
| 10 #include "content/renderer/media/webmediaplayer_ms.h" | 10 #include "content/renderer/media/webmediaplayer_ms.h" |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 EXPECT_CALL(*this, DoStopRendering()); | 721 EXPECT_CALL(*this, DoStopRendering()); |
| 722 } | 722 } |
| 723 | 723 |
| 724 INSTANTIATE_TEST_CASE_P(, | 724 INSTANTIATE_TEST_CASE_P(, |
| 725 WebMediaPlayerMSTest, | 725 WebMediaPlayerMSTest, |
| 726 ::testing::Combine(::testing::Bool(), | 726 ::testing::Combine(::testing::Bool(), |
| 727 ::testing::Bool())); | 727 ::testing::Bool())); |
| 728 | 728 |
| 729 // During this test, we check that when we send rotated video frames, it applies | 729 // During this test, we check that when we send rotated video frames, it applies |
| 730 // to player's natural size. | 730 // to player's natural size. |
| 731 TEST_F(WebMediaPlayerMSTest, RotatedVideoFrame) { | 731 TEST_F(WebMediaPlayerMSTest, RotationChange) { |
| 732 MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true); | 732 MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true); |
| 733 | 733 |
| 734 static int tokens[] = {0, 33, 66}; | 734 const int kTestBrake = static_cast<int>(FrameType::TEST_BRAKE); |
| 735 static int tokens[] = {0, 33, kTestBrake}; |
| 735 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 736 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
| 736 provider->QueueFrames(timestamps, false, false, 17, media::VIDEO_ROTATION_90); | 737 provider->QueueFrames(timestamps, false, false, 17, media::VIDEO_ROTATION_90); |
| 737 | |
| 738 EXPECT_CALL(*this, DoSetWebLayer(true)); | 738 EXPECT_CALL(*this, DoSetWebLayer(true)); |
| 739 EXPECT_CALL(*this, DoStartRendering()); | 739 EXPECT_CALL(*this, DoStartRendering()); |
| 740 EXPECT_CALL(*this, DoReadyStateChanged( | 740 EXPECT_CALL(*this, DoReadyStateChanged( |
| 741 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 741 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
| 742 EXPECT_CALL(*this, DoReadyStateChanged( | 742 EXPECT_CALL(*this, DoReadyStateChanged( |
| 743 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 743 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
| 744 EXPECT_CALL(*this, | 744 EXPECT_CALL(*this, |
| 745 CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight))); | 745 CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight))); |
| 746 message_loop_controller_.RunAndWaitForStatus( | 746 message_loop_controller_.RunAndWaitForStatus( |
| 747 media::PipelineStatus::PIPELINE_OK); | 747 media::PipelineStatus::PIPELINE_OK); |
| 748 const blink::WebSize& natural_size = player_->naturalSize(); | 748 blink::WebSize natural_size = player_->naturalSize(); |
| 749 // Check that height and width are flipped. | 749 // Check that height and width are flipped. |
| 750 EXPECT_EQ(kStandardHeight, natural_size.width); | 750 EXPECT_EQ(kStandardHeight, natural_size.width); |
| 751 EXPECT_EQ(kStandardWidth, natural_size.height); | 751 EXPECT_EQ(kStandardWidth, natural_size.height); |
| 752 |
| 753 // Change rotation. |
| 754 provider->QueueFrames(timestamps, false, false, 17, media::VIDEO_ROTATION_0); |
| 755 EXPECT_CALL(*this, DoSetWebLayer(true)); |
| 756 EXPECT_CALL(*this, DoStopRendering()); |
| 757 EXPECT_CALL(*this, DoStartRendering()); |
| 758 message_loop_controller_.RunAndWaitForStatus( |
| 759 media::PipelineStatus::PIPELINE_OK); |
| 760 natural_size = player_->naturalSize(); |
| 761 EXPECT_EQ(kStandardHeight, natural_size.height); |
| 762 EXPECT_EQ(kStandardWidth, natural_size.width); |
| 763 |
| 752 testing::Mock::VerifyAndClearExpectations(this); | 764 testing::Mock::VerifyAndClearExpectations(this); |
| 753 | |
| 754 EXPECT_CALL(*this, DoSetWebLayer(false)); | 765 EXPECT_CALL(*this, DoSetWebLayer(false)); |
| 755 EXPECT_CALL(*this, DoStopRendering()); | 766 EXPECT_CALL(*this, DoStopRendering()); |
| 756 } | 767 } |
| 757 | 768 |
| 758 // During this test, we check that web layer changes opacity according to the | 769 // During this test, we check that web layer changes opacity according to the |
| 759 // given frames. | 770 // given frames. |
| 760 TEST_F(WebMediaPlayerMSTest, OpacityChange) { | 771 TEST_F(WebMediaPlayerMSTest, OpacityChange) { |
| 761 MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true); | 772 MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true); |
| 762 | 773 |
| 763 // Push one opaque frame. | 774 // Push one opaque frame. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 // OnShown() should restart after a forced suspension. | 929 // OnShown() should restart after a forced suspension. |
| 919 player_->OnShown(); | 930 player_->OnShown(); |
| 920 EXPECT_FALSE(player_->paused()); | 931 EXPECT_FALSE(player_->paused()); |
| 921 EXPECT_CALL(*this, DoSetWebLayer(false)); | 932 EXPECT_CALL(*this, DoSetWebLayer(false)); |
| 922 | 933 |
| 923 base::RunLoop().RunUntilIdle(); | 934 base::RunLoop().RunUntilIdle(); |
| 924 } | 935 } |
| 925 #endif | 936 #endif |
| 926 | 937 |
| 927 } // namespace content | 938 } // namespace content |
| OLD | NEW |