| 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 17 matching lines...) Expand all Loading... |
| 28 public base::RefCountedThreadSafe<TestVideoDecoderCallback> { | 28 public base::RefCountedThreadSafe<TestVideoDecoderCallback> { |
| 29 public: | 29 public: |
| 30 TestVideoDecoderCallback() | 30 TestVideoDecoderCallback() |
| 31 : num_called_(0) {} | 31 : num_called_(0) {} |
| 32 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, | 32 void DecodeComplete(scoped_ptr<I420VideoFrame> frame, |
| 33 const base::TimeTicks render_time) { | 33 const base::TimeTicks render_time) { |
| 34 num_called_++; | 34 num_called_++; |
| 35 } | 35 } |
| 36 | 36 |
| 37 int number_times_called() {return num_called_;} | 37 int number_times_called() {return num_called_;} |
| 38 |
| 39 protected: |
| 40 virtual ~TestVideoDecoderCallback() {} |
| 41 |
| 38 private: | 42 private: |
| 43 friend class base::RefCountedThreadSafe<TestVideoDecoderCallback>; |
| 44 |
| 39 int num_called_; | 45 int num_called_; |
| 40 }; | 46 }; |
| 41 | 47 |
| 42 class VideoDecoderTest : public ::testing::Test { | 48 class VideoDecoderTest : public ::testing::Test { |
| 43 protected: | 49 protected: |
| 44 VideoDecoderTest() { | 50 VideoDecoderTest() { |
| 45 // Configure to vp8. | 51 // Configure to vp8. |
| 46 config_.codec = kVp8; | 52 config_.codec = kVp8; |
| 47 config_.use_external_decoder = false; | 53 config_.use_external_decoder = false; |
| 48 video_decoder_callback_ = new TestVideoDecoderCallback(); | 54 video_decoder_callback_ = new TestVideoDecoderCallback(); |
| 49 } | 55 } |
| 50 | 56 |
| 51 ~VideoDecoderTest() {} | 57 virtual ~VideoDecoderTest() {} |
| 52 virtual void SetUp() { | 58 virtual void SetUp() { |
| 53 task_runner_ = new test::FakeTaskRunner(&testing_clock_); | 59 task_runner_ = new test::FakeTaskRunner(&testing_clock_); |
| 54 cast_thread_ = new CastThread(task_runner_, NULL, NULL, | 60 cast_thread_ = new CastThread(task_runner_, NULL, NULL, |
| 55 NULL, task_runner_); | 61 NULL, task_runner_); |
| 56 decoder_ = new VideoDecoder(cast_thread_, config_); | 62 decoder_ = new VideoDecoder(cast_thread_, config_); |
| 57 } | 63 } |
| 58 | 64 |
| 59 scoped_refptr<VideoDecoder> decoder_; | 65 scoped_refptr<VideoDecoder> decoder_; |
| 60 VideoReceiverConfig config_; | 66 VideoReceiverConfig config_; |
| 61 EncodedVideoFrame encoded_frame_; | 67 EncodedVideoFrame encoded_frame_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 83 video_decoder_callback_.get()); | 89 video_decoder_callback_.get()); |
| 84 encoded_frame_.data.assign(kFrameSize, 0); | 90 encoded_frame_.data.assign(kFrameSize, 0); |
| 85 encoded_frame_.codec = kExternalVideo; | 91 encoded_frame_.codec = kExternalVideo; |
| 86 EXPECT_DEATH(decoder_->DecodeVideoFrame(&encoded_frame_, render_time, | 92 EXPECT_DEATH(decoder_->DecodeVideoFrame(&encoded_frame_, render_time, |
| 87 frame_decoded_callback, base::Bind(ReleaseFrame, &encoded_frame_)), | 93 frame_decoded_callback, base::Bind(ReleaseFrame, &encoded_frame_)), |
| 88 "Invalid codec"); | 94 "Invalid codec"); |
| 89 } | 95 } |
| 90 | 96 |
| 91 } // namespace cast | 97 } // namespace cast |
| 92 } // namespace media | 98 } // namespace media |
| OLD | NEW |