| 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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // TODO(scherkus): even though some filters are initialized on separate | 40 // TODO(scherkus): even though some filters are initialized on separate |
| 41 // threads these test aren't flaky... why? It's because filters' Initialize() | 41 // threads these test aren't flaky... why? It's because filters' Initialize() |
| 42 // is executed on |message_loop_| and the mock filters instantly call | 42 // is executed on |message_loop_| and the mock filters instantly call |
| 43 // InitializationComplete(), which keeps the pipeline humming along. If | 43 // InitializationComplete(), which keeps the pipeline humming along. If |
| 44 // either filters don't call InitializationComplete() immediately or filter | 44 // either filters don't call InitializationComplete() immediately or filter |
| 45 // initialization is moved to a separate thread this test will become flaky. | 45 // initialization is moved to a separate thread this test will become flaky. |
| 46 class PipelineImplTest : public ::testing::Test { | 46 class PipelineImplTest : public ::testing::Test { |
| 47 public: | 47 public: |
| 48 PipelineImplTest() | 48 PipelineImplTest() |
| 49 : pipeline_(&message_loop_), | 49 : pipeline_(new PipelineImpl(&message_loop_)), |
| 50 mocks_(new MockFilterFactory()) { | 50 mocks_(new MockFilterFactory()) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual ~PipelineImplTest() { | 53 virtual ~PipelineImplTest() { |
| 54 if (!pipeline_.IsRunning()) { | 54 if (!pipeline_->IsRunning()) { |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Expect a stop callback if we were started. | 58 // Expect a stop callback if we were started. |
| 59 EXPECT_CALL(callbacks_, OnStop()); | 59 EXPECT_CALL(callbacks_, OnStop()); |
| 60 pipeline_.Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 60 pipeline_->Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 61 &CallbackHelper::OnStop)); | 61 &CallbackHelper::OnStop)); |
| 62 message_loop_.RunAllPending(); | 62 message_loop_.RunAllPending(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 // Sets up expectations to allow the data source to initialize. | 66 // Sets up expectations to allow the data source to initialize. |
| 67 void InitializeDataSource() { | 67 void InitializeDataSource() { |
| 68 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) | 68 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) |
| 69 .WillOnce(Invoke(&RunFilterCallback)); | 69 .WillOnce(Invoke(&RunFilterCallback)); |
| 70 EXPECT_CALL(*mocks_->data_source(), SetPlaybackRate(0.0f)); | 70 EXPECT_CALL(*mocks_->data_source(), SetPlaybackRate(0.0f)); |
| 71 EXPECT_CALL(*mocks_->data_source(), Stop()); | 71 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 123 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 124 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 124 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 125 EXPECT_CALL(*mocks_->audio_renderer(), Stop()); | 125 EXPECT_CALL(*mocks_->audio_renderer(), Stop()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Sets up expectations on the callback and initializes the pipeline. Called | 128 // Sets up expectations on the callback and initializes the pipeline. Called |
| 129 // after tests have set expectations any filters they wish to use. | 129 // after tests have set expectations any filters they wish to use. |
| 130 void InitializePipeline() { | 130 void InitializePipeline() { |
| 131 // Expect an initialization callback. | 131 // Expect an initialization callback. |
| 132 EXPECT_CALL(callbacks_, OnStart()); | 132 EXPECT_CALL(callbacks_, OnStart()); |
| 133 pipeline_.Start(mocks_, "", | 133 pipeline_->Start(mocks_, "", |
| 134 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 134 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 135 &CallbackHelper::OnStart)); | 135 &CallbackHelper::OnStart)); |
| 136 message_loop_.RunAllPending(); | 136 message_loop_.RunAllPending(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Fixture members. | 139 // Fixture members. |
| 140 StrictMock<CallbackHelper> callbacks_; | 140 StrictMock<CallbackHelper> callbacks_; |
| 141 MessageLoop message_loop_; | 141 MessageLoop message_loop_; |
| 142 PipelineImpl pipeline_; | 142 scoped_refptr<PipelineImpl> pipeline_; |
| 143 scoped_refptr<media::MockFilterFactory> mocks_; | 143 scoped_refptr<media::MockFilterFactory> mocks_; |
| 144 | 144 |
| 145 private: | 145 private: |
| 146 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); | 146 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 // Test that playback controls methods no-op when the pipeline hasn't been | 149 // Test that playback controls methods no-op when the pipeline hasn't been |
| 150 // started. | 150 // started. |
| 151 TEST_F(PipelineImplTest, NotStarted) { | 151 TEST_F(PipelineImplTest, NotStarted) { |
| 152 const base::TimeDelta kZero; | 152 const base::TimeDelta kZero; |
| 153 | 153 |
| 154 // StrictMock<> will ensure these never get called, and valgrind/purify will | 154 // StrictMock<> will ensure these never get called, and valgrind/purify will |
| 155 // make sure the callbacks are instantly deleted. | 155 // make sure the callbacks are instantly deleted. |
| 156 pipeline_.Start(NULL, "", | 156 pipeline_->Start(NULL, "", |
| 157 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 158 &CallbackHelper::OnStart)); |
| 159 pipeline_->Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 160 &CallbackHelper::OnStop)); |
| 161 pipeline_->Seek(kZero, |
| 157 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 162 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 158 &CallbackHelper::OnStart)); | 163 &CallbackHelper::OnSeek)); |
| 159 pipeline_.Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | |
| 160 &CallbackHelper::OnStop)); | |
| 161 pipeline_.Seek(kZero, | |
| 162 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | |
| 163 &CallbackHelper::OnSeek)); | |
| 164 | 164 |
| 165 EXPECT_FALSE(pipeline_.IsRunning()); | 165 EXPECT_FALSE(pipeline_->IsRunning()); |
| 166 EXPECT_FALSE(pipeline_.IsInitialized()); | 166 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 167 EXPECT_FALSE(pipeline_.IsRendered("")); | 167 EXPECT_FALSE(pipeline_->IsRendered("")); |
| 168 EXPECT_FALSE(pipeline_.IsRendered(AudioDecoder::major_mime_type())); | 168 EXPECT_FALSE(pipeline_->IsRendered(AudioDecoder::major_mime_type())); |
| 169 EXPECT_FALSE(pipeline_.IsRendered(VideoDecoder::major_mime_type())); | 169 EXPECT_FALSE(pipeline_->IsRendered(VideoDecoder::major_mime_type())); |
| 170 | 170 |
| 171 // Setting should still work. | 171 // Setting should still work. |
| 172 EXPECT_EQ(0.0f, pipeline_.GetPlaybackRate()); | 172 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); |
| 173 pipeline_.SetPlaybackRate(-1.0f); | 173 pipeline_->SetPlaybackRate(-1.0f); |
| 174 EXPECT_EQ(0.0f, pipeline_.GetPlaybackRate()); | 174 EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); |
| 175 pipeline_.SetPlaybackRate(1.0f); | 175 pipeline_->SetPlaybackRate(1.0f); |
| 176 EXPECT_EQ(1.0f, pipeline_.GetPlaybackRate()); | 176 EXPECT_EQ(1.0f, pipeline_->GetPlaybackRate()); |
| 177 | 177 |
| 178 // Setting should still work. | 178 // Setting should still work. |
| 179 EXPECT_EQ(1.0f, pipeline_.GetVolume()); | 179 EXPECT_EQ(1.0f, pipeline_->GetVolume()); |
| 180 pipeline_.SetVolume(-1.0f); | 180 pipeline_->SetVolume(-1.0f); |
| 181 EXPECT_EQ(1.0f, pipeline_.GetVolume()); | 181 EXPECT_EQ(1.0f, pipeline_->GetVolume()); |
| 182 pipeline_.SetVolume(0.0f); | 182 pipeline_->SetVolume(0.0f); |
| 183 EXPECT_EQ(0.0f, pipeline_.GetVolume()); | 183 EXPECT_EQ(0.0f, pipeline_->GetVolume()); |
| 184 | 184 |
| 185 EXPECT_TRUE(kZero == pipeline_.GetCurrentTime()); | 185 EXPECT_TRUE(kZero == pipeline_->GetCurrentTime()); |
| 186 EXPECT_TRUE(kZero == pipeline_.GetBufferedTime()); | 186 EXPECT_TRUE(kZero == pipeline_->GetBufferedTime()); |
| 187 EXPECT_TRUE(kZero == pipeline_.GetDuration()); | 187 EXPECT_TRUE(kZero == pipeline_->GetDuration()); |
| 188 | 188 |
| 189 EXPECT_EQ(0, pipeline_.GetBufferedBytes()); | 189 EXPECT_EQ(0, pipeline_->GetBufferedBytes()); |
| 190 EXPECT_EQ(0, pipeline_.GetTotalBytes()); | 190 EXPECT_EQ(0, pipeline_->GetTotalBytes()); |
| 191 | 191 |
| 192 // Should always get set to zero. | 192 // Should always get set to zero. |
| 193 size_t width = 1u; | 193 size_t width = 1u; |
| 194 size_t height = 1u; | 194 size_t height = 1u; |
| 195 pipeline_.GetVideoSize(&width, &height); | 195 pipeline_->GetVideoSize(&width, &height); |
| 196 EXPECT_EQ(0u, width); | 196 EXPECT_EQ(0u, width); |
| 197 EXPECT_EQ(0u, height); | 197 EXPECT_EQ(0u, height); |
| 198 | 198 |
| 199 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); | 199 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 TEST_F(PipelineImplTest, NeverInitializes) { | 202 TEST_F(PipelineImplTest, NeverInitializes) { |
| 203 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) | 203 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) |
| 204 .WillOnce(Invoke(&DestroyFilterCallback)); | 204 .WillOnce(Invoke(&DestroyFilterCallback)); |
| 205 EXPECT_CALL(*mocks_->data_source(), Stop()); | 205 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 206 | 206 |
| 207 // This test hangs during initialization by never calling | 207 // This test hangs during initialization by never calling |
| 208 // InitializationComplete(). StrictMock<> will ensure that the callback is | 208 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 209 // never executed. | 209 // never executed. |
| 210 pipeline_.Start(mocks_, "", | 210 pipeline_->Start(mocks_, "", |
| 211 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 211 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 212 &CallbackHelper::OnStart)); | 212 &CallbackHelper::OnStart)); |
| 213 message_loop_.RunAllPending(); | 213 message_loop_.RunAllPending(); |
| 214 | 214 |
| 215 EXPECT_FALSE(pipeline_.IsInitialized()); | 215 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 216 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); | 216 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 217 | 217 |
| 218 // Because our callback will get executed when the test tears down, we'll | 218 // Because our callback will get executed when the test tears down, we'll |
| 219 // verify that nothing has been called, then set our expectation for the call | 219 // verify that nothing has been called, then set our expectation for the call |
| 220 // made during tear down. | 220 // made during tear down. |
| 221 Mock::VerifyAndClear(&callbacks_); | 221 Mock::VerifyAndClear(&callbacks_); |
| 222 EXPECT_CALL(callbacks_, OnStart()); | 222 EXPECT_CALL(callbacks_, OnStart()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 TEST_F(PipelineImplTest, RequiredFilterMissing) { | 225 TEST_F(PipelineImplTest, RequiredFilterMissing) { |
| 226 mocks_->set_creation_successful(false); | 226 mocks_->set_creation_successful(false); |
| 227 | 227 |
| 228 InitializePipeline(); | 228 InitializePipeline(); |
| 229 EXPECT_FALSE(pipeline_.IsInitialized()); | 229 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 230 EXPECT_EQ(PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | 230 EXPECT_EQ(PIPELINE_ERROR_REQUIRED_FILTER_MISSING, |
| 231 pipeline_.GetError()); | 231 pipeline_->GetError()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 TEST_F(PipelineImplTest, URLNotFound) { | 234 TEST_F(PipelineImplTest, URLNotFound) { |
| 235 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) | 235 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) |
| 236 .WillOnce(DoAll(SetError(mocks_->data_source(), | 236 .WillOnce(DoAll(SetError(mocks_->data_source(), |
| 237 PIPELINE_ERROR_URL_NOT_FOUND), | 237 PIPELINE_ERROR_URL_NOT_FOUND), |
| 238 Invoke(&RunFilterCallback))); | 238 Invoke(&RunFilterCallback))); |
| 239 EXPECT_CALL(*mocks_->data_source(), Stop()); | 239 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 240 | 240 |
| 241 InitializePipeline(); | 241 InitializePipeline(); |
| 242 EXPECT_FALSE(pipeline_.IsInitialized()); | 242 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 243 EXPECT_EQ(PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); | 243 EXPECT_EQ(PIPELINE_ERROR_URL_NOT_FOUND, pipeline_->GetError()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 TEST_F(PipelineImplTest, NoStreams) { | 246 TEST_F(PipelineImplTest, NoStreams) { |
| 247 // Manually set these expecations because SetPlaybackRate() is not called if | 247 // Manually set these expecations because SetPlaybackRate() is not called if |
| 248 // we cannot fully initialize the pipeline. | 248 // we cannot fully initialize the pipeline. |
| 249 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) | 249 EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull())) |
| 250 .WillOnce(Invoke(&RunFilterCallback)); | 250 .WillOnce(Invoke(&RunFilterCallback)); |
| 251 EXPECT_CALL(*mocks_->data_source(), Stop()); | 251 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 252 | 252 |
| 253 EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source(), NotNull())) | 253 EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source(), NotNull())) |
| 254 .WillOnce(Invoke(&RunFilterCallback)); | 254 .WillOnce(Invoke(&RunFilterCallback)); |
| 255 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) | 255 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) |
| 256 .WillRepeatedly(Return(0)); | 256 .WillRepeatedly(Return(0)); |
| 257 EXPECT_CALL(*mocks_->demuxer(), Stop()); | 257 EXPECT_CALL(*mocks_->demuxer(), Stop()); |
| 258 | 258 |
| 259 InitializePipeline(); | 259 InitializePipeline(); |
| 260 EXPECT_FALSE(pipeline_.IsInitialized()); | 260 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 261 EXPECT_EQ(PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_.GetError()); | 261 EXPECT_EQ(PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_->GetError()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 TEST_F(PipelineImplTest, AudioStream) { | 264 TEST_F(PipelineImplTest, AudioStream) { |
| 265 scoped_refptr<StrictMock<MockDemuxerStream> > stream = | 265 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 266 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 266 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 267 MockDemuxerStreamVector streams; | 267 MockDemuxerStreamVector streams; |
| 268 streams.push_back(stream); | 268 streams.push_back(stream); |
| 269 | 269 |
| 270 InitializeDataSource(); | 270 InitializeDataSource(); |
| 271 InitializeDemuxer(&streams); | 271 InitializeDemuxer(&streams); |
| 272 InitializeAudioDecoder(stream); | 272 InitializeAudioDecoder(stream); |
| 273 InitializeAudioRenderer(); | 273 InitializeAudioRenderer(); |
| 274 | 274 |
| 275 InitializePipeline(); | 275 InitializePipeline(); |
| 276 EXPECT_TRUE(pipeline_.IsInitialized()); | 276 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 277 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); | 277 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 278 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 278 EXPECT_TRUE(pipeline_->IsRendered(media::mime_type::kMajorTypeAudio)); |
| 279 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 279 EXPECT_FALSE(pipeline_->IsRendered(media::mime_type::kMajorTypeVideo)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST_F(PipelineImplTest, VideoStream) { | 282 TEST_F(PipelineImplTest, VideoStream) { |
| 283 scoped_refptr<StrictMock<MockDemuxerStream> > stream = | 283 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 284 new StrictMock<MockDemuxerStream>("video/x-foo"); | 284 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 285 MockDemuxerStreamVector streams; | 285 MockDemuxerStreamVector streams; |
| 286 streams.push_back(stream); | 286 streams.push_back(stream); |
| 287 | 287 |
| 288 InitializeDataSource(); | 288 InitializeDataSource(); |
| 289 InitializeDemuxer(&streams); | 289 InitializeDemuxer(&streams); |
| 290 InitializeVideoDecoder(stream); | 290 InitializeVideoDecoder(stream); |
| 291 InitializeVideoRenderer(); | 291 InitializeVideoRenderer(); |
| 292 | 292 |
| 293 InitializePipeline(); | 293 InitializePipeline(); |
| 294 EXPECT_TRUE(pipeline_.IsInitialized()); | 294 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 295 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); | 295 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 296 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 296 EXPECT_FALSE(pipeline_->IsRendered(media::mime_type::kMajorTypeAudio)); |
| 297 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 297 EXPECT_TRUE(pipeline_->IsRendered(media::mime_type::kMajorTypeVideo)); |
| 298 } | 298 } |
| 299 | 299 |
| 300 TEST_F(PipelineImplTest, AudioVideoStream) { | 300 TEST_F(PipelineImplTest, AudioVideoStream) { |
| 301 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 301 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 302 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 302 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 303 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = | 303 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 304 new StrictMock<MockDemuxerStream>("video/x-foo"); | 304 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 305 MockDemuxerStreamVector streams; | 305 MockDemuxerStreamVector streams; |
| 306 streams.push_back(audio_stream); | 306 streams.push_back(audio_stream); |
| 307 streams.push_back(video_stream); | 307 streams.push_back(video_stream); |
| 308 | 308 |
| 309 InitializeDataSource(); | 309 InitializeDataSource(); |
| 310 InitializeDemuxer(&streams); | 310 InitializeDemuxer(&streams); |
| 311 InitializeAudioDecoder(audio_stream); | 311 InitializeAudioDecoder(audio_stream); |
| 312 InitializeAudioRenderer(); | 312 InitializeAudioRenderer(); |
| 313 InitializeVideoDecoder(video_stream); | 313 InitializeVideoDecoder(video_stream); |
| 314 InitializeVideoRenderer(); | 314 InitializeVideoRenderer(); |
| 315 | 315 |
| 316 InitializePipeline(); | 316 InitializePipeline(); |
| 317 EXPECT_TRUE(pipeline_.IsInitialized()); | 317 EXPECT_TRUE(pipeline_->IsInitialized()); |
| 318 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); | 318 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); |
| 319 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 319 EXPECT_TRUE(pipeline_->IsRendered(media::mime_type::kMajorTypeAudio)); |
| 320 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 320 EXPECT_TRUE(pipeline_->IsRendered(media::mime_type::kMajorTypeVideo)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(PipelineImplTest, Seek) { | 323 TEST_F(PipelineImplTest, Seek) { |
| 324 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 324 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 325 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 325 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 326 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = | 326 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 327 new StrictMock<MockDemuxerStream>("video/x-foo"); | 327 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 328 MockDemuxerStreamVector streams; | 328 MockDemuxerStreamVector streams; |
| 329 streams.push_back(audio_stream); | 329 streams.push_back(audio_stream); |
| 330 streams.push_back(video_stream); | 330 streams.push_back(video_stream); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 349 EXPECT_CALL(*mocks_->video_decoder(), Seek(expected, NotNull())) | 349 EXPECT_CALL(*mocks_->video_decoder(), Seek(expected, NotNull())) |
| 350 .WillOnce(Invoke(&RunFilterCallback)); | 350 .WillOnce(Invoke(&RunFilterCallback)); |
| 351 EXPECT_CALL(*mocks_->video_renderer(), Seek(expected, NotNull())) | 351 EXPECT_CALL(*mocks_->video_renderer(), Seek(expected, NotNull())) |
| 352 .WillOnce(Invoke(&RunFilterCallback)); | 352 .WillOnce(Invoke(&RunFilterCallback)); |
| 353 | 353 |
| 354 // We expect a successful seek callback. | 354 // We expect a successful seek callback. |
| 355 EXPECT_CALL(callbacks_, OnSeek()); | 355 EXPECT_CALL(callbacks_, OnSeek()); |
| 356 | 356 |
| 357 // Initialize then seek! | 357 // Initialize then seek! |
| 358 InitializePipeline(); | 358 InitializePipeline(); |
| 359 pipeline_.Seek(expected, | 359 pipeline_->Seek(expected, |
| 360 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), | 360 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 361 &CallbackHelper::OnSeek)); | 361 &CallbackHelper::OnSeek)); |
| 362 message_loop_.RunAllPending(); | 362 message_loop_.RunAllPending(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(PipelineImplTest, SetVolume) { | 365 TEST_F(PipelineImplTest, SetVolume) { |
| 366 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 366 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 367 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 367 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 368 MockDemuxerStreamVector streams; | 368 MockDemuxerStreamVector streams; |
| 369 streams.push_back(audio_stream); | 369 streams.push_back(audio_stream); |
| 370 | 370 |
| 371 InitializeDataSource(); | 371 InitializeDataSource(); |
| 372 InitializeDemuxer(&streams); | 372 InitializeDemuxer(&streams); |
| 373 InitializeAudioDecoder(audio_stream); | 373 InitializeAudioDecoder(audio_stream); |
| 374 InitializeAudioRenderer(); | 374 InitializeAudioRenderer(); |
| 375 | 375 |
| 376 // The audio renderer should receive a call to SetVolume(). | 376 // The audio renderer should receive a call to SetVolume(). |
| 377 float expected = 0.5f; | 377 float expected = 0.5f; |
| 378 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); | 378 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); |
| 379 | 379 |
| 380 // Initialize then set volume! | 380 // Initialize then set volume! |
| 381 InitializePipeline(); | 381 InitializePipeline(); |
| 382 pipeline_.SetVolume(expected); | 382 pipeline_->SetVolume(expected); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace media | 385 } // namespace media |
| OLD | NEW |