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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "media/base/audio_decoder_config.h" | 6 #include "media/base/audio_decoder_config.h" |
7 #include "media/base/decoder_buffer.h" | 7 #include "media/base/decoder_buffer.h" |
8 #include "media/base/mock_callback.h" | 8 #include "media/base/mock_callback.h" |
9 #include "media/base/mock_demuxer_host.h" | 9 #include "media/base/mock_demuxer_host.h" |
10 #include "media/base/test_data_util.h" | 10 #include "media/base/test_data_util.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 class MockChunkDemuxerClient : public ChunkDemuxerClient { | 79 class MockChunkDemuxerClient : public ChunkDemuxerClient { |
80 public: | 80 public: |
81 MockChunkDemuxerClient() {} | 81 MockChunkDemuxerClient() {} |
82 virtual ~MockChunkDemuxerClient() {} | 82 virtual ~MockChunkDemuxerClient() {} |
83 | 83 |
84 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); | 84 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); |
85 MOCK_METHOD0(DemuxerClosed, void()); | 85 MOCK_METHOD0(DemuxerClosed, void()); |
86 // TODO(xhwang): This is a workaround of the issue that move-only parameters | 86 // TODO(xhwang): This is a workaround of the issue that move-only parameters |
87 // are not supported in mocked methods. Remove this when the issue is fixed. | 87 // are not supported in mocked methods. Remove this when the issue is fixed |
88 // See http://code.google.com/p/googletest/issues/detail?id=395 | 88 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use |
89 MOCK_METHOD2(KeyNeededMock, void(const uint8* init_data, int init_data_size)); | 89 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). |
90 void KeyNeeded(scoped_array<uint8> init_data, int init_data_size) { | 90 MOCK_METHOD2(NeedKeyMock, void(const uint8* init_data, int init_data_size)); |
91 KeyNeededMock(init_data.get(), init_data_size); | 91 void DemuxerNeedKey(scoped_array<uint8> init_data, int init_data_size) { |
| 92 NeedKeyMock(init_data.get(), init_data_size); |
92 } | 93 } |
93 | 94 |
94 private: | 95 private: |
95 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); | 96 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); |
96 }; | 97 }; |
97 | 98 |
98 class ChunkDemuxerTest : public testing::Test { | 99 class ChunkDemuxerTest : public testing::Test { |
99 protected: | 100 protected: |
100 enum CodecsIndex { | 101 enum CodecsIndex { |
101 AUDIO, | 102 AUDIO, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 bool has_video = (i & 0x2) != 0; | 432 bool has_video = (i & 0x2) != 0; |
432 bool video_content_encoded = (i & 0x4) != 0; | 433 bool video_content_encoded = (i & 0x4) != 0; |
433 | 434 |
434 // No test on invalid combination. | 435 // No test on invalid combination. |
435 if (!has_video && video_content_encoded) | 436 if (!has_video && video_content_encoded) |
436 continue; | 437 continue; |
437 | 438 |
438 client_.reset(new MockChunkDemuxerClient()); | 439 client_.reset(new MockChunkDemuxerClient()); |
439 demuxer_ = new ChunkDemuxer(client_.get()); | 440 demuxer_ = new ChunkDemuxer(client_.get()); |
440 if (has_video && video_content_encoded) | 441 if (has_video && video_content_encoded) |
441 EXPECT_CALL(*client_, KeyNeededMock(NotNull(), 16)); | 442 EXPECT_CALL(*client_, NeedKeyMock(NotNull(), 16)); |
442 | 443 |
443 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); | 444 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); |
444 | 445 |
445 scoped_refptr<DemuxerStream> audio_stream = | 446 scoped_refptr<DemuxerStream> audio_stream = |
446 demuxer_->GetStream(DemuxerStream::AUDIO); | 447 demuxer_->GetStream(DemuxerStream::AUDIO); |
447 if (has_audio) { | 448 if (has_audio) { |
448 ASSERT_TRUE(audio_stream); | 449 ASSERT_TRUE(audio_stream); |
449 | 450 |
450 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); | 451 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); |
451 EXPECT_EQ(kCodecVorbis, config.codec()); | 452 EXPECT_EQ(kCodecVorbis, config.codec()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); | 738 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); |
738 | 739 |
739 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); | 740 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); |
740 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK); | 741 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK); |
741 } | 742 } |
742 | 743 |
743 // Helper class to reduce duplicate code when testing end of stream | 744 // Helper class to reduce duplicate code when testing end of stream |
744 // Read() behavior. | 745 // Read() behavior. |
745 class EndOfStreamHelper { | 746 class EndOfStreamHelper { |
746 public: | 747 public: |
747 EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer) | 748 explicit EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer) |
748 : demuxer_(demuxer), | 749 : demuxer_(demuxer), |
749 audio_read_done_(false), | 750 audio_read_done_(false), |
750 video_read_done_(false) { | 751 video_read_done_(false) { |
751 } | 752 } |
752 | 753 |
753 // Request a read on the audio and video streams. | 754 // Request a read on the audio and video streams. |
754 void RequestReads() { | 755 void RequestReads() { |
755 EXPECT_FALSE(audio_read_done_); | 756 EXPECT_FALSE(audio_read_done_); |
756 EXPECT_FALSE(video_read_done_); | 757 EXPECT_FALSE(video_read_done_); |
757 | 758 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 | 1091 |
1091 std::vector<std::string> codecs(1); | 1092 std::vector<std::string> codecs(1); |
1092 codecs[0] = "vp8"; | 1093 codecs[0] = "vp8"; |
1093 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), | 1094 ASSERT_EQ(demuxer_->AddId(kSourceId, "video/webm", codecs), |
1094 ChunkDemuxer::kOk); | 1095 ChunkDemuxer::kOk); |
1095 | 1096 |
1096 ASSERT_TRUE(AppendInfoTracks(true, true, false)); | 1097 ASSERT_TRUE(AppendInfoTracks(true, true, false)); |
1097 } | 1098 } |
1098 | 1099 |
1099 } // namespace media | 1100 } // namespace media |
OLD | NEW |