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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 MediaStreamProviderError)); | 42 MediaStreamProviderError)); |
43 }; // class MockMediaStreamProviderListener | 43 }; // class MockMediaStreamProviderListener |
44 | 44 |
45 // Needed as an input argument to StartCaptureForClient(). | 45 // Needed as an input argument to StartCaptureForClient(). |
46 class MockFrameObserver : public VideoCaptureControllerEventHandler { | 46 class MockFrameObserver : public VideoCaptureControllerEventHandler { |
47 public: | 47 public: |
48 MOCK_METHOD1(OnError, void(const VideoCaptureControllerID& id)); | 48 MOCK_METHOD1(OnError, void(const VideoCaptureControllerID& id)); |
49 | 49 |
50 virtual void OnBufferCreated(const VideoCaptureControllerID& id, | 50 virtual void OnBufferCreated(const VideoCaptureControllerID& id, |
51 base::SharedMemoryHandle handle, | 51 base::SharedMemoryHandle handle, |
52 int length, int buffer_id) OVERRIDE {}; | 52 int length, int buffer_id) OVERRIDE {} |
53 virtual void OnBufferReady(const VideoCaptureControllerID& id, | 53 virtual void OnBufferDestroyed(const VideoCaptureControllerID& id, |
54 int buffer_id, | 54 int buffer_id) OVERRIDE {} |
55 base::Time timestamp) OVERRIDE {}; | 55 virtual void OnBufferReady( |
56 virtual void OnFrameInfo( | |
57 const VideoCaptureControllerID& id, | 56 const VideoCaptureControllerID& id, |
58 const media::VideoCaptureCapability& format) OVERRIDE {}; | 57 int buffer_id, |
59 virtual void OnFrameInfoChanged(const VideoCaptureControllerID& id, | 58 base::Time timestamp, |
60 int width, | 59 const media::VideoCaptureFormat& format) OVERRIDE {} |
61 int height, | 60 virtual void OnEnded(const VideoCaptureControllerID& id) OVERRIDE {} |
62 int frame_rate) OVERRIDE {}; | |
63 virtual void OnEnded(const VideoCaptureControllerID& id) OVERRIDE {}; | |
64 | 61 |
65 void OnGotControllerCallback(VideoCaptureControllerID) {} | 62 void OnGotControllerCallback(VideoCaptureControllerID) {} |
66 }; | 63 }; |
67 | 64 |
68 // Test class | 65 // Test class |
69 class VideoCaptureManagerTest : public testing::Test { | 66 class VideoCaptureManagerTest : public testing::Test { |
70 public: | 67 public: |
71 VideoCaptureManagerTest() : next_client_id_(1) {} | 68 VideoCaptureManagerTest() : next_client_id_(1) {} |
72 virtual ~VideoCaptureManagerTest() {} | 69 virtual ~VideoCaptureManagerTest() {} |
73 | 70 |
(...skipping 22 matching lines...) Expand all Loading... |
96 controllers_[id] = controller.get(); | 93 controllers_[id] = controller.get(); |
97 } else { | 94 } else { |
98 ASSERT_TRUE(NULL == controller); | 95 ASSERT_TRUE(NULL == controller); |
99 } | 96 } |
100 quit_closure.Run(); | 97 quit_closure.Run(); |
101 } | 98 } |
102 | 99 |
103 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { | 100 VideoCaptureControllerID StartClient(int session_id, bool expect_success) { |
104 media::VideoCaptureParams params; | 101 media::VideoCaptureParams params; |
105 params.session_id = session_id; | 102 params.session_id = session_id; |
106 params.width = 320; | 103 params.requested_format = media::VideoCaptureFormat( |
107 params.height = 240; | 104 320, 240, 30, media::ConstantResolutionVideoCaptureDevice); |
108 params.frame_rate = 30; | |
109 | 105 |
110 VideoCaptureControllerID client_id(next_client_id_++); | 106 VideoCaptureControllerID client_id(next_client_id_++); |
111 base::RunLoop run_loop; | 107 base::RunLoop run_loop; |
112 vcm_->StartCaptureForClient( | 108 vcm_->StartCaptureForClient( |
113 params, base::kNullProcessHandle, client_id, frame_observer_.get(), | 109 params, base::kNullProcessHandle, client_id, frame_observer_.get(), |
114 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, | 110 base::Bind(&VideoCaptureManagerTest::OnGotControllerCallback, |
115 base::Unretained(this), client_id, run_loop.QuitClosure(), | 111 base::Unretained(this), client_id, run_loop.QuitClosure(), |
116 expect_success)); | 112 expect_success)); |
117 run_loop.Run(); | 113 run_loop.Run(); |
118 return client_id; | 114 return client_id; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // VideoCaptureManager destructor otherwise. | 285 // VideoCaptureManager destructor otherwise. |
290 vcm_->Close(video_session_id); | 286 vcm_->Close(video_session_id); |
291 StopClient(client_id); | 287 StopClient(client_id); |
292 | 288 |
293 // Wait to check callbacks before removing the listener | 289 // Wait to check callbacks before removing the listener |
294 message_loop_->RunUntilIdle(); | 290 message_loop_->RunUntilIdle(); |
295 vcm_->Unregister(); | 291 vcm_->Unregister(); |
296 } | 292 } |
297 | 293 |
298 } // namespace content | 294 } // namespace content |
OLD | NEW |