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

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 10837118: Dead code elimination: scythe.chrome_functions:segment.path %media% edition, round 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds)); 120 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds));
121 return base::Bind(&FFmpegDemuxerTest::OnReadDone, base::Unretained(this), 121 return base::Bind(&FFmpegDemuxerTest::OnReadDone, base::Unretained(this),
122 location, size, timestampInMicroseconds); 122 location, size, timestampInMicroseconds);
123 } 123 }
124 124
125 // Accessor to demuxer internals. 125 // Accessor to demuxer internals.
126 void set_duration_known(bool duration_known) { 126 void set_duration_known(bool duration_known) {
127 demuxer_->duration_known_ = duration_known; 127 demuxer_->duration_known_ = duration_known;
128 } 128 }
129 129
130 // Creates a data source with the given |file_name|. If |disable_file_size|
131 // then the data source pretends it does not know the file size (e.g. often
132 // when streaming video). Uses this data source to initialize a demuxer, then
133 // returns true if the bitrate is valid, false otherwise.
134 bool VideoHasValidBitrate(
135 const std::string& file_name, bool disable_file_size) {
136 CreateDemuxer(file_name, disable_file_size);
137 InitializeDemuxer();
138 return demuxer_->GetBitrate() > 0;
139 }
140
141 bool IsStreamStopped(DemuxerStream::Type type) { 130 bool IsStreamStopped(DemuxerStream::Type type) {
142 DemuxerStream* stream = demuxer_->GetStream(type); 131 DemuxerStream* stream = demuxer_->GetStream(type);
143 CHECK(stream); 132 CHECK(stream);
144 return static_cast<FFmpegDemuxerStream*>(stream)->stopped_; 133 return static_cast<FFmpegDemuxerStream*>(stream)->stopped_;
145 } 134 }
146 135
147 // Fixture members. 136 // Fixture members.
148 scoped_refptr<FileDataSource> data_source_; 137 scoped_refptr<FileDataSource> data_source_;
149 scoped_refptr<FFmpegDemuxer> demuxer_; 138 scoped_refptr<FFmpegDemuxer> demuxer_;
150 StrictMock<MockDemuxerHost> host_; 139 StrictMock<MockDemuxerHost> host_;
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 EXPECT_EQ(size, position); 562 EXPECT_EQ(size, position);
574 563
575 EXPECT_EQ(0u, demuxer_->Read(32, buffer)); 564 EXPECT_EQ(0u, demuxer_->Read(32, buffer));
576 EXPECT_TRUE(demuxer_->GetPosition(&position)); 565 EXPECT_TRUE(demuxer_->GetPosition(&position));
577 EXPECT_EQ(size, position); 566 EXPECT_EQ(size, position);
578 567
579 demuxer_->Stop(NewExpectedClosure()); 568 demuxer_->Stop(NewExpectedClosure());
580 message_loop_.RunAllPending(); 569 message_loop_.RunAllPending();
581 } 570 }
582 571
583 TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer) {
584 EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", false));
585 }
586
587 TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_KnownSize) {
588 EXPECT_TRUE(VideoHasValidBitrate("bear-320x240.webm", false));
589 }
590
591 TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer_NoFileSize) {
592 EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", true));
593 }
594
595 TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_NoFileSize) {
596 EXPECT_TRUE(VideoHasValidBitrate("bear-320x240.webm", true));
597 }
598
599 TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) { 572 TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) {
600 CreateDemuxer("bear-320x240.webm"); 573 CreateDemuxer("bear-320x240.webm");
601 InitializeDemuxer(); 574 InitializeDemuxer();
602 575
603 InSequence s; 576 InSequence s;
604 577
605 int64 size; 578 int64 size;
606 int64 position; 579 int64 position;
607 EXPECT_TRUE(demuxer_->GetSize(&size)); 580 EXPECT_TRUE(demuxer_->GetSize(&size));
608 EXPECT_TRUE(demuxer_->GetPosition(&position)); 581 EXPECT_TRUE(demuxer_->GetPosition(&position));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) { 690 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) {
718 CreateDemuxer("vorbis_audio_wmv_video.mkv"); 691 CreateDemuxer("vorbis_audio_wmv_video.mkv");
719 InitializeDemuxer(); 692 InitializeDemuxer();
720 693
721 // Ensure the expected streams are present. 694 // Ensure the expected streams are present.
722 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO)); 695 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO));
723 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO)); 696 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO));
724 } 697 }
725 698
726 } // namespace media 699 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698