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

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

Issue 10534096: Generalize AesDecryptor to make it more spec compliant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 6 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
« no previous file with comments | « media/filters/chunk_demuxer_client.h ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 bool has_video = (i & 0x2) != 0; 584 bool has_video = (i & 0x2) != 0;
584 bool video_content_encoded = (i & 0x4) != 0; 585 bool video_content_encoded = (i & 0x4) != 0;
585 586
586 // No test on invalid combination. 587 // No test on invalid combination.
587 if (!has_video && video_content_encoded) 588 if (!has_video && video_content_encoded)
588 continue; 589 continue;
589 590
590 client_.reset(new MockChunkDemuxerClient()); 591 client_.reset(new MockChunkDemuxerClient());
591 demuxer_ = new ChunkDemuxer(client_.get()); 592 demuxer_ = new ChunkDemuxer(client_.get());
592 if (has_video && video_content_encoded) 593 if (has_video && video_content_encoded)
593 EXPECT_CALL(*client_, KeyNeededMock(NotNull(), 16)); 594 EXPECT_CALL(*client_, NeedKeyMock(NotNull(), 16));
594 595
595 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); 596 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded));
596 597
597 scoped_refptr<DemuxerStream> audio_stream = 598 scoped_refptr<DemuxerStream> audio_stream =
598 demuxer_->GetStream(DemuxerStream::AUDIO); 599 demuxer_->GetStream(DemuxerStream::AUDIO);
599 if (has_audio) { 600 if (has_audio) {
600 ASSERT_TRUE(audio_stream); 601 ASSERT_TRUE(audio_stream);
601 602
602 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); 603 const AudioDecoderConfig& config = audio_stream->audio_decoder_config();
603 EXPECT_EQ(kCodecVorbis, config.codec()); 604 EXPECT_EQ(kCodecVorbis, config.codec());
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 ASSERT_TRUE(AppendData(cluster->data(), cluster->size())); 890 ASSERT_TRUE(AppendData(cluster->data(), cluster->size()));
890 891
891 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK)); 892 EXPECT_CALL(host_, OnDemuxerError(PIPELINE_ERROR_NETWORK));
892 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK); 893 demuxer_->EndOfStream(PIPELINE_ERROR_NETWORK);
893 } 894 }
894 895
895 // Helper class to reduce duplicate code when testing end of stream 896 // Helper class to reduce duplicate code when testing end of stream
896 // Read() behavior. 897 // Read() behavior.
897 class EndOfStreamHelper { 898 class EndOfStreamHelper {
898 public: 899 public:
899 EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer) 900 explicit EndOfStreamHelper(const scoped_refptr<Demuxer> demuxer)
900 : demuxer_(demuxer), 901 : demuxer_(demuxer),
901 audio_read_done_(false), 902 audio_read_done_(false),
902 video_read_done_(false) { 903 video_read_done_(false) {
903 } 904 }
904 905
905 // Request a read on the audio and video streams. 906 // Request a read on the audio and video streams.
906 void RequestReads() { 907 void RequestReads() {
907 EXPECT_FALSE(audio_read_done_); 908 EXPECT_FALSE(audio_read_done_);
908 EXPECT_FALSE(video_read_done_); 909 EXPECT_FALSE(video_read_done_);
909 910
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 NewExpectedStatusCB(PIPELINE_OK)); 1617 NewExpectedStatusCB(PIPELINE_OK));
1617 1618
1618 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms 1619 // Generate a cluster to fulfill this seek, where audio timecode begins 25ms
1619 // after the video. 1620 // after the video.
1620 scoped_ptr<Cluster> middle_cluster(GenerateCluster(5025, 5000, 8)); 1621 scoped_ptr<Cluster> middle_cluster(GenerateCluster(5025, 5000, 8));
1621 ASSERT_TRUE(AppendData(middle_cluster->data(), middle_cluster->size())); 1622 ASSERT_TRUE(AppendData(middle_cluster->data(), middle_cluster->size()));
1622 GenerateExpectedReads(5025, 5000, 8, audio, video); 1623 GenerateExpectedReads(5025, 5000, 8, audio, video);
1623 } 1624 }
1624 1625
1625 } // namespace media 1626 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer_client.h ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698