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

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

Issue 2782004: Added checks to GetBufferedTime() to cap at the media's duration (Closed)
Patch Set: Fixed nits from code review Created 10 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
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/callback.h" 7 #include "base/callback.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/waitable_event.h" 9 #include "base/waitable_event.h"
10 #include "media/base/pipeline_impl.h" 10 #include "media/base/pipeline_impl.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 EXPECT_TRUE(pipeline_->IsInitialized()); 495 EXPECT_TRUE(pipeline_->IsInitialized());
496 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError()); 496 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError());
497 EXPECT_EQ(kDuration.ToInternalValue(), 497 EXPECT_EQ(kDuration.ToInternalValue(),
498 pipeline_->GetMediaDuration().ToInternalValue()); 498 pipeline_->GetMediaDuration().ToInternalValue());
499 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes()); 499 EXPECT_EQ(kTotalBytes, pipeline_->GetTotalBytes());
500 EXPECT_EQ(kBufferedBytes, pipeline_->GetBufferedBytes()); 500 EXPECT_EQ(kBufferedBytes, pipeline_->GetBufferedBytes());
501 EXPECT_EQ(0, 501 EXPECT_EQ(0,
502 pipeline_->GetBufferedTime().ToInternalValue()); 502 pipeline_->GetBufferedTime().ToInternalValue());
503 } 503 }
504 504
505 TEST_F(PipelineImplTest, GetBufferedTime) {
506 CreateVideoStream();
507 MockDemuxerStreamVector streams;
508 streams.push_back(video_stream());
509
510 InitializeDataSource();
511 const base::TimeDelta kDuration = base::TimeDelta::FromSeconds(100);
512 InitializeDemuxer(&streams, kDuration);
513 InitializeVideoDecoder(video_stream());
514 InitializeVideoRenderer();
515
516 InitializePipeline();
517 EXPECT_TRUE(pipeline_->IsInitialized());
518 EXPECT_EQ(PIPELINE_OK, pipeline_->GetError());
519
520 // If media is loaded, we should return duration of media.
521 pipeline_->SetLoaded(true);
522 EXPECT_EQ(kDuration.ToInternalValue(),
523 pipeline_->GetBufferedTime().ToInternalValue());
524 pipeline_->SetLoaded(false);
525
526 // Buffered time is 0 if no bytes are buffered or read.
527 pipeline_->SetBufferedBytes(0);
528 EXPECT_EQ(0, pipeline_->GetBufferedTime().ToInternalValue());
529 pipeline_->SetBufferedBytes(kBufferedBytes);
530
531 pipeline_->SetCurrentReadPosition(0);
532 EXPECT_EQ(0, pipeline_->GetBufferedTime().ToInternalValue());
533
534 // We should return buffered_time_ if it is set and valid.
535 const base::TimeDelta buffered = base::TimeDelta::FromSeconds(10);
536 pipeline_->SetBufferedTime(buffered);
537 EXPECT_EQ(buffered.ToInternalValue(),
538 pipeline_->GetBufferedTime().ToInternalValue());
539 }
540
505 TEST_F(PipelineImplTest, DisableAudioRenderer) { 541 TEST_F(PipelineImplTest, DisableAudioRenderer) {
506 CreateAudioStream(); 542 CreateAudioStream();
507 CreateVideoStream(); 543 CreateVideoStream();
508 MockDemuxerStreamVector streams; 544 MockDemuxerStreamVector streams;
509 streams.push_back(audio_stream()); 545 streams.push_back(audio_stream());
510 streams.push_back(video_stream()); 546 streams.push_back(video_stream());
511 547
512 InitializeDataSource(); 548 InitializeDataSource();
513 InitializeDemuxer(&streams, base::TimeDelta()); 549 InitializeDemuxer(&streams, base::TimeDelta());
514 InitializeAudioDecoder(audio_stream()); 550 InitializeAudioDecoder(audio_stream());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 613
578 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded()) 614 EXPECT_CALL(*mocks_->audio_renderer(), HasEnded())
579 .WillOnce(Return(true)); 615 .WillOnce(Return(true));
580 EXPECT_CALL(*mocks_->video_renderer(), HasEnded()) 616 EXPECT_CALL(*mocks_->video_renderer(), HasEnded())
581 .WillOnce(Return(true)); 617 .WillOnce(Return(true));
582 EXPECT_CALL(callbacks_, OnEnded()); 618 EXPECT_CALL(callbacks_, OnEnded());
583 host->NotifyEnded(); 619 host->NotifyEnded();
584 } 620 }
585 621
586 } // namespace media 622 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698