OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 RunClosure<0>())); | 213 RunClosure<0>())); |
214 } | 214 } |
215 | 215 |
216 EXPECT_CALL(callbacks_, OnFlushed()); | 216 EXPECT_CALL(callbacks_, OnFlushed()); |
217 | 217 |
218 renderer_impl_->Flush( | 218 renderer_impl_->Flush( |
219 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); | 219 base::Bind(&CallbackHelper::OnFlushed, base::Unretained(&callbacks_))); |
220 base::RunLoop().RunUntilIdle(); | 220 base::RunLoop().RunUntilIdle(); |
221 } | 221 } |
222 | 222 |
223 void SetPlaybackRate(float playback_rate) { | 223 void SetPlaybackRate(double playback_rate) { |
224 EXPECT_CALL(time_source_, SetPlaybackRate(playback_rate)); | 224 EXPECT_CALL(time_source_, SetPlaybackRate(playback_rate)); |
225 renderer_impl_->SetPlaybackRate(playback_rate); | 225 renderer_impl_->SetPlaybackRate(playback_rate); |
226 base::RunLoop().RunUntilIdle(); | 226 base::RunLoop().RunUntilIdle(); |
227 } | 227 } |
228 | 228 |
229 int64 GetMediaTimeMs() { | 229 int64 GetMediaTimeMs() { |
230 return renderer_impl_->GetMediaTime().InMilliseconds(); | 230 return renderer_impl_->GetMediaTime().InMilliseconds(); |
231 } | 231 } |
232 | 232 |
233 bool IsMediaTimeAdvancing(float playback_rate) { | 233 bool IsMediaTimeAdvancing(double playback_rate) { |
234 int64 start_time_ms = GetMediaTimeMs(); | 234 int64 start_time_ms = GetMediaTimeMs(); |
235 const int64 time_to_advance_ms = 100; | 235 const int64 time_to_advance_ms = 100; |
236 | 236 |
237 test_tick_clock_.Advance( | 237 test_tick_clock_.Advance( |
238 base::TimeDelta::FromMilliseconds(time_to_advance_ms)); | 238 base::TimeDelta::FromMilliseconds(time_to_advance_ms)); |
239 | 239 |
240 if (GetMediaTimeMs() == start_time_ms + time_to_advance_ms * playback_rate) | 240 if (GetMediaTimeMs() == start_time_ms + time_to_advance_ms * playback_rate) |
241 return true; | 241 return true; |
242 | 242 |
243 DCHECK_EQ(start_time_ms, GetMediaTimeMs()); | 243 DCHECK_EQ(start_time_ms, GetMediaTimeMs()); |
244 return false; | 244 return false; |
245 } | 245 } |
246 | 246 |
247 bool IsMediaTimeAdvancing() { | 247 bool IsMediaTimeAdvancing() { |
248 return IsMediaTimeAdvancing(1.0f); | 248 return IsMediaTimeAdvancing(1.0); |
249 } | 249 } |
250 | 250 |
251 // Fixture members. | 251 // Fixture members. |
252 base::MessageLoop message_loop_; | 252 base::MessageLoop message_loop_; |
253 StrictMock<CallbackHelper> callbacks_; | 253 StrictMock<CallbackHelper> callbacks_; |
254 base::SimpleTestTickClock test_tick_clock_; | 254 base::SimpleTestTickClock test_tick_clock_; |
255 | 255 |
256 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; | 256 scoped_ptr<StrictMock<MockDemuxer> > demuxer_; |
257 StrictMock<MockVideoRenderer>* video_renderer_; | 257 StrictMock<MockVideoRenderer>* video_renderer_; |
258 StrictMock<MockAudioRenderer>* audio_renderer_; | 258 StrictMock<MockAudioRenderer>* audio_renderer_; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // Simulate underflow. | 373 // Simulate underflow. |
374 EXPECT_CALL(time_source_, StopTicking()); | 374 EXPECT_CALL(time_source_, StopTicking()); |
375 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); | 375 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); |
376 | 376 |
377 // Flush while underflowed. We shouldn't call StopTicking() again. | 377 // Flush while underflowed. We shouldn't call StopTicking() again. |
378 Flush(true); | 378 Flush(true); |
379 } | 379 } |
380 | 380 |
381 TEST_F(RendererImplTest, SetPlaybackRate) { | 381 TEST_F(RendererImplTest, SetPlaybackRate) { |
382 InitializeWithAudioAndVideo(); | 382 InitializeWithAudioAndVideo(); |
383 SetPlaybackRate(1.0f); | 383 SetPlaybackRate(1.0); |
384 SetPlaybackRate(2.0f); | 384 SetPlaybackRate(2.0); |
385 } | 385 } |
386 | 386 |
387 TEST_F(RendererImplTest, SetVolume) { | 387 TEST_F(RendererImplTest, SetVolume) { |
388 InitializeWithAudioAndVideo(); | 388 InitializeWithAudioAndVideo(); |
389 EXPECT_CALL(*audio_renderer_, SetVolume(2.0f)); | 389 EXPECT_CALL(*audio_renderer_, SetVolume(2.0f)); |
390 renderer_impl_->SetVolume(2.0f); | 390 renderer_impl_->SetVolume(2.0f); |
391 } | 391 } |
392 | 392 |
393 TEST_F(RendererImplTest, AudioStreamEnded) { | 393 TEST_F(RendererImplTest, AudioStreamEnded) { |
394 InitializeWithAudio(); | 394 InitializeWithAudio(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 Mock::VerifyAndClearExpectations(&time_source_); | 561 Mock::VerifyAndClearExpectations(&time_source_); |
562 | 562 |
563 EXPECT_CALL(time_source_, StopTicking()); | 563 EXPECT_CALL(time_source_, StopTicking()); |
564 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); | 564 audio_buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); |
565 | 565 |
566 // Nothing else should primed on the message loop. | 566 // Nothing else should primed on the message loop. |
567 base::RunLoop().RunUntilIdle(); | 567 base::RunLoop().RunUntilIdle(); |
568 } | 568 } |
569 | 569 |
570 } // namespace media | 570 } // namespace media |
OLD | NEW |