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