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

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

Issue 1964253002: Bug Fix: Rendering stuck due to thread issue of WebMediaPlayerMSCompositor (M51) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 blink::WebMediaPlayer::ReadyStateHaveMetadata)); 590 blink::WebMediaPlayer::ReadyStateHaveMetadata));
591 EXPECT_CALL(*this, DoReadyStateChanged( 591 EXPECT_CALL(*this, DoReadyStateChanged(
592 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); 592 blink::WebMediaPlayer::ReadyStateHaveEnoughData));
593 message_loop_controller_.RunAndWaitForStatus( 593 message_loop_controller_.RunAndWaitForStatus(
594 media::PipelineStatus::PIPELINE_OK); 594 media::PipelineStatus::PIPELINE_OK);
595 testing::Mock::VerifyAndClearExpectations(this); 595 testing::Mock::VerifyAndClearExpectations(this);
596 596
597 // Here we call pause, and expect a freezing frame. 597 // Here we call pause, and expect a freezing frame.
598 EXPECT_CALL(*this, DoStopRendering()); 598 EXPECT_CALL(*this, DoStopRendering());
599 player_.pause(); 599 player_.pause();
600 auto prev_frame = compositor_->GetCurrentFrame(); 600 auto prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
601 message_loop_controller_.RunAndWaitForStatus( 601 message_loop_controller_.RunAndWaitForStatus(
602 media::PipelineStatus::PIPELINE_OK); 602 media::PipelineStatus::PIPELINE_OK);
603 auto after_frame = compositor_->GetCurrentFrame(); 603 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
604 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp()); 604 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp());
605 testing::Mock::VerifyAndClearExpectations(this); 605 testing::Mock::VerifyAndClearExpectations(this);
606 606
607 EXPECT_CALL(*this, DoSetWebLayer(false)); 607 EXPECT_CALL(*this, DoSetWebLayer(false));
608 } 608 }
609 609
610 TEST_P(WebMediaPlayerMSTest, PlayThenPauseThenPlay) { 610 TEST_P(WebMediaPlayerMSTest, PlayThenPauseThenPlay) {
611 const bool opaque_frame = GetParam(); 611 const bool opaque_frame = GetParam();
612 // Similary to PlayAndPause test above, this one focuses on testing that 612 // Similary to PlayAndPause test above, this one focuses on testing that
613 // WebMediaPlayerMS can be resumed after a period of paused status. 613 // WebMediaPlayerMS can be resumed after a period of paused status.
(...skipping 12 matching lines...) Expand all
626 blink::WebMediaPlayer::ReadyStateHaveMetadata)); 626 blink::WebMediaPlayer::ReadyStateHaveMetadata));
627 EXPECT_CALL(*this, DoReadyStateChanged( 627 EXPECT_CALL(*this, DoReadyStateChanged(
628 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); 628 blink::WebMediaPlayer::ReadyStateHaveEnoughData));
629 message_loop_controller_.RunAndWaitForStatus( 629 message_loop_controller_.RunAndWaitForStatus(
630 media::PipelineStatus::PIPELINE_OK); 630 media::PipelineStatus::PIPELINE_OK);
631 testing::Mock::VerifyAndClearExpectations(this); 631 testing::Mock::VerifyAndClearExpectations(this);
632 632
633 // Here we call pause, and expect a freezing frame. 633 // Here we call pause, and expect a freezing frame.
634 EXPECT_CALL(*this, DoStopRendering()); 634 EXPECT_CALL(*this, DoStopRendering());
635 player_.pause(); 635 player_.pause();
636 auto prev_frame = compositor_->GetCurrentFrame(); 636 auto prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
637 message_loop_controller_.RunAndWaitForStatus( 637 message_loop_controller_.RunAndWaitForStatus(
638 media::PipelineStatus::PIPELINE_OK); 638 media::PipelineStatus::PIPELINE_OK);
639 auto after_frame = compositor_->GetCurrentFrame(); 639 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
640 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp()); 640 EXPECT_EQ(prev_frame->timestamp(), after_frame->timestamp());
641 testing::Mock::VerifyAndClearExpectations(this); 641 testing::Mock::VerifyAndClearExpectations(this);
642 642
643 // We resume the player, and expect rendering can continue. 643 // We resume the player, and expect rendering can continue.
644 EXPECT_CALL(*this, DoStartRendering()); 644 EXPECT_CALL(*this, DoStartRendering());
645 player_.play(); 645 player_.play();
646 prev_frame = compositor_->GetCurrentFrame(); 646 prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
647 message_loop_controller_.RunAndWaitForStatus( 647 message_loop_controller_.RunAndWaitForStatus(
648 media::PipelineStatus::PIPELINE_OK); 648 media::PipelineStatus::PIPELINE_OK);
649 after_frame = compositor_->GetCurrentFrame(); 649 after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
650 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 650 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
651 testing::Mock::VerifyAndClearExpectations(this); 651 testing::Mock::VerifyAndClearExpectations(this);
652 652
653 EXPECT_CALL(*this, DoSetWebLayer(false)); 653 EXPECT_CALL(*this, DoSetWebLayer(false));
654 EXPECT_CALL(*this, DoStopRendering()); 654 EXPECT_CALL(*this, DoStopRendering());
655 } 655 }
656 656
657 INSTANTIATE_TEST_CASE_P(, WebMediaPlayerMSTest, ::testing::Bool()); 657 INSTANTIATE_TEST_CASE_P(, WebMediaPlayerMSTest, ::testing::Bool());
658 658
659 TEST_F(WebMediaPlayerMSTest, BackgroudRendering) { 659 TEST_F(WebMediaPlayerMSTest, BackgroudRendering) {
(...skipping 18 matching lines...) Expand all
678 blink::WebMediaPlayer::ReadyStateHaveMetadata)); 678 blink::WebMediaPlayer::ReadyStateHaveMetadata));
679 EXPECT_CALL(*this, DoReadyStateChanged( 679 EXPECT_CALL(*this, DoReadyStateChanged(
680 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); 680 blink::WebMediaPlayer::ReadyStateHaveEnoughData));
681 681
682 message_loop_controller_.RunAndWaitForStatus( 682 message_loop_controller_.RunAndWaitForStatus(
683 media::PipelineStatus::PIPELINE_OK); 683 media::PipelineStatus::PIPELINE_OK);
684 testing::Mock::VerifyAndClearExpectations(this); 684 testing::Mock::VerifyAndClearExpectations(this);
685 685
686 // Switch to background rendering, expect rendering to continue. 686 // Switch to background rendering, expect rendering to continue.
687 SetBackgroundRendering(true); 687 SetBackgroundRendering(true);
688 auto prev_frame = compositor_->GetCurrentFrame(); 688 auto 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 auto after_frame = compositor_->GetCurrentFrame(); 691 auto after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
692 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 692 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
693 693
694 // Switch to foreground rendering. 694 // Switch to foreground rendering.
695 SetBackgroundRendering(false); 695 SetBackgroundRendering(false);
696 prev_frame = compositor_->GetCurrentFrame(); 696 prev_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
697 message_loop_controller_.RunAndWaitForStatus( 697 message_loop_controller_.RunAndWaitForStatus(
698 media::PipelineStatus::PIPELINE_OK); 698 media::PipelineStatus::PIPELINE_OK);
699 after_frame = compositor_->GetCurrentFrame(); 699 after_frame = compositor_->GetCurrentFrameWithoutUpdatingStatistics();
700 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); 700 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp());
701 testing::Mock::VerifyAndClearExpectations(this); 701 testing::Mock::VerifyAndClearExpectations(this);
702 702
703 EXPECT_CALL(*this, DoSetWebLayer(false)); 703 EXPECT_CALL(*this, DoSetWebLayer(false));
704 EXPECT_CALL(*this, DoStopRendering()); 704 EXPECT_CALL(*this, DoStopRendering());
705 } 705 }
706 706
707 #if defined(OS_ANDROID) 707 #if defined(OS_ANDROID)
708 TEST_F(WebMediaPlayerMSTest, HiddenPlayerTests) { 708 TEST_F(WebMediaPlayerMSTest, HiddenPlayerTests) {
709 LoadAndGetFrameProvider(true); 709 LoadAndGetFrameProvider(true);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 EXPECT_TRUE(player_.paused()); 747 EXPECT_TRUE(player_.paused());
748 748
749 // OnShown() should restart after a forced suspension. 749 // OnShown() should restart after a forced suspension.
750 player_.OnShown(); 750 player_.OnShown();
751 EXPECT_FALSE(player_.paused()); 751 EXPECT_FALSE(player_.paused());
752 EXPECT_CALL(*this, DoSetWebLayer(false)); 752 EXPECT_CALL(*this, DoSetWebLayer(false));
753 } 753 }
754 #endif 754 #endif
755 755
756 } // namespace content 756 } // 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