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/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "content/renderer/media/rtc_video_decoder.h" | 9 #include "content/renderer/media/rtc_video_decoder.h" |
10 #include "media/base/gmock_callback_support.h" | 10 #include "media/base/gmock_callback_support.h" |
11 #include "media/filters/mock_gpu_video_decoder_factories.h" | 11 #include "media/filters/mock_gpu_video_accelerator_factories.h" |
12 #include "media/video/mock_video_decode_accelerator.h" | 12 #include "media/video/mock_video_decode_accelerator.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using ::testing::_; | 15 using ::testing::_; |
16 using ::testing::Invoke; | 16 using ::testing::Invoke; |
17 using ::testing::Return; | 17 using ::testing::Return; |
18 using ::testing::SaveArg; | 18 using ::testing::SaveArg; |
19 using ::testing::WithArgs; | 19 using ::testing::WithArgs; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 class RTCVideoDecoderTest : public ::testing::Test, | 23 class RTCVideoDecoderTest : public ::testing::Test, |
24 webrtc::DecodedImageCallback { | 24 webrtc::DecodedImageCallback { |
25 public: | 25 public: |
26 RTCVideoDecoderTest() | 26 RTCVideoDecoderTest() |
27 : mock_gpu_factories_(new media::MockGpuVideoDecoderFactories), | 27 : mock_gpu_factories_(new media::MockGpuVideoAcceleratorFactories), |
28 vda_thread_("vda_thread"), | 28 vda_thread_("vda_thread"), |
29 idle_waiter_(false, false) { | 29 idle_waiter_(false, false) { |
30 memset(&codec_, 0, sizeof(codec_)); | 30 memset(&codec_, 0, sizeof(codec_)); |
31 } | 31 } |
32 | 32 |
33 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
34 ASSERT_TRUE(vda_thread_.Start()); | 34 ASSERT_TRUE(vda_thread_.Start()); |
35 vda_loop_proxy_ = vda_thread_.message_loop_proxy(); | 35 vda_loop_proxy_ = vda_thread_.message_loop_proxy(); |
36 mock_vda_ = new media::MockVideoDecodeAccelerator; | 36 mock_vda_ = new media::MockVideoDecodeAccelerator; |
37 EXPECT_CALL(*mock_gpu_factories_, GetMessageLoop()) | 37 EXPECT_CALL(*mock_gpu_factories_, GetMessageLoop()) |
38 .WillRepeatedly(Return(vda_loop_proxy_)); | 38 .WillRepeatedly(Return(vda_loop_proxy_)); |
39 EXPECT_CALL(*mock_gpu_factories_, CreateVideoDecodeAccelerator(_, _)) | 39 EXPECT_CALL(*mock_gpu_factories_, DoCreateVideoDecodeAccelerator(_, _)) |
40 .WillRepeatedly( | 40 .WillRepeatedly( |
41 Return(static_cast<media::VideoDecodeAccelerator*>(NULL))); | 41 Return(static_cast<media::VideoDecodeAccelerator*>(NULL))); |
42 EXPECT_CALL(*mock_gpu_factories_, | 42 EXPECT_CALL(*mock_gpu_factories_, |
43 CreateVideoDecodeAccelerator(media::VP8PROFILE_MAIN, _)) | 43 DoCreateVideoDecodeAccelerator(media::VP8PROFILE_MAIN, _)) |
44 .WillRepeatedly(Return(mock_vda_)); | 44 .WillRepeatedly(Return(mock_vda_)); |
45 EXPECT_CALL(*mock_gpu_factories_, Abort()).WillRepeatedly(Return()); | 45 EXPECT_CALL(*mock_gpu_factories_, Abort()).WillRepeatedly(Return()); |
46 EXPECT_CALL(*mock_gpu_factories_, CreateSharedMemory(_)) | 46 EXPECT_CALL(*mock_gpu_factories_, CreateSharedMemory(_)) |
47 .WillRepeatedly(Return(static_cast<base::SharedMemory*>(NULL))); | 47 .WillRepeatedly(Return(static_cast<base::SharedMemory*>(NULL))); |
48 EXPECT_CALL(*mock_vda_, Destroy()); | 48 EXPECT_CALL(*mock_vda_, Destroy()); |
49 rtc_decoder_ = | 49 rtc_decoder_ = |
50 RTCVideoDecoder::Create(webrtc::kVideoCodecVP8, mock_gpu_factories_); | 50 RTCVideoDecoder::Create(webrtc::kVideoCodecVP8, mock_gpu_factories_); |
51 } | 51 } |
52 | 52 |
53 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() OVERRIDE { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void RunUntilIdle() { | 89 void RunUntilIdle() { |
90 VLOG(2) << "RunUntilIdle"; | 90 VLOG(2) << "RunUntilIdle"; |
91 vda_loop_proxy_->PostTask(FROM_HERE, | 91 vda_loop_proxy_->PostTask(FROM_HERE, |
92 base::Bind(&base::WaitableEvent::Signal, | 92 base::Bind(&base::WaitableEvent::Signal, |
93 base::Unretained(&idle_waiter_))); | 93 base::Unretained(&idle_waiter_))); |
94 idle_waiter_.Wait(); | 94 idle_waiter_.Wait(); |
95 } | 95 } |
96 | 96 |
97 protected: | 97 protected: |
98 scoped_refptr<media::MockGpuVideoDecoderFactories> mock_gpu_factories_; | 98 scoped_refptr<media::MockGpuVideoAcceleratorFactories> mock_gpu_factories_; |
99 media::MockVideoDecodeAccelerator* mock_vda_; | 99 media::MockVideoDecodeAccelerator* mock_vda_; |
100 scoped_ptr<RTCVideoDecoder> rtc_decoder_; | 100 scoped_ptr<RTCVideoDecoder> rtc_decoder_; |
101 webrtc::VideoCodec codec_; | 101 webrtc::VideoCodec codec_; |
102 base::Thread vda_thread_; | 102 base::Thread vda_thread_; |
103 | 103 |
104 private: | 104 private: |
105 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; | 105 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; |
106 | 106 |
107 base::Lock lock_; | 107 base::Lock lock_; |
108 base::WaitableEvent idle_waiter_; | 108 base::WaitableEvent idle_waiter_; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, 0)); | 176 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, 0)); |
177 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, | 177 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, |
178 RTCVideoDecoder::ID_HALF - 2)); | 178 RTCVideoDecoder::ID_HALF - 2)); |
179 EXPECT_TRUE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, | 179 EXPECT_TRUE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, |
180 RTCVideoDecoder::ID_HALF + 2)); | 180 RTCVideoDecoder::ID_HALF + 2)); |
181 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, | 181 EXPECT_FALSE(rtc_decoder_->IsBufferAfterReset(RTCVideoDecoder::ID_LAST, |
182 RTCVideoDecoder::ID_LAST)); | 182 RTCVideoDecoder::ID_LAST)); |
183 } | 183 } |
184 | 184 |
185 } // content | 185 } // content |
OLD | NEW |