Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Side by Side Diff: content/renderer/media/webmediaplayer_ms_unittest.cc

Issue 1930003002: Bug Fix: Rendering stuck due to thread issue of WebMediaPlayerMSCompositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Function Rename Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/media/webmediaplayer_ms_compositor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/public/renderer/media_stream_renderer_factory.h" 7 #include "content/public/renderer/media_stream_renderer_factory.h"
8 #include "content/renderer/media/webmediaplayer_ms.h" 8 #include "content/renderer/media/webmediaplayer_ms.h"
9 #include "content/renderer/media/webmediaplayer_ms_compositor.h" 9 #include "content/renderer/media/webmediaplayer_ms_compositor.h"
10 #include "content/renderer/render_frame_impl.h" 10 #include "content/renderer/render_frame_impl.h"
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0), 627 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0),
628 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0)); 628 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0));
629 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); 629 EXPECT_CALL(*this, CheckSizeChanged(frame_size));
630 message_loop_controller_.RunAndWaitForStatus( 630 message_loop_controller_.RunAndWaitForStatus(
631 media::PipelineStatus::PIPELINE_OK); 631 media::PipelineStatus::PIPELINE_OK);
632 testing::Mock::VerifyAndClearExpectations(this); 632 testing::Mock::VerifyAndClearExpectations(this);
633 633
634 // Here we call pause, and expect a freezing frame. 634 // Here we call pause, and expect a freezing frame.
635 EXPECT_CALL(*this, DoStopRendering()); 635 EXPECT_CALL(*this, DoStopRendering());
636 player_.pause(); 636 player_.pause();
637 auto prev_frame = compositor_->GetCurrentFrame(); 637 auto prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
638 message_loop_controller_.RunAndWaitForStatus( 638 message_loop_controller_.RunAndWaitForStatus(
639 media::PipelineStatus::PIPELINE_OK); 639 media::PipelineStatus::PIPELINE_OK);
640 auto after_frame = compositor_->GetCurrentFrame(); 640 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
641 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp()); 641 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp());
642 testing::Mock::VerifyAndClearExpectations(this); 642 testing::Mock::VerifyAndClearExpectations(this);
643 643
644 EXPECT_CALL(*this, DoSetWebLayer(false)); 644 EXPECT_CALL(*this, DoSetWebLayer(false));
645 } 645 }
646 646
647 TEST_P(WebMediaPlayerMSTest, PlayThenPauseThenPlay) { 647 TEST_P(WebMediaPlayerMSTest, PlayThenPauseThenPlay) {
648 const bool opaque_frame = testing::get<0>(GetParam()); 648 const bool opaque_frame = testing::get<0>(GetParam());
649 const bool odd_size_frame = testing::get<1>(GetParam()); 649 const bool odd_size_frame = testing::get<1>(GetParam());
650 // Similary to PlayAndPause test above, this one focuses on testing that 650 // Similary to PlayAndPause test above, this one focuses on testing that
(...skipping 17 matching lines...) Expand all
668 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0), 668 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0),
669 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0)); 669 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0));
670 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); 670 EXPECT_CALL(*this, CheckSizeChanged(frame_size));
671 message_loop_controller_.RunAndWaitForStatus( 671 message_loop_controller_.RunAndWaitForStatus(
672 media::PipelineStatus::PIPELINE_OK); 672 media::PipelineStatus::PIPELINE_OK);
673 testing::Mock::VerifyAndClearExpectations(this); 673 testing::Mock::VerifyAndClearExpectations(this);
674 674
675 // Here we call pause, and expect a freezing frame. 675 // Here we call pause, and expect a freezing frame.
676 EXPECT_CALL(*this, DoStopRendering()); 676 EXPECT_CALL(*this, DoStopRendering());
677 player_.pause(); 677 player_.pause();
678 auto prev_frame = compositor_->GetCurrentFrame(); 678 auto prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
679 message_loop_controller_.RunAndWaitForStatus( 679 message_loop_controller_.RunAndWaitForStatus(
680 media::PipelineStatus::PIPELINE_OK); 680 media::PipelineStatus::PIPELINE_OK);
681 auto after_frame = compositor_->GetCurrentFrame(); 681 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
682 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp()); 682 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp());
683 testing::Mock::VerifyAndClearExpectations(this); 683 testing::Mock::VerifyAndClearExpectations(this);
684 684
685 // We resume the player, and expect rendering can continue. 685 // We resume the player, and expect rendering can continue.
686 EXPECT_CALL(*this, DoStartRendering()); 686 EXPECT_CALL(*this, DoStartRendering());
687 player_.play(); 687 player_.play();
688 prev_frame = compositor_->GetCurrentFrame(); 688 prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
689 message_loop_controller_.RunAndWaitForStatus( 689 message_loop_controller_.RunAndWaitForStatus(
690 media::PipelineStatus::PIPELINE_OK); 690 media::PipelineStatus::PIPELINE_OK);
691 after_frame = compositor_->GetCurrentFrame(); 691 after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
692 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 692 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
693 testing::Mock::VerifyAndClearExpectations(this); 693 testing::Mock::VerifyAndClearExpectations(this);
694 694
695 EXPECT_CALL(*this, DoSetWebLayer(false)); 695 EXPECT_CALL(*this, DoSetWebLayer(false));
696 EXPECT_CALL(*this, DoStopRendering()); 696 EXPECT_CALL(*this, DoStopRendering());
697 } 697 }
698 698
699 INSTANTIATE_TEST_CASE_P(, 699 INSTANTIATE_TEST_CASE_P(,
700 WebMediaPlayerMSTest, 700 WebMediaPlayerMSTest,
701 ::testing::Combine(::testing::Bool(), 701 ::testing::Combine(::testing::Bool(),
(...skipping 22 matching lines...) Expand all
724 EXPECT_CALL(*this, DoReadyStateChanged( 724 EXPECT_CALL(*this, DoReadyStateChanged(
725 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); 725 blink::WebMediaPlayer::ReadyStateHaveEnoughData));
726 gfx::Size frame_size = gfx::Size(kStandardWidth, kStandardHeight); 726 gfx::Size frame_size = gfx::Size(kStandardWidth, kStandardHeight);
727 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); 727 EXPECT_CALL(*this, CheckSizeChanged(frame_size));
728 message_loop_controller_.RunAndWaitForStatus( 728 message_loop_controller_.RunAndWaitForStatus(
729 media::PipelineStatus::PIPELINE_OK); 729 media::PipelineStatus::PIPELINE_OK);
730 testing::Mock::VerifyAndClearExpectations(this); 730 testing::Mock::VerifyAndClearExpectations(this);
731 731
732 // Switch to background rendering, expect rendering to continue. 732 // Switch to background rendering, expect rendering to continue.
733 SetBackgroundRendering(true); 733 SetBackgroundRendering(true);
734 auto prev_frame = compositor_->GetCurrentFrame(); 734 auto prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
735 message_loop_controller_.RunAndWaitForStatus( 735 message_loop_controller_.RunAndWaitForStatus(
736 media::PipelineStatus::PIPELINE_OK); 736 media::PipelineStatus::PIPELINE_OK);
737 auto after_frame = compositor_->GetCurrentFrame(); 737 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
738 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 738 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
739 739
740 // Switch to foreground rendering. 740 // Switch to foreground rendering.
741 SetBackgroundRendering(false); 741 SetBackgroundRendering(false);
742 prev_frame = compositor_->GetCurrentFrame(); 742 prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
743 message_loop_controller_.RunAndWaitForStatus( 743 message_loop_controller_.RunAndWaitForStatus(
744 media::PipelineStatus::PIPELINE_OK); 744 media::PipelineStatus::PIPELINE_OK);
745 after_frame = compositor_->GetCurrentFrame(); 745 after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
746 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 746 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
747 testing::Mock::VerifyAndClearExpectations(this); 747 testing::Mock::VerifyAndClearExpectations(this);
748 748
749 EXPECT_CALL(*this, DoSetWebLayer(false)); 749 EXPECT_CALL(*this, DoSetWebLayer(false));
750 EXPECT_CALL(*this, DoStopRendering()); 750 EXPECT_CALL(*this, DoStopRendering());
751 } 751 }
752 752
753 TEST_F(WebMediaPlayerMSTest, FrameSizeChange) { 753 TEST_F(WebMediaPlayerMSTest, FrameSizeChange) {
754 // During this test, the frame size of the input changes. 754 // During this test, the frame size of the input changes.
755 // We need to make sure, when sizeChanged() gets called, new size should be 755 // We need to make sure, when sizeChanged() gets called, new size should be
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 EXPECT_TRUE(player_.paused()); 822 EXPECT_TRUE(player_.paused());
823 823
824 // OnShown() should restart after a forced suspension. 824 // OnShown() should restart after a forced suspension.
825 player_.OnShown(); 825 player_.OnShown();
826 EXPECT_FALSE(player_.paused()); 826 EXPECT_FALSE(player_.paused());
827 EXPECT_CALL(*this, DoSetWebLayer(false)); 827 EXPECT_CALL(*this, DoSetWebLayer(false));
828 } 828 }
829 #endif 829 #endif
830 830
831 } // namespace content 831 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_ms_compositor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698