OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/test/simple_test_tick_clock.h" | 8 #include "base/test/simple_test_tick_clock.h" |
9 #include "media/cast/cast_defines.h" | 9 #include "media/cast/cast_defines.h" |
10 #include "media/cast/cast_thread.h" | 10 #include "media/cast/cast_thread.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 public: | 29 public: |
30 TestVideoDecoderCallback() | 30 TestVideoDecoderCallback() |
31 : num_called_(0) {} | 31 : num_called_(0) {} |
32 // TODO(mikhal): Set and check expectations. | 32 // TODO(mikhal): Set and check expectations. |
33 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, | 33 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, |
34 const base::TimeTicks render_time) { | 34 const base::TimeTicks render_time) { |
35 num_called_++; | 35 num_called_++; |
36 } | 36 } |
37 | 37 |
38 int number_times_called() {return num_called_;} | 38 int number_times_called() {return num_called_;} |
| 39 |
| 40 protected: |
| 41 virtual ~TestVideoDecoderCallback() {} |
| 42 |
39 private: | 43 private: |
| 44 friend class base::RefCountedThreadSafe<TestVideoDecoderCallback>; |
| 45 |
40 int num_called_; | 46 int num_called_; |
41 }; | 47 }; |
42 | 48 |
43 class VideoDecoderTest : public ::testing::Test { | 49 class VideoDecoderTest : public ::testing::Test { |
44 protected: | 50 protected: |
45 VideoDecoderTest() { | 51 VideoDecoderTest() { |
46 // Configure to vp8. | 52 // Configure to vp8. |
47 config_.codec = kVp8; | 53 config_.codec = kVp8; |
48 config_.use_external_decoder = false; | 54 config_.use_external_decoder = false; |
49 video_decoder_callback_ = new TestVideoDecoderCallback(); | 55 video_decoder_callback_ = new TestVideoDecoderCallback(); |
50 } | 56 } |
51 | 57 |
52 ~VideoDecoderTest() {} | 58 virtual ~VideoDecoderTest() {} |
53 virtual void SetUp() { | 59 virtual void SetUp() { |
54 task_runner_ = new test::FakeTaskRunner(&testing_clock_); | 60 task_runner_ = new test::FakeTaskRunner(&testing_clock_); |
55 cast_thread_ = new CastThread(task_runner_, NULL, NULL, | 61 cast_thread_ = new CastThread(task_runner_, NULL, NULL, |
56 NULL, task_runner_); | 62 NULL, task_runner_); |
57 decoder_ = new VideoDecoder(cast_thread_, config_); | 63 decoder_ = new VideoDecoder(cast_thread_, config_); |
58 } | 64 } |
59 | 65 |
60 scoped_refptr<VideoDecoder> decoder_; | 66 scoped_refptr<VideoDecoder> decoder_; |
61 VideoReceiverConfig config_; | 67 VideoReceiverConfig config_; |
62 EncodedVideoFrame encoded_frame_; | 68 EncodedVideoFrame encoded_frame_; |
(...skipping 22 matching lines...) Expand all Loading... |
85 video_decoder_callback_.get()); | 91 video_decoder_callback_.get()); |
86 encoded_frame_.data.assign(kFrameSize, 0); | 92 encoded_frame_.data.assign(kFrameSize, 0); |
87 encoded_frame_.codec = kExternalVideo; | 93 encoded_frame_.codec = kExternalVideo; |
88 EXPECT_DEATH(decoder_->DecodeVideoFrame(&encoded_frame_, render_time, | 94 EXPECT_DEATH(decoder_->DecodeVideoFrame(&encoded_frame_, render_time, |
89 frame_decoded_callback, base::Bind(ReleaseFrame, &encoded_frame_)), | 95 frame_decoded_callback, base::Bind(ReleaseFrame, &encoded_frame_)), |
90 "Invalid codec"); | 96 "Invalid codec"); |
91 } | 97 } |
92 | 98 |
93 } // namespace cast | 99 } // namespace cast |
94 } // namespace media | 100 } // namespace media |
OLD | NEW |