Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: media/base/pipeline_unittest.cc

Issue 10535101: Replace Pipeline::SetNetworkActivity() with BufferedDataSource -> WebMediaPlayerImpl callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/threading/simple_thread.h" 10 #include "base/threading/simple_thread.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // Sets up expectations on the callback and initializes the pipeline. Called 186 // Sets up expectations on the callback and initializes the pipeline. Called
187 // after tests have set expectations any filters they wish to use. 187 // after tests have set expectations any filters they wish to use.
188 void InitializePipeline(PipelineStatus start_status) { 188 void InitializePipeline(PipelineStatus start_status) {
189 EXPECT_CALL(callbacks_, OnStart(start_status)); 189 EXPECT_CALL(callbacks_, OnStart(start_status));
190 190
191 pipeline_->Start( 191 pipeline_->Start(
192 mocks_->Create().Pass(), 192 mocks_->Create().Pass(),
193 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 193 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
194 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 194 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
195 NetworkEventCB(),
196 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); 195 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
197 message_loop_.RunAllPending(); 196 message_loop_.RunAllPending();
198 } 197 }
199 198
200 void CreateAudioStream() { 199 void CreateAudioStream() {
201 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 200 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
202 } 201 }
203 202
204 void CreateVideoStream() { 203 void CreateVideoStream() {
205 video_stream_ = CreateStream(DemuxerStream::VIDEO); 204 video_stream_ = CreateStream(DemuxerStream::VIDEO);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) 297 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
299 .WillOnce(Invoke(&RunClosure)); 298 .WillOnce(Invoke(&RunClosure));
300 299
301 // This test hangs during initialization by never calling 300 // This test hangs during initialization by never calling
302 // InitializationComplete(). StrictMock<> will ensure that the callback is 301 // InitializationComplete(). StrictMock<> will ensure that the callback is
303 // never executed. 302 // never executed.
304 pipeline_->Start( 303 pipeline_->Start(
305 mocks_->Create().Pass(), 304 mocks_->Create().Pass(),
306 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 305 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
307 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 306 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
308 NetworkEventCB(),
309 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); 307 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
310 message_loop_.RunAllPending(); 308 message_loop_.RunAllPending();
311 309
312 EXPECT_FALSE(pipeline_->IsInitialized()); 310 EXPECT_FALSE(pipeline_->IsInitialized());
313 311
314 // Because our callback will get executed when the test tears down, we'll 312 // Because our callback will get executed when the test tears down, we'll
315 // verify that nothing has been called, then set our expectation for the call 313 // verify that nothing has been called, then set our expectation for the call
316 // made during tear down. 314 // made during tear down.
317 Mock::VerifyAndClear(&callbacks_); 315 Mock::VerifyAndClear(&callbacks_);
318 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); 316 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK));
319 } 317 }
320 318
321 TEST_F(PipelineTest, RequiredFilterMissing) { 319 TEST_F(PipelineTest, RequiredFilterMissing) {
322 // Create a filter collection with missing filter. 320 // Create a filter collection with missing filter.
323 scoped_ptr<FilterCollection> collection(mocks_->Create()); 321 scoped_ptr<FilterCollection> collection(mocks_->Create());
324 collection->SetDemuxer(NULL); 322 collection->SetDemuxer(NULL);
325 323
326 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); 324 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING));
327 pipeline_->Start( 325 pipeline_->Start(
328 collection.Pass(), 326 collection.Pass(),
329 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 327 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
330 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), 328 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
331 NetworkEventCB(),
332 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); 329 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)));
333 message_loop_.RunAllPending(); 330 message_loop_.RunAllPending();
334 EXPECT_FALSE(pipeline_->IsInitialized()); 331 EXPECT_FALSE(pipeline_->IsInitialized());
335 } 332 }
336 333
337 TEST_F(PipelineTest, URLNotFound) { 334 TEST_F(PipelineTest, URLNotFound) {
338 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)) 335 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _))
339 .WillOnce(InitializeDemuxerWithError(PIPELINE_ERROR_URL_NOT_FOUND)); 336 .WillOnce(InitializeDemuxerWithError(PIPELINE_ERROR_URL_NOT_FOUND));
340 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) 337 EXPECT_CALL(*mocks_->demuxer(), Stop(_))
341 .WillOnce(Invoke(&RunClosure)); 338 .WillOnce(Invoke(&RunClosure));
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); 844 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0));
848 } 845 }
849 846
850 // Test that different-thread, some-delay callback (the expected common case) 847 // Test that different-thread, some-delay callback (the expected common case)
851 // works correctly. 848 // works correctly.
852 TEST(PipelineStatusNotificationTest, DelayedCallback) { 849 TEST(PipelineStatusNotificationTest, DelayedCallback) {
853 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); 850 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20));
854 } 851 }
855 852
856 } // namespace media 853 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/filters/chunk_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698