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