Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_util.h" | 10 #include "base/file_util.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CreateDemuxer(const std::string& name) { | 72 void CreateDemuxer(const std::string& name) { |
| 73 CHECK(!demuxer_); | 73 CHECK(!demuxer_); |
| 74 | 74 |
| 75 EXPECT_CALL(host_, SetTotalBytes(_)).Times(AnyNumber()); | 75 EXPECT_CALL(host_, SetTotalBytes(_)).Times(AnyNumber()); |
| 76 EXPECT_CALL(host_, AddBufferedByteRange(_, _)).Times(AnyNumber()); | 76 EXPECT_CALL(host_, AddBufferedByteRange(_, _)).Times(AnyNumber()); |
| 77 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); | 77 EXPECT_CALL(host_, AddBufferedTimeRange(_, _)).Times(AnyNumber()); |
| 78 | 78 |
| 79 CreateDataSource(name); | 79 CreateDataSource(name); |
| 80 | |
| 81 media::FFmpegNeedKeyCB need_key_cb = | |
| 82 base::Bind(&FFmpegDemuxerTest::NeedKeyCB, base::Unretained(this)); | |
| 80 demuxer_ = new FFmpegDemuxer(message_loop_.message_loop_proxy(), | 83 demuxer_ = new FFmpegDemuxer(message_loop_.message_loop_proxy(), |
| 81 data_source_); | 84 data_source_, |
| 85 need_key_cb); | |
|
xhwang
2013/03/12 17:28:57
Can we actually add a test with an encrypted file
fgalligan1
2013/03/13 17:58:09
Added a test. Please take a look.
| |
| 82 } | 86 } |
| 83 | 87 |
| 84 MOCK_METHOD1(CheckPoint, void(int v)); | 88 MOCK_METHOD1(CheckPoint, void(int v)); |
| 85 | 89 |
| 86 void InitializeDemuxer() { | 90 void InitializeDemuxer() { |
| 87 EXPECT_CALL(host_, SetDuration(_)); | 91 EXPECT_CALL(host_, SetDuration(_)); |
| 88 WaitableMessageLoopEvent event; | 92 WaitableMessageLoopEvent event; |
| 89 demuxer_->Initialize(&host_, event.GetPipelineStatusCB()); | 93 demuxer_->Initialize(&host_, event.GetPipelineStatusCB()); |
| 90 event.RunAndWaitForStatus(PIPELINE_OK); | 94 event.RunAndWaitForStatus(PIPELINE_OK); |
| 91 } | 95 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 170 |
| 167 file_path = file_path.Append(FILE_PATH_LITERAL("media")) | 171 file_path = file_path.Append(FILE_PATH_LITERAL("media")) |
| 168 .Append(FILE_PATH_LITERAL("test")) | 172 .Append(FILE_PATH_LITERAL("test")) |
| 169 .Append(FILE_PATH_LITERAL("data")) | 173 .Append(FILE_PATH_LITERAL("data")) |
| 170 .AppendASCII(name); | 174 .AppendASCII(name); |
| 171 | 175 |
| 172 data_source_ = new FileDataSource(); | 176 data_source_ = new FileDataSource(); |
| 173 EXPECT_TRUE(data_source_->Initialize(file_path)); | 177 EXPECT_TRUE(data_source_->Initialize(file_path)); |
| 174 } | 178 } |
| 175 | 179 |
| 180 void NeedKeyCB(const std::string& type, | |
| 181 scoped_array<uint8> init_data, int init_data_size) { | |
| 182 } | |
| 183 | |
| 176 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerTest); | 184 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxerTest); |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { | 187 TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) { |
| 180 // Simulate avformat_open_input() failing. | 188 // Simulate avformat_open_input() failing. |
| 181 CreateDemuxer("ten_byte_file"); | 189 CreateDemuxer("ten_byte_file"); |
| 182 WaitableMessageLoopEvent event; | 190 WaitableMessageLoopEvent event; |
| 183 demuxer_->Initialize(&host_, event.GetPipelineStatusCB()); | 191 demuxer_->Initialize(&host_, event.GetPipelineStatusCB()); |
| 184 event.RunAndWaitForStatus(DEMUXER_ERROR_COULD_NOT_OPEN); | 192 event.RunAndWaitForStatus(DEMUXER_ERROR_COULD_NOT_OPEN); |
| 185 } | 193 } |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 TEST_F(FFmpegDemuxerTest, MP4_ZeroStszEntry) { | 629 TEST_F(FFmpegDemuxerTest, MP4_ZeroStszEntry) { |
| 622 #if !defined(USE_PROPRIETARY_CODECS) | 630 #if !defined(USE_PROPRIETARY_CODECS) |
| 623 return; | 631 return; |
| 624 #endif | 632 #endif |
| 625 CreateDemuxer("bear-1280x720-zero-stsz-entry.mp4"); | 633 CreateDemuxer("bear-1280x720-zero-stsz-entry.mp4"); |
| 626 InitializeDemuxer(); | 634 InitializeDemuxer(); |
| 627 ReadUntilEndOfStream(); | 635 ReadUntilEndOfStream(); |
| 628 } | 636 } |
| 629 | 637 |
| 630 } // namespace media | 638 } // namespace media |
| OLD | NEW |