| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
| 8 #include "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
| 9 #include "media/base/media_format.h" | 9 #include "media/base/media_format.h" |
| 10 #include "media/base/filters.h" | 10 #include "media/base/filters.h" |
| 11 #include "media/base/factory.h" | 11 #include "media/base/factory.h" |
| 12 #include "media/base/filter_host.h" | 12 #include "media/base/filter_host.h" |
| 13 #include "media/base/mock_media_filters.h" | 13 #include "media/base/mock_filters.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace { | 16 using ::testing::DoAll; |
| 17 using ::testing::Return; |
| 18 using ::testing::StrictMock; |
| 17 | 19 |
| 18 class PipelineImplTest : public testing::Test { | 20 namespace media { |
| 19 protected: | 21 |
| 22 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 23 |
| 24 class PipelineImplTest : public ::testing::Test { |
| 25 public: |
| 20 PipelineImplTest() | 26 PipelineImplTest() |
| 21 : initialize_result_(false), | 27 : mocks_(new MockFilterFactory()), |
| 28 initialize_result_(false), |
| 22 seek_result_(false), | 29 seek_result_(false), |
| 23 initialize_event_(false, false), | 30 initialize_event_(false, false), |
| 24 seek_event_(false, false) { | 31 seek_event_(false, false) { |
| 25 } | 32 } |
| 26 | 33 |
| 27 virtual ~PipelineImplTest() {} | 34 virtual ~PipelineImplTest() { |
| 28 | |
| 29 virtual void TearDown() { | |
| 30 // Force the pipeline to shut down its thread. | 35 // Force the pipeline to shut down its thread. |
| 31 pipeline_.Stop(); | 36 pipeline_.Stop(); |
| 32 } | 37 } |
| 33 | 38 |
| 39 protected: |
| 34 // Called by tests after they have finished setting up MockFilterConfig. | 40 // Called by tests after they have finished setting up MockFilterConfig. |
| 35 // Initializes the pipeline and returns true if the initialization callback | 41 // Initializes the pipeline and returns true if the initialization callback |
| 36 // was executed, false otherwise. | 42 // was executed, false otherwise. |
| 37 bool InitializeAndWait() { | 43 bool InitializeAndWait() { |
| 38 DCHECK(!filters_); | 44 pipeline_.Start(mocks_, "", |
| 39 filters_ = new media::old_mocks::MockFilterFactory(&config_); | |
| 40 pipeline_.Start(filters_, "", | |
| 41 NewCallback(this, &PipelineImplTest::OnInitialize)); | 45 NewCallback(this, &PipelineImplTest::OnInitialize)); |
| 42 return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); | 46 return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); |
| 43 } | 47 } |
| 44 | 48 |
| 45 // Issues a seek on the pipeline and returns true if the seek callback was | 49 // Issues a seek on the pipeline and returns true if the seek callback was |
| 46 // executed, false otherwise. | 50 // executed, false otherwise. |
| 47 bool SeekAndWait(const base::TimeDelta& time) { | 51 bool SeekAndWait(const base::TimeDelta& time) { |
| 48 pipeline_.Seek(time, NewCallback(this, &PipelineImplTest::OnSeek)); | 52 pipeline_.Seek(time, NewCallback(this, &PipelineImplTest::OnSeek)); |
| 49 return seek_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); | 53 return seek_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); |
| 50 } | 54 } |
| 51 | 55 |
| 56 // Sets up expectations to allow the data source to initialize. |
| 57 void InitializeDataSource() { |
| 58 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 59 .WillOnce(DoAll(InitializationComplete(mocks_->data_source()), |
| 60 Return(true))); |
| 61 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 62 } |
| 63 |
| 64 // Sets up expectations to allow the demuxer to initialize. |
| 65 void InitializeDemuxer(MockDemuxerStreamVector* streams) { |
| 66 EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source())) |
| 67 .WillOnce(DoAll(InitializationComplete(mocks_->demuxer()), |
| 68 Return(true))); |
| 69 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) |
| 70 .WillRepeatedly(Return(streams->size())); |
| 71 EXPECT_CALL(*mocks_->demuxer(), Stop()); |
| 72 |
| 73 // Configure the demuxer to return the streams. |
| 74 for (size_t i = 0; i < streams->size(); ++i) { |
| 75 scoped_refptr<DemuxerStream> stream = (*streams)[i]; |
| 76 EXPECT_CALL(*mocks_->demuxer(), GetStream(i)) |
| 77 .WillRepeatedly(Return(stream)); |
| 78 } |
| 79 } |
| 80 |
| 81 // Sets up expectations to allow the video decoder to initialize. |
| 82 void InitializeVideoDecoder(MockDemuxerStream* stream) { |
| 83 EXPECT_CALL(*mocks_->video_decoder(), Initialize(stream)) |
| 84 .WillOnce(DoAll(InitializationComplete(mocks_->video_decoder()), |
| 85 Return(true))); |
| 86 EXPECT_CALL(*mocks_->video_decoder(), Stop()); |
| 87 } |
| 88 |
| 89 // Sets up expectations to allow the audio decoder to initialize. |
| 90 void InitializeAudioDecoder(MockDemuxerStream* stream) { |
| 91 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream)) |
| 92 .WillOnce(DoAll(InitializationComplete(mocks_->audio_decoder()), |
| 93 Return(true))); |
| 94 EXPECT_CALL(*mocks_->audio_decoder(), Stop()); |
| 95 } |
| 96 |
| 97 // Sets up expectations to allow the video renderer to initialize. |
| 98 void InitializeVideoRenderer() { |
| 99 EXPECT_CALL(*mocks_->video_renderer(), Initialize(mocks_->video_decoder())) |
| 100 .WillOnce(DoAll(InitializationComplete(mocks_->video_renderer()), |
| 101 Return(true))); |
| 102 EXPECT_CALL(*mocks_->video_renderer(), Stop()); |
| 103 } |
| 104 |
| 105 // Sets up expectations to allow the audio renderer to initialize. |
| 106 void InitializeAudioRenderer() { |
| 107 EXPECT_CALL(*mocks_->audio_renderer(), Initialize(mocks_->audio_decoder())) |
| 108 .WillOnce(DoAll(InitializationComplete(mocks_->audio_renderer()), |
| 109 Return(true))); |
| 110 EXPECT_CALL(*mocks_->audio_renderer(), Stop()); |
| 111 } |
| 112 |
| 52 // Fixture members. | 113 // Fixture members. |
| 53 media::PipelineImpl pipeline_; | 114 media::PipelineImpl pipeline_; |
| 54 scoped_refptr<media::old_mocks::MockFilterFactory> filters_; | 115 scoped_refptr<media::MockFilterFactory> mocks_; |
| 55 media::old_mocks::MockFilterConfig config_; | |
| 56 bool initialize_result_; | 116 bool initialize_result_; |
| 57 bool seek_result_; | 117 bool seek_result_; |
| 58 | 118 |
| 59 private: | 119 private: |
| 60 void OnInitialize(bool result) { | 120 void OnInitialize(bool result) { |
| 61 initialize_result_ = result; | 121 initialize_result_ = result; |
| 62 initialize_event_.Signal(); | 122 initialize_event_.Signal(); |
| 63 } | 123 } |
| 64 | 124 |
| 65 void OnSeek(bool result) { | 125 void OnSeek(bool result) { |
| 66 seek_result_ = result; | 126 seek_result_ = result; |
| 67 seek_event_.Signal(); | 127 seek_event_.Signal(); |
| 68 } | 128 } |
| 69 | 129 |
| 70 // Used to wait for callbacks. | 130 // Used to wait for callbacks. |
| 71 base::WaitableEvent initialize_event_; | 131 base::WaitableEvent initialize_event_; |
| 72 base::WaitableEvent seek_event_; | 132 base::WaitableEvent seek_event_; |
| 73 | 133 |
| 74 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); | 134 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); |
| 75 }; | 135 }; |
| 76 | 136 |
| 77 TEST_F(PipelineImplTest, NeverInitializes) { | 137 TEST_F(PipelineImplTest, NeverInitializes) { |
| 78 config_.data_source_behavior = media::old_mocks::MOCK_DATA_SOURCE_NEVER_INIT; | 138 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 139 .WillOnce(Return(true)); |
| 140 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 79 | 141 |
| 80 // This test hangs during initialization by never calling | 142 // This test hangs during initialization by never calling |
| 81 // InitializationComplete(). Make sure we tear down the pipeline properly. | 143 // InitializationComplete(). Make sure we tear down the pipeline properly. |
| 82 ASSERT_FALSE(InitializeAndWait()); | 144 ASSERT_FALSE(InitializeAndWait()); |
| 83 EXPECT_FALSE(initialize_result_); | 145 EXPECT_FALSE(initialize_result_); |
| 84 EXPECT_FALSE(pipeline_.IsInitialized()); | 146 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 85 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 147 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); |
| 86 } | 148 } |
| 87 | 149 |
| 88 TEST_F(PipelineImplTest, RequiredFilterMissing) { | 150 TEST_F(PipelineImplTest, RequiredFilterMissing) { |
| 89 config_.create_filter = false; | 151 mocks_->set_creation_successful(false); |
| 90 | 152 |
| 91 ASSERT_TRUE(InitializeAndWait()); | 153 ASSERT_TRUE(InitializeAndWait()); |
| 92 EXPECT_FALSE(initialize_result_); | 154 EXPECT_FALSE(initialize_result_); |
| 93 EXPECT_FALSE(pipeline_.IsInitialized()); | 155 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 94 EXPECT_EQ(media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | 156 EXPECT_EQ(media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING, |
| 95 pipeline_.GetError()); | 157 pipeline_.GetError()); |
| 96 } | 158 } |
| 97 | 159 |
| 98 TEST_F(PipelineImplTest, URLNotFound) { | 160 TEST_F(PipelineImplTest, URLNotFound) { |
| 99 config_.data_source_behavior = | 161 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 100 media::old_mocks::MOCK_DATA_SOURCE_URL_ERROR_IN_INIT; | 162 .WillOnce(DoAll(Error(mocks_->data_source(), |
| 163 PIPELINE_ERROR_URL_NOT_FOUND), |
| 164 Return(false))); |
| 165 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 101 | 166 |
| 102 ASSERT_TRUE(InitializeAndWait()); | 167 ASSERT_TRUE(InitializeAndWait()); |
| 103 EXPECT_FALSE(initialize_result_); | 168 EXPECT_FALSE(initialize_result_); |
| 104 EXPECT_FALSE(pipeline_.IsInitialized()); | 169 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 105 EXPECT_EQ(media::PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); | 170 EXPECT_EQ(media::PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); |
| 106 } | 171 } |
| 107 | 172 |
| 108 TEST_F(PipelineImplTest, NoStreams) { | 173 TEST_F(PipelineImplTest, NoStreams) { |
| 109 config_.has_audio = false; | 174 MockDemuxerStreamVector streams; |
| 110 config_.has_video = false; | 175 InitializeDataSource(); |
| 176 InitializeDemuxer(&streams); |
| 111 | 177 |
| 112 ASSERT_TRUE(InitializeAndWait()); | 178 ASSERT_TRUE(InitializeAndWait()); |
| 113 EXPECT_FALSE(initialize_result_); | 179 EXPECT_FALSE(initialize_result_); |
| 114 EXPECT_FALSE(pipeline_.IsInitialized()); | 180 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 115 EXPECT_EQ(media::PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_.GetError()); | 181 EXPECT_EQ(media::PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_.GetError()); |
| 116 | |
| 117 EXPECT_FALSE(filters_->audio_decoder()); | |
| 118 EXPECT_FALSE(filters_->audio_renderer()); | |
| 119 EXPECT_FALSE(filters_->video_decoder()); | |
| 120 EXPECT_FALSE(filters_->video_renderer()); | |
| 121 } | 182 } |
| 122 | 183 |
| 123 TEST_F(PipelineImplTest, AudioStream) { | 184 TEST_F(PipelineImplTest, AudioStream) { |
| 124 config_.has_video = false; | 185 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 186 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 187 MockDemuxerStreamVector streams; |
| 188 streams.push_back(stream); |
| 189 |
| 190 InitializeDataSource(); |
| 191 InitializeDemuxer(&streams); |
| 192 InitializeAudioDecoder(stream); |
| 193 InitializeAudioRenderer(); |
| 125 | 194 |
| 126 ASSERT_TRUE(InitializeAndWait()); | 195 ASSERT_TRUE(InitializeAndWait()); |
| 127 EXPECT_TRUE(initialize_result_); | 196 EXPECT_TRUE(initialize_result_); |
| 128 EXPECT_TRUE(pipeline_.IsInitialized()); | 197 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 129 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 198 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); |
| 130 | |
| 131 size_t width, height; | |
| 132 pipeline_.GetVideoSize(&width, &height); | |
| 133 EXPECT_EQ(0u, width); | |
| 134 EXPECT_EQ(0u, height); | |
| 135 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 199 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 136 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 200 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 137 | |
| 138 EXPECT_TRUE(filters_->audio_decoder()); | |
| 139 EXPECT_TRUE(filters_->audio_renderer()); | |
| 140 EXPECT_FALSE(filters_->video_decoder()); | |
| 141 EXPECT_FALSE(filters_->video_renderer()); | |
| 142 } | 201 } |
| 143 | 202 |
| 144 TEST_F(PipelineImplTest, VideoStream) { | 203 TEST_F(PipelineImplTest, VideoStream) { |
| 145 config_.has_audio = false; | 204 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 205 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 206 MockDemuxerStreamVector streams; |
| 207 streams.push_back(stream); |
| 208 |
| 209 InitializeDataSource(); |
| 210 InitializeDemuxer(&streams); |
| 211 InitializeVideoDecoder(stream); |
| 212 InitializeVideoRenderer(); |
| 146 | 213 |
| 147 ASSERT_TRUE(InitializeAndWait()); | 214 ASSERT_TRUE(InitializeAndWait()); |
| 148 EXPECT_TRUE(initialize_result_); | 215 EXPECT_TRUE(initialize_result_); |
| 149 EXPECT_TRUE(pipeline_.IsInitialized()); | 216 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 150 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 217 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); |
| 151 | |
| 152 size_t width, height; | |
| 153 pipeline_.GetVideoSize(&width, &height); | |
| 154 EXPECT_EQ(config_.video_width, width); | |
| 155 EXPECT_EQ(config_.video_height, height); | |
| 156 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 218 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 157 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 219 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 158 | |
| 159 EXPECT_FALSE(filters_->audio_decoder()); | |
| 160 EXPECT_FALSE(filters_->audio_renderer()); | |
| 161 EXPECT_TRUE(filters_->video_decoder()); | |
| 162 EXPECT_TRUE(filters_->video_renderer()); | |
| 163 } | 220 } |
| 164 | 221 |
| 165 TEST_F(PipelineImplTest, AudioVideoStream) { | 222 TEST_F(PipelineImplTest, AudioVideoStream) { |
| 223 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 224 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 225 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 226 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 227 MockDemuxerStreamVector streams; |
| 228 streams.push_back(audio_stream); |
| 229 streams.push_back(video_stream); |
| 230 |
| 231 InitializeDataSource(); |
| 232 InitializeDemuxer(&streams); |
| 233 InitializeAudioDecoder(audio_stream); |
| 234 InitializeAudioRenderer(); |
| 235 InitializeVideoDecoder(video_stream); |
| 236 InitializeVideoRenderer(); |
| 237 |
| 166 ASSERT_TRUE(InitializeAndWait()); | 238 ASSERT_TRUE(InitializeAndWait()); |
| 167 EXPECT_TRUE(initialize_result_); | 239 EXPECT_TRUE(initialize_result_); |
| 168 EXPECT_TRUE(pipeline_.IsInitialized()); | 240 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 169 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 241 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); |
| 170 | |
| 171 size_t width, height; | |
| 172 pipeline_.GetVideoSize(&width, &height); | |
| 173 EXPECT_EQ(config_.video_width, width); | |
| 174 EXPECT_EQ(config_.video_height, height); | |
| 175 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 242 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 176 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 243 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 177 | |
| 178 EXPECT_TRUE(filters_->audio_decoder()); | |
| 179 EXPECT_TRUE(filters_->audio_renderer()); | |
| 180 EXPECT_TRUE(filters_->video_decoder()); | |
| 181 EXPECT_TRUE(filters_->video_renderer()); | |
| 182 } | 244 } |
| 183 | 245 |
| 184 TEST_F(PipelineImplTest, Seek) { | 246 TEST_F(PipelineImplTest, Seek) { |
| 247 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 248 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 249 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 250 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 251 MockDemuxerStreamVector streams; |
| 252 streams.push_back(audio_stream); |
| 253 streams.push_back(video_stream); |
| 254 |
| 255 InitializeDataSource(); |
| 256 InitializeDemuxer(&streams); |
| 257 InitializeAudioDecoder(audio_stream); |
| 258 InitializeAudioRenderer(); |
| 259 InitializeVideoDecoder(video_stream); |
| 260 InitializeVideoRenderer(); |
| 261 |
| 262 // Every filter should receive a call to Seek(). |
| 263 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); |
| 264 EXPECT_CALL(*mocks_->data_source(), Seek(expected)); |
| 265 EXPECT_CALL(*mocks_->demuxer(), Seek(expected)); |
| 266 EXPECT_CALL(*mocks_->audio_decoder(), Seek(expected)); |
| 267 EXPECT_CALL(*mocks_->audio_renderer(), Seek(expected)); |
| 268 EXPECT_CALL(*mocks_->video_decoder(), Seek(expected)); |
| 269 EXPECT_CALL(*mocks_->video_renderer(), Seek(expected)); |
| 270 |
| 271 // Initialize then seek! |
| 185 ASSERT_TRUE(InitializeAndWait()); | 272 ASSERT_TRUE(InitializeAndWait()); |
| 186 | |
| 187 // Seek and verify callback returned true. | |
| 188 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); | |
| 189 EXPECT_TRUE(SeekAndWait(expected)); | 273 EXPECT_TRUE(SeekAndWait(expected)); |
| 190 EXPECT_TRUE(seek_result_); | 274 EXPECT_TRUE(seek_result_); |
| 191 | |
| 192 // Verify every filter received the seek. | |
| 193 // TODO(scherkus): implement whatever it takes so I can use EXPECT_EQ with | |
| 194 // base::TimeDelta. | |
| 195 EXPECT_TRUE(expected == filters_->data_source()->seek_time()); | |
| 196 EXPECT_TRUE(expected == filters_->demuxer()->seek_time()); | |
| 197 EXPECT_TRUE(expected == filters_->audio_decoder()->seek_time()); | |
| 198 EXPECT_TRUE(expected == filters_->audio_renderer()->seek_time()); | |
| 199 EXPECT_TRUE(expected == filters_->video_decoder()->seek_time()); | |
| 200 EXPECT_TRUE(expected == filters_->video_renderer()->seek_time()); | |
| 201 } | 275 } |
| 202 | 276 |
| 203 // Try to execute Start()/Stop() on the Pipeline many times and very fast. This | 277 TEST_F(PipelineImplTest, SetVolume) { |
| 204 // test is trying to simulate the situation where the pipeline can get dead | 278 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 205 // locked very easily by quickly calling Start()/Stop(). | 279 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 206 TEST_F(PipelineImplTest, StressTestPipelineStartStop) { | 280 MockDemuxerStreamVector streams; |
| 207 media::old_mocks::MockFilterConfig config; | 281 streams.push_back(audio_stream); |
| 208 const int kTimes = 1000; | 282 |
| 209 for (int i = 0; i < kTimes; ++i) { | 283 InitializeDataSource(); |
| 210 scoped_refptr<media::old_mocks::MockFilterFactory> factory = | 284 InitializeDemuxer(&streams); |
| 211 new media::old_mocks::MockFilterFactory(&config); | 285 InitializeAudioDecoder(audio_stream); |
| 212 media::PipelineImpl pipeline; | 286 InitializeAudioRenderer(); |
| 213 pipeline.Start(factory.get(), "", NULL); | 287 |
| 214 pipeline.Stop(); | 288 // The audio renderer should receive a call to SetVolume(). |
| 215 } | 289 float expected = 0.5f; |
| 290 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); |
| 291 |
| 292 // Initialize then set volume! |
| 293 ASSERT_TRUE(InitializeAndWait()); |
| 294 pipeline_.SetVolume(expected); |
| 216 } | 295 } |
| 217 | 296 |
| 218 // TODO(ralphl): Add a unit test that makes sure that the mock audio filter | 297 } // namespace media |
| 219 // is actually called on a SetVolume() call to the pipeline. I almost checked | |
| 220 // in code that broke this, but all unit tests were passing. | |
| 221 | 298 |
| 222 } // namespace | |
| OLD | NEW |