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

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

Issue 10581050: Ensure media's buffered ranges always have a range that includes currentTime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Alternative implementation, introducing DataSourceHost::AddBufferedTimeRange(). 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
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size()); 474 EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size());
475 475
476 EXPECT_FALSE(pipeline_->DidLoadingProgress()); 476 EXPECT_FALSE(pipeline_->DidLoadingProgress());
477 pipeline_->AddBufferedByteRange(0, kTotalBytes / 8); 477 pipeline_->AddBufferedByteRange(0, kTotalBytes / 8);
478 EXPECT_TRUE(pipeline_->DidLoadingProgress()); 478 EXPECT_TRUE(pipeline_->DidLoadingProgress());
479 EXPECT_FALSE(pipeline_->DidLoadingProgress()); 479 EXPECT_FALSE(pipeline_->DidLoadingProgress());
480 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 480 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
481 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); 481 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0));
482 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); 482 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0));
483 pipeline_->AddBufferedTimeRange(base::TimeDelta(), kDuration / 8);
484 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0));
485 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0));
483 486
484 base::TimeDelta kSeekTime = kDuration / 2; 487 base::TimeDelta kSeekTime = kDuration / 2;
485 ExpectSeek(kSeekTime); 488 ExpectSeek(kSeekTime);
486 DoSeek(kSeekTime); 489 DoSeek(kSeekTime);
487 490
488 EXPECT_FALSE(pipeline_->DidLoadingProgress()); 491 EXPECT_FALSE(pipeline_->DidLoadingProgress());
489 pipeline_->AddBufferedByteRange(kTotalBytes / 2, 492 pipeline_->AddBufferedByteRange(kTotalBytes / 2,
490 kTotalBytes / 2 + kTotalBytes / 8); 493 kTotalBytes / 2 + kTotalBytes / 8);
491 EXPECT_TRUE(pipeline_->DidLoadingProgress()); 494 EXPECT_TRUE(pipeline_->DidLoadingProgress());
492 EXPECT_FALSE(pipeline_->DidLoadingProgress()); 495 EXPECT_FALSE(pipeline_->DidLoadingProgress());
493 EXPECT_EQ(2u, pipeline_->GetBufferedTimeRanges().size()); 496 EXPECT_EQ(2u, pipeline_->GetBufferedTimeRanges().size());
494 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0)); 497 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0));
495 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0)); 498 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0));
496 EXPECT_EQ(kDuration / 2, pipeline_->GetBufferedTimeRanges().start(1)); 499 EXPECT_EQ(kDuration / 2, pipeline_->GetBufferedTimeRanges().start(1));
497 EXPECT_EQ(kDuration / 2 + kDuration / 8, 500 EXPECT_EQ(kDuration / 2 + kDuration / 8,
498 pipeline_->GetBufferedTimeRanges().end(1)); 501 pipeline_->GetBufferedTimeRanges().end(1));
502
503 pipeline_->AddBufferedTimeRange(kDuration / 4, 3 * kDuration / 8);
504 EXPECT_EQ(base::TimeDelta(), pipeline_->GetBufferedTimeRanges().start(0));
505 EXPECT_EQ(kDuration / 8, pipeline_->GetBufferedTimeRanges().end(0));
506 EXPECT_EQ(kDuration / 4, pipeline_->GetBufferedTimeRanges().start(1));
507 EXPECT_EQ(3* kDuration / 8, pipeline_->GetBufferedTimeRanges().end(1));
508 EXPECT_EQ(kDuration / 2, pipeline_->GetBufferedTimeRanges().start(2));
509 EXPECT_EQ(kDuration / 2 + kDuration / 8,
510 pipeline_->GetBufferedTimeRanges().end(2));
499 } 511 }
500 512
501 TEST_F(PipelineTest, DisableAudioRenderer) { 513 TEST_F(PipelineTest, DisableAudioRenderer) {
502 CreateAudioStream(); 514 CreateAudioStream();
503 CreateVideoStream(); 515 CreateVideoStream();
504 MockDemuxerStreamVector streams; 516 MockDemuxerStreamVector streams;
505 streams.push_back(audio_stream()); 517 streams.push_back(audio_stream());
506 streams.push_back(video_stream()); 518 streams.push_back(video_stream());
507 519
508 InitializeDemuxer(&streams); 520 InitializeDemuxer(&streams);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); 856 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0));
845 } 857 }
846 858
847 // Test that different-thread, some-delay callback (the expected common case) 859 // Test that different-thread, some-delay callback (the expected common case)
848 // works correctly. 860 // works correctly.
849 TEST(PipelineStatusNotificationTest, DelayedCallback) { 861 TEST(PipelineStatusNotificationTest, DelayedCallback) {
850 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); 862 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20));
851 } 863 }
852 864
853 } // namespace media 865 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | media/base/ranges.h » ('j') | media/filters/chunk_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698