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/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
9 #include "media/cast/cast_config.h" | 9 #include "media/cast/cast_config.h" |
10 #include "media/cast/cast_defines.h" | 10 #include "media/cast/cast_defines.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>; | 37 friend class base::RefCountedThreadSafe<DecodeTestFrameCallback>; |
38 }; | 38 }; |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 class VideoDecoderTest : public ::testing::Test { | 41 class VideoDecoderTest : public ::testing::Test { |
42 protected: | 42 protected: |
43 VideoDecoderTest() | 43 VideoDecoderTest() |
44 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), | 44 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), |
45 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_, | 45 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_, |
46 task_runner_, task_runner_, task_runner_, task_runner_, | 46 task_runner_, task_runner_, task_runner_, task_runner_, |
47 GetDefaultCastLoggingConfig())), | 47 task_runner_, GetDefaultCastLoggingConfig())), |
48 test_callback_(new DecodeTestFrameCallback()) { | 48 test_callback_(new DecodeTestFrameCallback()) { |
49 // Configure to vp8. | 49 // Configure to vp8. |
50 config_.codec = kVp8; | 50 config_.codec = transport::kVp8; |
51 config_.use_external_decoder = false; | 51 config_.use_external_decoder = false; |
52 decoder_.reset(new VideoDecoder(config_, cast_environment_)); | 52 decoder_.reset(new VideoDecoder(config_, cast_environment_)); |
53 testing_clock_.Advance( | 53 testing_clock_.Advance( |
54 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 54 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
55 } | 55 } |
56 | 56 |
57 virtual ~VideoDecoderTest() {} | 57 virtual ~VideoDecoderTest() {} |
58 | 58 |
59 scoped_ptr<VideoDecoder> decoder_; | 59 scoped_ptr<VideoDecoder> decoder_; |
60 VideoReceiverConfig config_; | 60 VideoReceiverConfig config_; |
61 base::SimpleTestTickClock testing_clock_; | 61 base::SimpleTestTickClock testing_clock_; |
62 scoped_refptr<test::FakeTaskRunner> task_runner_; | 62 scoped_refptr<test::FakeTaskRunner> task_runner_; |
63 scoped_refptr<CastEnvironment> cast_environment_; | 63 scoped_refptr<CastEnvironment> cast_environment_; |
64 scoped_refptr<DecodeTestFrameCallback> test_callback_; | 64 scoped_refptr<DecodeTestFrameCallback> test_callback_; |
65 }; | 65 }; |
66 | 66 |
67 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind. | 67 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind. |
68 TEST_F(VideoDecoderTest, DISABLED_SizeZero) { | 68 TEST_F(VideoDecoderTest, DISABLED_SizeZero) { |
69 EncodedVideoFrame encoded_frame; | 69 transport::EncodedVideoFrame encoded_frame; |
70 base::TimeTicks render_time; | 70 base::TimeTicks render_time; |
71 encoded_frame.codec = kVp8; | 71 encoded_frame.codec = transport::kVp8; |
72 EXPECT_DEATH( | 72 EXPECT_DEATH( |
73 decoder_->DecodeVideoFrame( | 73 decoder_->DecodeVideoFrame( |
74 &encoded_frame, render_time, | 74 &encoded_frame, render_time, |
75 base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_)), | 75 base::Bind(&DecodeTestFrameCallback::DecodeComplete, test_callback_)), |
76 "Empty frame"); | 76 "Empty frame"); |
77 } | 77 } |
78 | 78 |
79 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind. | 79 // TODO(pwestin): EXPECT_DEATH tests can not pass valgrind. |
80 TEST_F(VideoDecoderTest, DISABLED_InvalidCodec) { | 80 TEST_F(VideoDecoderTest, DISABLED_InvalidCodec) { |
81 EncodedVideoFrame encoded_frame; | 81 transport::EncodedVideoFrame encoded_frame; |
82 base::TimeTicks render_time; | 82 base::TimeTicks render_time; |
83 encoded_frame.data.assign(kFrameSize, 0); | 83 encoded_frame.data.assign(kFrameSize, 0); |
84 encoded_frame.codec = kExternalVideo; | 84 encoded_frame.codec = transport::kExternalVideo; |
85 EXPECT_DEATH( | 85 EXPECT_DEATH( |
86 decoder_->DecodeVideoFrame(&encoded_frame, render_time, base::Bind( | 86 decoder_->DecodeVideoFrame(&encoded_frame, render_time, base::Bind( |
87 &DecodeTestFrameCallback::DecodeComplete, test_callback_)), | 87 &DecodeTestFrameCallback::DecodeComplete, test_callback_)), |
88 "Invalid codec"); | 88 "Invalid codec"); |
89 } | 89 } |
90 | 90 |
91 // TODO(pwestin): Test decoding a real frame. | 91 // TODO(pwestin): Test decoding a real frame. |
92 | 92 |
93 } // namespace cast | 93 } // namespace cast |
94 } // namespace media | 94 } // namespace media |
OLD | NEW |