OLD | NEW |
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 // Unit test for VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
14 #include "content/browser/browser_thread_impl.h" | 14 #include "content/browser/browser_thread_impl.h" |
15 #include "content/browser/renderer_host/media/media_stream_provider.h" | 15 #include "content/browser/renderer_host/media/media_stream_provider.h" |
16 #include "content/browser/renderer_host/media/video_capture_manager.h" | 16 #include "content/browser/renderer_host/media/video_capture_manager.h" |
17 #include "content/common/media/media_stream_options.h" | 17 #include "content/common/media/media_stream_options.h" |
| 18 #include "media/base/encoded_bitstream_buffer.h" |
18 #include "media/video/capture/video_capture_device.h" | 19 #include "media/video/capture/video_capture_device.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using ::testing::_; | 23 using ::testing::_; |
23 using ::testing::AnyNumber; | 24 using ::testing::AnyNumber; |
24 using ::testing::InSequence; | 25 using ::testing::InSequence; |
25 using testing::SaveArg; | 26 using testing::SaveArg; |
26 using ::testing::Return; | 27 using ::testing::Return; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 // Listener class used to track progress of VideoCaptureManager test. | 31 // Listener class used to track progress of VideoCaptureManager test. |
31 class MockMediaStreamProviderListener : public MediaStreamProviderListener { | 32 class MockMediaStreamProviderListener : public MediaStreamProviderListener { |
32 public: | 33 public: |
33 MockMediaStreamProviderListener() {} | 34 MockMediaStreamProviderListener() {} |
34 ~MockMediaStreamProviderListener() {} | 35 ~MockMediaStreamProviderListener() {} |
35 | 36 |
36 MOCK_METHOD2(Opened, void(MediaStreamType, int)); | 37 MOCK_METHOD2(Opened, void(MediaStreamType, int)); |
37 MOCK_METHOD2(Closed, void(MediaStreamType, int)); | 38 MOCK_METHOD2(Closed, void(MediaStreamType, int)); |
38 MOCK_METHOD2(DevicesEnumerated, void(MediaStreamType, | 39 MOCK_METHOD2(DevicesEnumerated, void(MediaStreamType, |
39 const StreamDeviceInfoArray&)); | 40 const StreamDeviceInfoArray&)); |
40 MOCK_METHOD3(Error, void(MediaStreamType, int, | 41 MOCK_METHOD3(Error, void(MediaStreamType, int, |
41 MediaStreamProviderError)); | 42 MediaStreamProviderError)); |
42 }; // class MockMediaStreamProviderListener | 43 }; // class MockMediaStreamProviderListener |
43 | 44 |
44 // Needed as an input argument to Start(). | 45 // Needed as an input argument to Start(). |
45 class MockFrameObserver : public media::VideoCaptureDevice::EventHandler { | 46 class MockFrameObserver : public media::VideoCaptureDevice::EventHandler { |
46 public: | 47 public: |
47 virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer() OVERRIDE { | 48 virtual scoped_refptr<media::VideoFrame> ReserveOutputVideoFrame() OVERRIDE { |
| 49 return NULL; |
| 50 } |
| 51 virtual scoped_refptr<media::EncodedBitstreamBuffer> |
| 52 ReserveOutputEncodedBitstreamBuffer() OVERRIDE { |
48 return NULL; | 53 return NULL; |
49 } | 54 } |
50 virtual void OnError() OVERRIDE {} | 55 virtual void OnError() OVERRIDE {} |
51 virtual void OnFrameInfo( | 56 virtual void OnFrameInfo( |
52 const media::VideoCaptureCapability& info) OVERRIDE {} | 57 const media::VideoCaptureCapability& info) OVERRIDE {} |
| 58 virtual void OnEncodedFrameInfo( |
| 59 const media::VideoEncodingParameters& parameters) OVERRIDE {} |
53 virtual void OnIncomingCapturedFrame(const uint8* data, | 60 virtual void OnIncomingCapturedFrame(const uint8* data, |
54 int length, | 61 int length, |
55 base::Time timestamp, | 62 base::Time timestamp, |
56 int rotation, | 63 int rotation, |
57 bool flip_vert, | 64 bool flip_vert, |
58 bool flip_horiz) OVERRIDE {} | 65 bool flip_horiz) OVERRIDE {} |
| 66 virtual void OnBitstreamConfigChanged( |
| 67 const media::RuntimeVideoEncodingParameters& params) OVERRIDE {} |
59 virtual void OnIncomingCapturedVideoFrame( | 68 virtual void OnIncomingCapturedVideoFrame( |
60 const scoped_refptr<media::VideoFrame>& frame, | 69 const scoped_refptr<media::VideoFrame>& frame, |
61 base::Time timestamp) OVERRIDE {} | 70 base::Time timestamp) OVERRIDE {} |
| 71 virtual void OnIncomingCapturedEncodedBitstreamBuffer( |
| 72 const scoped_refptr<media::EncodedBitstreamBuffer>& buffer, |
| 73 size_t data_size, |
| 74 base::Time timestamp) OVERRIDE {} |
62 }; | 75 }; |
63 | 76 |
64 // Test class | 77 // Test class |
65 class VideoCaptureManagerTest : public testing::Test { | 78 class VideoCaptureManagerTest : public testing::Test { |
66 public: | 79 public: |
67 VideoCaptureManagerTest() {} | 80 VideoCaptureManagerTest() {} |
68 virtual ~VideoCaptureManagerTest() {} | 81 virtual ~VideoCaptureManagerTest() {} |
69 | 82 |
70 protected: | 83 protected: |
71 virtual void SetUp() OVERRIDE { | 84 virtual void SetUp() OVERRIDE { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // VideoCaptureManager destructor otherwise. | 277 // VideoCaptureManager destructor otherwise. |
265 vcm_->Close(video_session_id); | 278 vcm_->Close(video_session_id); |
266 vcm_->Stop(video_session_id, base::Closure()); | 279 vcm_->Stop(video_session_id, base::Closure()); |
267 | 280 |
268 // Wait to check callbacks before removing the listener | 281 // Wait to check callbacks before removing the listener |
269 message_loop_->RunUntilIdle(); | 282 message_loop_->RunUntilIdle(); |
270 vcm_->Unregister(); | 283 vcm_->Unregister(); |
271 } | 284 } |
272 | 285 |
273 } // namespace content | 286 } // namespace content |
OLD | NEW |