Index: media/blink/webmediaplayer_impl_unittest.cc |
diff --git a/media/blink/webmediaplayer_impl_unittest.cc b/media/blink/webmediaplayer_impl_unittest.cc |
index f903c2d07810ca84704a10c299831241e273c81e..1151a25232b56c7724f4fbad630d75722996d256 100644 |
--- a/media/blink/webmediaplayer_impl_unittest.cc |
+++ b/media/blink/webmediaplayer_impl_unittest.cc |
@@ -84,9 +84,14 @@ class DummyWebMediaPlayerClient : public blink::WebMediaPlayerClient { |
void connectedToRemoteDevice() override {} |
void disconnectedFromRemoteDevice() override {} |
void cancelledRemotePlaybackRequest() override {} |
+ bool isAutoplayingMuted() override { return is_autoplaying_muted_; } |
void requestReload(const blink::WebURL& newUrl) override {} |
+ void set_is_autoplaying_muted(bool value) { is_autoplaying_muted_ = value; } |
+ |
private: |
+ bool is_autoplaying_muted_ = false; |
+ |
DISALLOW_COPY_AND_ASSIGN(DummyWebMediaPlayerClient); |
}; |
@@ -215,6 +220,10 @@ class WebMediaPlayerImplTest : public testing::Test { |
return wmpi_->UpdatePlayState_ComputePlayState(false, false, false); |
} |
+ void SetDelegateState(WebMediaPlayerImpl::DelegateState state) { |
+ wmpi_->SetDelegateState(state); |
+ } |
+ |
bool IsSuspended() { return wmpi_->pipeline_controller_.IsSuspended(); } |
void AddBufferedRanges() { |
@@ -653,4 +662,54 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_BackgroundedVideoPaused) { |
EXPECT_TRUE(state.is_suspended); |
} |
+TEST_F(WebMediaPlayerImplTest, SetVolumeCallsDidPlay) { |
sandersd (OOO until July 31)
2016/10/04 23:53:04
We don't have tests that all the other triggers re
mlamouri (slow - plz ping)
2016/10/05 16:19:49
Added the comment and removed the test.
|
+ InitializeDefaultWebMediaPlayerImpl(); |
+ SetMetadata(true, true); |
+ SetReadyState(blink::WebMediaPlayer::ReadyStateHaveFutureData); |
+ SetPaused(false); |
+ |
+ EXPECT_CALL(delegate_, DidPlay(_, _, _, _, _)); |
+ wmpi_->setVolume(1.0); |
+} |
+ |
+TEST_F(WebMediaPlayerImplTest, AutoplayMuted_StartsAndStops) { |
+ InitializeDefaultWebMediaPlayerImpl(); |
+ WebMediaPlayerImpl::PlayState state; |
+ SetMetadata(true, true); |
+ SetReadyState(blink::WebMediaPlayer::ReadyStateHaveFutureData); |
+ SetPaused(false); |
+ |
+ EXPECT_CALL(delegate_, DidPlay(_, true, false, false, _)); |
+ EXPECT_CALL(delegate_, DidPlay(_, true, true, false, _)); |
sandersd (OOO until July 31)
2016/10/04 23:53:04
Move these right before the respective SetDelegate
mlamouri (slow - plz ping)
2016/10/05 16:19:49
Done.
|
+ |
+ client_.set_is_autoplaying_muted(true); |
+ state = ComputePlayState(); |
+ EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state); |
+ SetDelegateState(state.delegate_state); |
sandersd (OOO until July 31)
2016/10/04 23:53:04
This seems to be testing two different things. Pro
mlamouri (slow - plz ping)
2016/10/05 16:19:49
I'm not sure I'm following this. ComputePlayState(
sandersd (OOO until July 31)
2016/10/05 17:38:17
Sorry, I should have said UpdatePlayState().
|
+ |
+ client_.set_is_autoplaying_muted(false); |
+ state = ComputePlayState(); |
+ EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state); |
+ SetDelegateState(state.delegate_state); |
+} |
+ |
+TEST_F(WebMediaPlayerImplTest, AutoplayMuted_SetVolume) { |
+ InitializeDefaultWebMediaPlayerImpl(); |
+ WebMediaPlayerImpl::PlayState state; |
+ SetMetadata(true, true); |
+ SetReadyState(blink::WebMediaPlayer::ReadyStateHaveFutureData); |
+ SetPaused(false); |
+ |
+ EXPECT_CALL(delegate_, DidPlay(_, true, false, false, _)); |
+ EXPECT_CALL(delegate_, DidPlay(_, true, true, false, _)); |
+ |
+ client_.set_is_autoplaying_muted(true); |
+ state = ComputePlayState(); |
+ EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state); |
+ SetDelegateState(state.delegate_state); |
+ |
+ client_.set_is_autoplaying_muted(false); |
+ wmpi_->setVolume(1.0); |
+} |
+ |
} // namespace media |