| 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_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 using ::testing::DoAll; | 16 using ::testing::DoAll; |
| 17 using ::testing::Mock; |
| 17 using ::testing::Return; | 18 using ::testing::Return; |
| 18 using ::testing::StrictMock; | 19 using ::testing::StrictMock; |
| 19 | 20 |
| 20 namespace media { | 21 namespace media { |
| 21 | 22 |
| 22 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 23 // Used for setting expectations on pipeline callbacks. Using a StrictMock |
| 24 // also lets us test for missing callbacks. |
| 25 class CallbackHelper { |
| 26 public: |
| 27 CallbackHelper() {} |
| 28 virtual ~CallbackHelper() {} |
| 23 | 29 |
| 30 MOCK_METHOD1(OnInitialize, void(bool result)); |
| 31 MOCK_METHOD1(OnSeek, void(bool result)); |
| 32 MOCK_METHOD1(OnStop, void(bool result)); |
| 33 |
| 34 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
| 36 }; |
| 37 |
| 38 // TODO(scherkus): even though some filters are initialized on separate |
| 39 // threads these test aren't flaky... why? It's because filters' Initialize() |
| 40 // is executed on |message_loop_| and the mock filters instantly call |
| 41 // InitializationComplete(), which keeps the pipeline humming along. If |
| 42 // either filters don't call InitializationComplete() immediately or filter |
| 43 // initialization is moved to a separate thread this test will become flaky. |
| 24 class PipelineImplTest : public ::testing::Test { | 44 class PipelineImplTest : public ::testing::Test { |
| 25 public: | 45 public: |
| 26 PipelineImplTest() | 46 PipelineImplTest() |
| 27 : mocks_(new MockFilterFactory()), | 47 : pipeline_(&message_loop_), |
| 28 initialize_result_(false), | 48 mocks_(new MockFilterFactory()) { |
| 29 seek_result_(false), | |
| 30 initialize_event_(false, false), | |
| 31 seek_event_(false, false) { | |
| 32 } | 49 } |
| 33 | 50 |
| 34 virtual ~PipelineImplTest() { | 51 virtual ~PipelineImplTest() { |
| 35 // Force the pipeline to shut down its thread. | 52 if (!pipeline_.IsRunning()) { |
| 36 pipeline_.Stop(); | 53 return; |
| 54 } |
| 55 |
| 56 // Expect a stop callback if we were started. |
| 57 EXPECT_CALL(callbacks_, OnStop(true)); |
| 58 pipeline_.Stop(NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 59 &CallbackHelper::OnStop)); |
| 60 message_loop_.RunAllPending(); |
| 37 } | 61 } |
| 38 | 62 |
| 39 protected: | 63 protected: |
| 40 // Called by tests after they have finished setting up MockFilterConfig. | |
| 41 // Initializes the pipeline and returns true if the initialization callback | |
| 42 // was executed, false otherwise. | |
| 43 bool InitializeAndWait() { | |
| 44 pipeline_.Start(mocks_, "", | |
| 45 NewCallback(this, &PipelineImplTest::OnInitialize)); | |
| 46 return initialize_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); | |
| 47 } | |
| 48 | |
| 49 // Issues a seek on the pipeline and returns true if the seek callback was | |
| 50 // executed, false otherwise. | |
| 51 bool SeekAndWait(const base::TimeDelta& time) { | |
| 52 pipeline_.Seek(time, NewCallback(this, &PipelineImplTest::OnSeek)); | |
| 53 return seek_event_.TimedWait(base::TimeDelta::FromMilliseconds(500)); | |
| 54 } | |
| 55 | |
| 56 // Sets up expectations to allow the data source to initialize. | 64 // Sets up expectations to allow the data source to initialize. |
| 57 void InitializeDataSource() { | 65 void InitializeDataSource() { |
| 58 EXPECT_CALL(*mocks_->data_source(), Initialize("")) | 66 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 59 .WillOnce(DoAll(InitializationComplete(mocks_->data_source()), | 67 .WillOnce(DoAll(InitializationComplete(mocks_->data_source()), |
| 60 Return(true))); | 68 Return(true))); |
| 61 EXPECT_CALL(*mocks_->data_source(), Stop()); | 69 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 62 } | 70 } |
| 63 | 71 |
| 64 // Sets up expectations to allow the demuxer to initialize. | 72 // Sets up expectations to allow the demuxer to initialize. |
| 73 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 65 void InitializeDemuxer(MockDemuxerStreamVector* streams) { | 74 void InitializeDemuxer(MockDemuxerStreamVector* streams) { |
| 66 EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source())) | 75 EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source())) |
| 67 .WillOnce(DoAll(InitializationComplete(mocks_->demuxer()), | 76 .WillOnce(DoAll(InitializationComplete(mocks_->demuxer()), |
| 68 Return(true))); | 77 Return(true))); |
| 69 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) | 78 EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams()) |
| 70 .WillRepeatedly(Return(streams->size())); | 79 .WillRepeatedly(Return(streams->size())); |
| 71 EXPECT_CALL(*mocks_->demuxer(), Stop()); | 80 EXPECT_CALL(*mocks_->demuxer(), Stop()); |
| 72 | 81 |
| 73 // Configure the demuxer to return the streams. | 82 // Configure the demuxer to return the streams. |
| 74 for (size_t i = 0; i < streams->size(); ++i) { | 83 for (size_t i = 0; i < streams->size(); ++i) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 103 } | 112 } |
| 104 | 113 |
| 105 // Sets up expectations to allow the audio renderer to initialize. | 114 // Sets up expectations to allow the audio renderer to initialize. |
| 106 void InitializeAudioRenderer() { | 115 void InitializeAudioRenderer() { |
| 107 EXPECT_CALL(*mocks_->audio_renderer(), Initialize(mocks_->audio_decoder())) | 116 EXPECT_CALL(*mocks_->audio_renderer(), Initialize(mocks_->audio_decoder())) |
| 108 .WillOnce(DoAll(InitializationComplete(mocks_->audio_renderer()), | 117 .WillOnce(DoAll(InitializationComplete(mocks_->audio_renderer()), |
| 109 Return(true))); | 118 Return(true))); |
| 110 EXPECT_CALL(*mocks_->audio_renderer(), Stop()); | 119 EXPECT_CALL(*mocks_->audio_renderer(), Stop()); |
| 111 } | 120 } |
| 112 | 121 |
| 122 // Sets up expectations on the callback and initializes the pipeline. Called |
| 123 // afters tests have set expectations any filters they wish to use. |
| 124 void InitializePipeline(bool callback_result) { |
| 125 // Expect an initialization callback. |
| 126 EXPECT_CALL(callbacks_, OnInitialize(callback_result)); |
| 127 pipeline_.Start(mocks_, "", |
| 128 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 129 &CallbackHelper::OnInitialize)); |
| 130 message_loop_.RunAllPending(); |
| 131 } |
| 132 |
| 113 // Fixture members. | 133 // Fixture members. |
| 114 media::PipelineImpl pipeline_; | 134 StrictMock<CallbackHelper> callbacks_; |
| 135 MessageLoop message_loop_; |
| 136 PipelineImpl pipeline_; |
| 115 scoped_refptr<media::MockFilterFactory> mocks_; | 137 scoped_refptr<media::MockFilterFactory> mocks_; |
| 116 bool initialize_result_; | |
| 117 bool seek_result_; | |
| 118 | 138 |
| 119 private: | 139 private: |
| 120 void OnInitialize(bool result) { | |
| 121 initialize_result_ = result; | |
| 122 initialize_event_.Signal(); | |
| 123 } | |
| 124 | |
| 125 void OnSeek(bool result) { | |
| 126 seek_result_ = result; | |
| 127 seek_event_.Signal(); | |
| 128 } | |
| 129 | |
| 130 // Used to wait for callbacks. | |
| 131 base::WaitableEvent initialize_event_; | |
| 132 base::WaitableEvent seek_event_; | |
| 133 | |
| 134 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); | 140 DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); |
| 135 }; | 141 }; |
| 136 | 142 |
| 137 TEST_F(PipelineImplTest, NeverInitializes) { | 143 TEST_F(PipelineImplTest, NeverInitializes) { |
| 138 EXPECT_CALL(*mocks_->data_source(), Initialize("")) | 144 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 139 .WillOnce(Return(true)); | 145 .WillOnce(Return(true)); |
| 140 EXPECT_CALL(*mocks_->data_source(), Stop()); | 146 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 141 | 147 |
| 142 // This test hangs during initialization by never calling | 148 // This test hangs during initialization by never calling |
| 143 // InitializationComplete(). Make sure we tear down the pipeline properly. | 149 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 144 ASSERT_FALSE(InitializeAndWait()); | 150 // never executed. |
| 145 EXPECT_FALSE(initialize_result_); | 151 pipeline_.Start(mocks_, "", |
| 152 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 153 &CallbackHelper::OnInitialize)); |
| 154 message_loop_.RunAllPending(); |
| 155 |
| 146 EXPECT_FALSE(pipeline_.IsInitialized()); | 156 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 147 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 157 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); |
| 158 |
| 159 // Because our callback will get executed when the test tears down, we'll |
| 160 // verify that nothing has been called, then set our expectation for the call |
| 161 // made during tear down. |
| 162 Mock::VerifyAndClear(&callbacks_); |
| 163 EXPECT_CALL(callbacks_, OnInitialize(false)); |
| 148 } | 164 } |
| 149 | 165 |
| 150 TEST_F(PipelineImplTest, RequiredFilterMissing) { | 166 TEST_F(PipelineImplTest, RequiredFilterMissing) { |
| 151 mocks_->set_creation_successful(false); | 167 mocks_->set_creation_successful(false); |
| 152 | 168 |
| 153 ASSERT_TRUE(InitializeAndWait()); | 169 InitializePipeline(false); |
| 154 EXPECT_FALSE(initialize_result_); | |
| 155 EXPECT_FALSE(pipeline_.IsInitialized()); | 170 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 156 EXPECT_EQ(media::PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | 171 EXPECT_EQ(PIPELINE_ERROR_REQUIRED_FILTER_MISSING, |
| 157 pipeline_.GetError()); | 172 pipeline_.GetError()); |
| 158 } | 173 } |
| 159 | 174 |
| 160 TEST_F(PipelineImplTest, URLNotFound) { | 175 TEST_F(PipelineImplTest, URLNotFound) { |
| 161 EXPECT_CALL(*mocks_->data_source(), Initialize("")) | 176 EXPECT_CALL(*mocks_->data_source(), Initialize("")) |
| 162 .WillOnce(DoAll(Error(mocks_->data_source(), | 177 .WillOnce(DoAll(Error(mocks_->data_source(), |
| 163 PIPELINE_ERROR_URL_NOT_FOUND), | 178 PIPELINE_ERROR_URL_NOT_FOUND), |
| 164 Return(false))); | 179 Return(false))); |
| 165 EXPECT_CALL(*mocks_->data_source(), Stop()); | 180 EXPECT_CALL(*mocks_->data_source(), Stop()); |
| 166 | 181 |
| 167 ASSERT_TRUE(InitializeAndWait()); | 182 InitializePipeline(false); |
| 168 EXPECT_FALSE(initialize_result_); | |
| 169 EXPECT_FALSE(pipeline_.IsInitialized()); | 183 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 170 EXPECT_EQ(media::PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); | 184 EXPECT_EQ(PIPELINE_ERROR_URL_NOT_FOUND, pipeline_.GetError()); |
| 171 } | 185 } |
| 172 | 186 |
| 173 TEST_F(PipelineImplTest, NoStreams) { | 187 TEST_F(PipelineImplTest, NoStreams) { |
| 174 MockDemuxerStreamVector streams; | 188 MockDemuxerStreamVector streams; |
| 175 InitializeDataSource(); | 189 InitializeDataSource(); |
| 176 InitializeDemuxer(&streams); | 190 InitializeDemuxer(&streams); |
| 177 | 191 |
| 178 ASSERT_TRUE(InitializeAndWait()); | 192 InitializePipeline(false); |
| 179 EXPECT_FALSE(initialize_result_); | |
| 180 EXPECT_FALSE(pipeline_.IsInitialized()); | 193 EXPECT_FALSE(pipeline_.IsInitialized()); |
| 181 EXPECT_EQ(media::PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_.GetError()); | 194 EXPECT_EQ(PIPELINE_ERROR_COULD_NOT_RENDER, pipeline_.GetError()); |
| 182 } | 195 } |
| 183 | 196 |
| 184 TEST_F(PipelineImplTest, AudioStream) { | 197 TEST_F(PipelineImplTest, AudioStream) { |
| 185 scoped_refptr<StrictMock<MockDemuxerStream> > stream = | 198 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 186 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 199 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 187 MockDemuxerStreamVector streams; | 200 MockDemuxerStreamVector streams; |
| 188 streams.push_back(stream); | 201 streams.push_back(stream); |
| 189 | 202 |
| 190 InitializeDataSource(); | 203 InitializeDataSource(); |
| 191 InitializeDemuxer(&streams); | 204 InitializeDemuxer(&streams); |
| 192 InitializeAudioDecoder(stream); | 205 InitializeAudioDecoder(stream); |
| 193 InitializeAudioRenderer(); | 206 InitializeAudioRenderer(); |
| 194 | 207 |
| 195 ASSERT_TRUE(InitializeAndWait()); | 208 InitializePipeline(true); |
| 196 EXPECT_TRUE(initialize_result_); | |
| 197 EXPECT_TRUE(pipeline_.IsInitialized()); | 209 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 198 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 210 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); |
| 199 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 211 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 200 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 212 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 201 } | 213 } |
| 202 | 214 |
| 203 TEST_F(PipelineImplTest, VideoStream) { | 215 TEST_F(PipelineImplTest, VideoStream) { |
| 204 scoped_refptr<StrictMock<MockDemuxerStream> > stream = | 216 scoped_refptr<StrictMock<MockDemuxerStream> > stream = |
| 205 new StrictMock<MockDemuxerStream>("video/x-foo"); | 217 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 206 MockDemuxerStreamVector streams; | 218 MockDemuxerStreamVector streams; |
| 207 streams.push_back(stream); | 219 streams.push_back(stream); |
| 208 | 220 |
| 209 InitializeDataSource(); | 221 InitializeDataSource(); |
| 210 InitializeDemuxer(&streams); | 222 InitializeDemuxer(&streams); |
| 211 InitializeVideoDecoder(stream); | 223 InitializeVideoDecoder(stream); |
| 212 InitializeVideoRenderer(); | 224 InitializeVideoRenderer(); |
| 213 | 225 |
| 214 ASSERT_TRUE(InitializeAndWait()); | 226 InitializePipeline(true); |
| 215 EXPECT_TRUE(initialize_result_); | |
| 216 EXPECT_TRUE(pipeline_.IsInitialized()); | 227 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 217 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 228 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); |
| 218 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 229 EXPECT_FALSE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 219 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 230 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 220 } | 231 } |
| 221 | 232 |
| 222 TEST_F(PipelineImplTest, AudioVideoStream) { | 233 TEST_F(PipelineImplTest, AudioVideoStream) { |
| 223 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 234 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 224 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 235 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 225 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = | 236 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 226 new StrictMock<MockDemuxerStream>("video/x-foo"); | 237 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 227 MockDemuxerStreamVector streams; | 238 MockDemuxerStreamVector streams; |
| 228 streams.push_back(audio_stream); | 239 streams.push_back(audio_stream); |
| 229 streams.push_back(video_stream); | 240 streams.push_back(video_stream); |
| 230 | 241 |
| 231 InitializeDataSource(); | 242 InitializeDataSource(); |
| 232 InitializeDemuxer(&streams); | 243 InitializeDemuxer(&streams); |
| 233 InitializeAudioDecoder(audio_stream); | 244 InitializeAudioDecoder(audio_stream); |
| 234 InitializeAudioRenderer(); | 245 InitializeAudioRenderer(); |
| 235 InitializeVideoDecoder(video_stream); | 246 InitializeVideoDecoder(video_stream); |
| 236 InitializeVideoRenderer(); | 247 InitializeVideoRenderer(); |
| 237 | 248 |
| 238 ASSERT_TRUE(InitializeAndWait()); | 249 InitializePipeline(true); |
| 239 EXPECT_TRUE(initialize_result_); | |
| 240 EXPECT_TRUE(pipeline_.IsInitialized()); | 250 EXPECT_TRUE(pipeline_.IsInitialized()); |
| 241 EXPECT_EQ(media::PIPELINE_OK, pipeline_.GetError()); | 251 EXPECT_EQ(PIPELINE_OK, pipeline_.GetError()); |
| 242 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); | 252 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeAudio)); |
| 243 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); | 253 EXPECT_TRUE(pipeline_.IsRendered(media::mime_type::kMajorTypeVideo)); |
| 244 } | 254 } |
| 245 | 255 |
| 246 TEST_F(PipelineImplTest, Seek) { | 256 TEST_F(PipelineImplTest, Seek) { |
| 247 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 257 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 248 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 258 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 249 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = | 259 scoped_refptr<StrictMock<MockDemuxerStream> > video_stream = |
| 250 new StrictMock<MockDemuxerStream>("video/x-foo"); | 260 new StrictMock<MockDemuxerStream>("video/x-foo"); |
| 251 MockDemuxerStreamVector streams; | 261 MockDemuxerStreamVector streams; |
| 252 streams.push_back(audio_stream); | 262 streams.push_back(audio_stream); |
| 253 streams.push_back(video_stream); | 263 streams.push_back(video_stream); |
| 254 | 264 |
| 255 InitializeDataSource(); | 265 InitializeDataSource(); |
| 256 InitializeDemuxer(&streams); | 266 InitializeDemuxer(&streams); |
| 257 InitializeAudioDecoder(audio_stream); | 267 InitializeAudioDecoder(audio_stream); |
| 258 InitializeAudioRenderer(); | 268 InitializeAudioRenderer(); |
| 259 InitializeVideoDecoder(video_stream); | 269 InitializeVideoDecoder(video_stream); |
| 260 InitializeVideoRenderer(); | 270 InitializeVideoRenderer(); |
| 261 | 271 |
| 262 // Every filter should receive a call to Seek(). | 272 // Every filter should receive a call to Seek(). |
| 263 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); | 273 base::TimeDelta expected = base::TimeDelta::FromSeconds(2000); |
| 264 EXPECT_CALL(*mocks_->data_source(), Seek(expected)); | 274 EXPECT_CALL(*mocks_->data_source(), Seek(expected)); |
| 265 EXPECT_CALL(*mocks_->demuxer(), Seek(expected)); | 275 EXPECT_CALL(*mocks_->demuxer(), Seek(expected)); |
| 266 EXPECT_CALL(*mocks_->audio_decoder(), Seek(expected)); | 276 EXPECT_CALL(*mocks_->audio_decoder(), Seek(expected)); |
| 267 EXPECT_CALL(*mocks_->audio_renderer(), Seek(expected)); | 277 EXPECT_CALL(*mocks_->audio_renderer(), Seek(expected)); |
| 268 EXPECT_CALL(*mocks_->video_decoder(), Seek(expected)); | 278 EXPECT_CALL(*mocks_->video_decoder(), Seek(expected)); |
| 269 EXPECT_CALL(*mocks_->video_renderer(), Seek(expected)); | 279 EXPECT_CALL(*mocks_->video_renderer(), Seek(expected)); |
| 270 | 280 |
| 281 // We expect a successful seek callback. |
| 282 EXPECT_CALL(callbacks_, OnSeek(true)); |
| 283 |
| 271 // Initialize then seek! | 284 // Initialize then seek! |
| 272 ASSERT_TRUE(InitializeAndWait()); | 285 InitializePipeline(true); |
| 273 EXPECT_TRUE(SeekAndWait(expected)); | 286 pipeline_.Seek(expected, |
| 274 EXPECT_TRUE(seek_result_); | 287 NewCallback(reinterpret_cast<CallbackHelper*>(&callbacks_), |
| 288 &CallbackHelper::OnSeek)); |
| 289 message_loop_.RunAllPending(); |
| 275 } | 290 } |
| 276 | 291 |
| 277 TEST_F(PipelineImplTest, SetVolume) { | 292 TEST_F(PipelineImplTest, SetVolume) { |
| 278 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = | 293 scoped_refptr<StrictMock<MockDemuxerStream> > audio_stream = |
| 279 new StrictMock<MockDemuxerStream>("audio/x-foo"); | 294 new StrictMock<MockDemuxerStream>("audio/x-foo"); |
| 280 MockDemuxerStreamVector streams; | 295 MockDemuxerStreamVector streams; |
| 281 streams.push_back(audio_stream); | 296 streams.push_back(audio_stream); |
| 282 | 297 |
| 283 InitializeDataSource(); | 298 InitializeDataSource(); |
| 284 InitializeDemuxer(&streams); | 299 InitializeDemuxer(&streams); |
| 285 InitializeAudioDecoder(audio_stream); | 300 InitializeAudioDecoder(audio_stream); |
| 286 InitializeAudioRenderer(); | 301 InitializeAudioRenderer(); |
| 287 | 302 |
| 288 // The audio renderer should receive a call to SetVolume(). | 303 // The audio renderer should receive a call to SetVolume(). |
| 289 float expected = 0.5f; | 304 float expected = 0.5f; |
| 290 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); | 305 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(expected)); |
| 291 | 306 |
| 292 // Initialize then set volume! | 307 // Initialize then set volume! |
| 293 ASSERT_TRUE(InitializeAndWait()); | 308 InitializePipeline(true); |
| 294 pipeline_.SetVolume(expected); | 309 pipeline_.SetVolume(expected); |
| 295 } | 310 } |
| 296 | 311 |
| 297 } // namespace media | 312 } // namespace media |
| 298 | |
| OLD | NEW |