| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| 11 #include "base/threading/simple_thread.h" | 11 #include "base/threading/simple_thread.h" |
| 12 #include "base/time/clock.h" | 12 #include "base/time/clock.h" |
| 13 #include "media/base/clock.h" | 13 #include "media/base/clock.h" |
| 14 #include "media/base/gmock_callback_support.h" | 14 #include "media/base/gmock_callback_support.h" |
| 15 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
| 16 #include "media/base/mock_filters.h" | 16 #include "media/base/mock_filters.h" |
| 17 #include "media/base/pipeline.h" | 17 #include "media/base/pipeline.h" |
| 18 #include "media/base/test_helpers.h" | 18 #include "media/base/test_helpers.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 if (audio_stream_) | 280 if (audio_stream_) |
| 281 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>()); | 281 EXPECT_CALL(*audio_renderer_, Stop(_)).WillOnce(RunClosure<0>()); |
| 282 | 282 |
| 283 if (video_stream_) | 283 if (video_stream_) |
| 284 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); | 284 EXPECT_CALL(*video_renderer_, Stop(_)).WillOnce(RunClosure<0>()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Fixture members. | 287 // Fixture members. |
| 288 StrictMock<CallbackHelper> callbacks_; | 288 StrictMock<CallbackHelper> callbacks_; |
| 289 base::SimpleTestClock test_clock_; | 289 base::SimpleTestTickClock test_tick_clock_; |
| 290 base::MessageLoop message_loop_; | 290 base::MessageLoop message_loop_; |
| 291 scoped_ptr<Pipeline> pipeline_; | 291 scoped_ptr<Pipeline> pipeline_; |
| 292 | 292 |
| 293 scoped_ptr<FilterCollection> filter_collection_; | 293 scoped_ptr<FilterCollection> filter_collection_; |
| 294 scoped_ptr<MockDemuxer> demuxer_; | 294 scoped_ptr<MockDemuxer> demuxer_; |
| 295 MockVideoRenderer* video_renderer_; | 295 MockVideoRenderer* video_renderer_; |
| 296 MockAudioRenderer* audio_renderer_; | 296 MockAudioRenderer* audio_renderer_; |
| 297 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; | 297 scoped_ptr<StrictMock<MockDemuxerStream> > audio_stream_; |
| 298 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; | 298 scoped_ptr<StrictMock<MockDemuxerStream> > video_stream_; |
| 299 AudioRenderer::TimeCB audio_time_cb_; | 299 AudioRenderer::TimeCB audio_time_cb_; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); | 599 base::TimeDelta duration = base::TimeDelta::FromSeconds(10); |
| 600 | 600 |
| 601 CreateAudioStream(); | 601 CreateAudioStream(); |
| 602 CreateVideoStream(); | 602 CreateVideoStream(); |
| 603 MockDemuxerStreamVector streams; | 603 MockDemuxerStreamVector streams; |
| 604 streams.push_back(audio_stream()); | 604 streams.push_back(audio_stream()); |
| 605 streams.push_back(video_stream()); | 605 streams.push_back(video_stream()); |
| 606 | 606 |
| 607 // Replace the clock so we can simulate wallclock time advancing w/o using | 607 // Replace the clock so we can simulate wallclock time advancing w/o using |
| 608 // Sleep(). | 608 // Sleep(). |
| 609 pipeline_->SetClockForTesting(new Clock(&test_clock_)); | 609 pipeline_->SetClockForTesting(new Clock(&test_tick_clock_)); |
| 610 | 610 |
| 611 InitializeDemuxer(&streams, duration); | 611 InitializeDemuxer(&streams, duration); |
| 612 InitializeAudioRenderer(audio_stream(), false); | 612 InitializeAudioRenderer(audio_stream(), false); |
| 613 InitializeVideoRenderer(video_stream()); | 613 InitializeVideoRenderer(video_stream()); |
| 614 InitializePipeline(PIPELINE_OK); | 614 InitializePipeline(PIPELINE_OK); |
| 615 | 615 |
| 616 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue()); | 616 EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue()); |
| 617 | 617 |
| 618 float playback_rate = 1.0f; | 618 float playback_rate = 1.0f; |
| 619 EXPECT_CALL(*demuxer_, SetPlaybackRate(playback_rate)); | 619 EXPECT_CALL(*demuxer_, SetPlaybackRate(playback_rate)); |
| 620 EXPECT_CALL(*video_renderer_, SetPlaybackRate(playback_rate)); | 620 EXPECT_CALL(*video_renderer_, SetPlaybackRate(playback_rate)); |
| 621 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate)); | 621 EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate)); |
| 622 pipeline_->SetPlaybackRate(playback_rate); | 622 pipeline_->SetPlaybackRate(playback_rate); |
| 623 message_loop_.RunUntilIdle(); | 623 message_loop_.RunUntilIdle(); |
| 624 | 624 |
| 625 InSequence s; | 625 InSequence s; |
| 626 | 626 |
| 627 // Verify that the clock doesn't advance since it hasn't been started by | 627 // Verify that the clock doesn't advance since it hasn't been started by |
| 628 // a time update from the audio stream. | 628 // a time update from the audio stream. |
| 629 int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); | 629 int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); |
| 630 test_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); | 630 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); |
| 631 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); | 631 EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); |
| 632 | 632 |
| 633 // Signal end of audio stream. | 633 // Signal end of audio stream. |
| 634 pipeline_->OnAudioRendererEnded(); | 634 pipeline_->OnAudioRendererEnded(); |
| 635 message_loop_.RunUntilIdle(); | 635 message_loop_.RunUntilIdle(); |
| 636 | 636 |
| 637 // Verify that the clock advances. | 637 // Verify that the clock advances. |
| 638 start_time = pipeline_->GetMediaTime().ToInternalValue(); | 638 start_time = pipeline_->GetMediaTime().ToInternalValue(); |
| 639 test_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); | 639 test_tick_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); |
| 640 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); | 640 EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); |
| 641 | 641 |
| 642 // Signal end of video stream and make sure OnEnded() callback occurs. | 642 // Signal end of video stream and make sure OnEnded() callback occurs. |
| 643 EXPECT_CALL(callbacks_, OnEnded()); | 643 EXPECT_CALL(callbacks_, OnEnded()); |
| 644 pipeline_->OnVideoRendererEnded(); | 644 pipeline_->OnVideoRendererEnded(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 TEST_F(PipelineTest, ErrorDuringSeek) { | 647 TEST_F(PipelineTest, ErrorDuringSeek) { |
| 648 CreateAudioStream(); | 648 CreateAudioStream(); |
| 649 MockDemuxerStreamVector streams; | 649 MockDemuxerStreamVector streams; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); | 1170 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); |
| 1171 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); | 1171 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); |
| 1172 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); | 1172 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); |
| 1173 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1173 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
| 1174 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1174 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1175 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); | 1175 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); |
| 1176 INSTANTIATE_TEARDOWN_TEST(Error, Starting); | 1176 INSTANTIATE_TEARDOWN_TEST(Error, Starting); |
| 1177 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1177 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1178 | 1178 |
| 1179 } // namespace media | 1179 } // namespace media |
| OLD | NEW |