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

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

Issue 11198017: Add DecryptingAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/decrypting_audio_decoder_unittest.cc ('k') | media/media.gyp » ('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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 29 matching lines...) Expand all
40 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size)); 40 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size));
41 buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig( 41 buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig(
42 std::string(reinterpret_cast<const char*>(kFakeKeyId), 42 std::string(reinterpret_cast<const char*>(kFakeKeyId),
43 arraysize(kFakeKeyId)), 43 arraysize(kFakeKeyId)),
44 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)), 44 std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)),
45 0, 45 0,
46 std::vector<SubsampleEntry>()))); 46 std::vector<SubsampleEntry>())));
47 return buffer; 47 return buffer;
48 } 48 }
49 49
50 // Use anonymous namespace here to prevent the actions to be defined multiple
51 // times across multiple test files. Sadly we can't use static for them.
52 namespace {
53
50 ACTION_P(ReturnBuffer, buffer) { 54 ACTION_P(ReturnBuffer, buffer) {
51 arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer); 55 arg0.Run(buffer ? DemuxerStream::kOk : DemuxerStream::kAborted, buffer);
52 } 56 }
53 57
54 ACTION(ReturnConfigChanged) { 58 ACTION(ReturnConfigChanged) {
55 arg0.Run(DemuxerStream::kConfigChanged, scoped_refptr<DecoderBuffer>(NULL)); 59 arg0.Run(DemuxerStream::kConfigChanged, scoped_refptr<DecoderBuffer>(NULL));
56 } 60 }
57 61
58 ACTION_P(RunCallback0, param) { 62 ACTION_P(RunCallback0, param) {
59 if (!arg0.is_null()) 63 if (!arg0.is_null())
60 arg0.Run(param); 64 arg0.Run(param);
61 } 65 }
62 66
63 ACTION_P(RunCallback1, param) { 67 ACTION_P(RunCallback1, param) {
64 arg1.Run(param); 68 arg1.Run(param);
65 } 69 }
66 70
67 ACTION_P2(RunCallback2, param1, param2) { 71 ACTION_P2(RunCallback2, param1, param2) {
68 arg1.Run(param1, param2); 72 arg1.Run(param1, param2);
69 } 73 }
70 74
71 ACTION_P2(ResetAndRunCallback, callback, param) { 75 ACTION_P2(ResetAndRunCallback, callback, param) {
72 base::ResetAndReturn(callback).Run(param); 76 base::ResetAndReturn(callback).Run(param);
73 } 77 }
74 78
75 MATCHER(IsNullCallback, "") { 79 MATCHER(IsNullCallback, "") {
76 return (arg.is_null()); 80 return (arg.is_null());
77 } 81 }
78 82
83 } // namespace
84
79 class DecryptingVideoDecoderTest : public testing::Test { 85 class DecryptingVideoDecoderTest : public testing::Test {
80 public: 86 public:
81 DecryptingVideoDecoderTest() 87 DecryptingVideoDecoderTest()
82 : decoder_(new StrictMock<DecryptingVideoDecoder>( 88 : decoder_(new StrictMock<DecryptingVideoDecoder>(
83 base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >, 89 base::Bind(&Identity<scoped_refptr<base::MessageLoopProxy> >,
84 message_loop_.message_loop_proxy()), 90 message_loop_.message_loop_proxy()),
85 base::Bind( 91 base::Bind(
86 &DecryptingVideoDecoderTest::RequestDecryptorNotification, 92 &DecryptingVideoDecoderTest::RequestDecryptorNotification,
87 base::Unretained(this)))), 93 base::Unretained(this)))),
88 decryptor_(new StrictMock<MockDecryptor>()), 94 decryptor_(new StrictMock<MockDecryptor>()),
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 598
593 EXPECT_CALL(*demuxer_, Read(_)) 599 EXPECT_CALL(*demuxer_, Read(_))
594 .WillOnce(ReturnConfigChanged()); 600 .WillOnce(ReturnConfigChanged());
595 601
596 // TODO(xhwang): Update this test when kConfigChanged is supported in 602 // TODO(xhwang): Update this test when kConfigChanged is supported in
597 // DecryptingVideoDecoder. 603 // DecryptingVideoDecoder.
598 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_); 604 ReadAndExpectFrameReadyWith(VideoDecoder::kDecodeError, null_video_frame_);
599 } 605 }
600 606
601 } // namespace media 607 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decrypting_audio_decoder_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698