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

Unified Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 8294025: Merge 105121 - Numerous fixes to audio/video buffered resource loading. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/874/src/
Patch Set: '' Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/file_data_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer_unittest.cc
===================================================================
--- media/filters/ffmpeg_demuxer_unittest.cc (revision 105891)
+++ media/filters/ffmpeg_demuxer_unittest.cc (working copy)
@@ -60,7 +60,12 @@
demuxer_ = NULL;
}
- scoped_refptr<DataSource> CreateDataSource(const std::string& name) {
+ scoped_refptr<FileDataSource> CreateDataSource(const std::string& name) {
+ return CreateDataSource(name, false);
+ }
+
+ scoped_refptr<FileDataSource> CreateDataSource(const std::string& name,
+ bool disable_file_size) {
FilePath file_path;
EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
@@ -69,7 +74,8 @@
.Append(FILE_PATH_LITERAL("data"))
.AppendASCII(name);
- scoped_refptr<FileDataSource> data_source = new FileDataSource();
+ scoped_refptr<FileDataSource> data_source = new FileDataSource(
+ disable_file_size);
EXPECT_EQ(PIPELINE_OK, data_source->Initialize(file_path.MaybeAsASCII()));
@@ -101,6 +107,18 @@
buffer->GetTimestamp());
}
+ // Creates a data source with the given |file_name|. If |disable_file_size|
+ // then the data source pretends it does not know the file size (e.g. often
+ // when streaming video). Uses this data source to initialize a demuxer, then
+ // returns true if the bitrate is valid, false otherwise.
+ bool VideoHasValidBitrate(
+ const std::string& file_name, bool disable_file_size) {
+ scoped_refptr<FileDataSource> data_source =
+ CreateDataSource(file_name, disable_file_size);
+ InitializeDemuxer(data_source);
+ return demuxer_->GetBitrate() > 0;
+ }
+
// Fixture members.
scoped_refptr<FFmpegDemuxer> demuxer_;
StrictMock<MockFilterHost> host_;
@@ -498,6 +516,22 @@
message_loop_.RunAllPending();
}
+TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer) {
+ EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", false));
+}
+
+TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_KnownSize) {
+ EXPECT_TRUE(VideoHasValidBitrate("bear-320x240.webm", false));
+}
+
+TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer_NoFileSize) {
+ EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", true));
+}
+
+TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_NoFileSize) {
+ EXPECT_FALSE(VideoHasValidBitrate("bear-320x240.webm", true));
+}
+
TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) {
scoped_refptr<DataSource> data_source = CreateDataSource("bear-320x240.webm");
InitializeDemuxer(data_source);
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/file_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698