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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 class MockChunkDemuxerClient : public ChunkDemuxerClient { | 85 class MockChunkDemuxerClient : public ChunkDemuxerClient { |
86 public: | 86 public: |
87 MockChunkDemuxerClient() {} | 87 MockChunkDemuxerClient() {} |
88 virtual ~MockChunkDemuxerClient() {} | 88 virtual ~MockChunkDemuxerClient() {} |
89 | 89 |
90 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); | 90 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); |
91 MOCK_METHOD0(DemuxerClosed, void()); | 91 MOCK_METHOD0(DemuxerClosed, void()); |
92 // TODO(xhwang): This is a workaround of the issue that move-only parameters | 92 // TODO(xhwang): This is a workaround of the issue that move-only parameters |
93 // are not supported in mocked methods. Remove this when the issue is fixed. | 93 // are not supported in mocked methods. Remove this when the issue is fixed |
94 // See http://code.google.com/p/googletest/issues/detail?id=395 | 94 // (http://code.google.com/p/googletest/issues/detail?id=395) or when we use |
95 MOCK_METHOD2(KeyNeededMock, void(const uint8* init_data, int init_data_size)); | 95 // std::string instead of scoped_array<uint8> (http://crbug.com/130689). |
96 void KeyNeeded(scoped_array<uint8> init_data, int init_data_size) { | 96 MOCK_METHOD2(NeedKeyMock, void(const uint8* init_data, int init_data_size)); |
97 KeyNeededMock(init_data.get(), init_data_size); | 97 void DemuxerNeedKey(scoped_array<uint8> init_data, int init_data_size) { |
| 98 NeedKeyMock(init_data.get(), init_data_size); |
98 } | 99 } |
99 | 100 |
100 private: | 101 private: |
101 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); | 102 DISALLOW_COPY_AND_ASSIGN(MockChunkDemuxerClient); |
102 }; | 103 }; |
103 | 104 |
104 class ChunkDemuxerTest : public testing::Test { | 105 class ChunkDemuxerTest : public testing::Test { |
105 protected: | 106 protected: |
106 enum CodecsIndex { | 107 enum CodecsIndex { |
107 AUDIO, | 108 AUDIO, |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 bool has_video = (i & 0x2) != 0; | 571 bool has_video = (i & 0x2) != 0; |
571 bool video_content_encoded = (i & 0x4) != 0; | 572 bool video_content_encoded = (i & 0x4) != 0; |
572 | 573 |
573 // No test on invalid combination. | 574 // No test on invalid combination. |
574 if (!has_video && video_content_encoded) | 575 if (!has_video && video_content_encoded) |
575 continue; | 576 continue; |
576 | 577 |
577 client_.reset(new MockChunkDemuxerClient()); | 578 client_.reset(new MockChunkDemuxerClient()); |
578 demuxer_ = new ChunkDemuxer(client_.get()); | 579 demuxer_ = new ChunkDemuxer(client_.get()); |
579 if (has_video && video_content_encoded) | 580 if (has_video && video_content_encoded) |
580 EXPECT_CALL(*client_, KeyNeededMock(NotNull(), 16)); | 581 EXPECT_CALL(*client_, NeedKeyMock(NotNull(), 16)); |
581 | 582 |
582 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); | 583 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); |
583 | 584 |
584 scoped_refptr<DemuxerStream> audio_stream = | 585 scoped_refptr<DemuxerStream> audio_stream = |
585 demuxer_->GetStream(DemuxerStream::AUDIO); | 586 demuxer_->GetStream(DemuxerStream::AUDIO); |
586 if (has_audio) { | 587 if (has_audio) { |
587 ASSERT_TRUE(audio_stream); | 588 ASSERT_TRUE(audio_stream); |
588 | 589 |
589 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); | 590 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); |
590 EXPECT_EQ(kCodecVorbis, config.codec()); | 591 EXPECT_EQ(kCodecVorbis, config.codec()); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); | 877 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); |
877 | 878 |
878 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); | 879 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); |
879 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK); | 880 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK); |
880 } | 881 } |
881 | 882 |
882 // Helper class to reduce duplicate code when testing end of stream | 883 // Helper class to reduce duplicate code when testing end of stream |
883 // Read() behavior. | 884 // Read() behavior. |
884 class EndOfStreamHelper { | 885 class EndOfStreamHelper { |
885 public: | 886 public: |
886 EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer) | 887 explicit EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer) |
887 : demuxer_(demuxer), | 888 : demuxer_(demuxer), |
888 audio_read_done_(false), | 889 audio_read_done_(false), |
889 video_read_done_(false) { | 890 video_read_done_(false) { |
890 } | 891 } |
891 | 892 |
892 // Request a read on the audio and video streams. | 893 // Request a read on the audio and video streams. |
893 void RequestReads() { | 894 void RequestReads() { |
894 EXPECT_FALSE(audio_read_done_); | 895 EXPECT_FALSE(audio_read_done_); |
895 EXPECT_FALSE(video_read_done_); | 896 EXPECT_FALSE(video_read_done_); |
896 | 897 |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 expected.push_back(CreateRange(0, 1, 100)); | 1574 expected.push_back(CreateRange(0, 1, 100)); |
1574 | 1575 |
1575 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); | 1576 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); |
1576 ASSERT_TRUE(AppendData(cluster_v->data(), cluster_v->size())); | 1577 ASSERT_TRUE(AppendData(cluster_v->data(), cluster_v->size())); |
1577 | 1578 |
1578 demuxer_->EndOfStream(PIPELINE_OK); | 1579 demuxer_->EndOfStream(PIPELINE_OK); |
1579 CheckExpectedRanges(expected); | 1580 CheckExpectedRanges(expected); |
1580 } | 1581 } |
1581 | 1582 |
1582 } // namespace media | 1583 } // namespace media |
OLD | NEW |