Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager_unittest.cc

Issue 29423003: Added video capture capabilities retrieval and caching to VideoCaptureManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 VideoCaptureControllerID client_id = StartClient(video_session_id, true); 158 VideoCaptureControllerID client_id = StartClient(video_session_id, true);
159 159
160 StopClient(client_id); 160 StopClient(client_id);
161 vcm_->Close(video_session_id); 161 vcm_->Close(video_session_id);
162 162
163 // Wait to check callbacks before removing the listener. 163 // Wait to check callbacks before removing the listener.
164 message_loop_->RunUntilIdle(); 164 message_loop_->RunUntilIdle();
165 vcm_->Unregister(); 165 vcm_->Unregister();
166 } 166 }
167 167
168 // Try to enumerate devices, then check their capture capabilities.
169 TEST_F(VideoCaptureManagerTest, EnumerateDevicesAndCheckCapabilities) {
170 StreamDeviceInfoArray devices;
171
172 EXPECT_CALL(*listener_, DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, _))
173 .Times(1).WillOnce(SaveArg<1>(&devices));
174 vcm_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE);
175 message_loop_->RunUntilIdle();
176
177 StreamDeviceInfoArray::iterator device_it;
178 for (device_it = devices.begin(); device_it != devices.end(); ++device_it) {
179 const media::VideoCaptureCapabilities* device_capabilities =
180 vcm_->EnumerateDeviceCapabilities(*device_it);
181 if (device_capabilities == NULL) continue;
182 DCHECK_GE(device_capabilities->size(), 1u);
183
184 media::VideoCaptureCapabilities::const_iterator format;
185 for (format = device_capabilities->begin();
186 format != device_capabilities->end();
187 ++format) {
188 DCHECK_GE(format->width, 1);
189 DCHECK_GE(format->height, 1);
190 DCHECK_GE(format->frame_rate, 1);
191 DVLOG(1) << " Device name: " << device_it->device.name << ", format ("
192 << format->width << "x" << format->height << ")@"
193 << format->frame_rate << "fps";
194 }
195 }
196 vcm_->Unregister();
197 }
198
168 // Open the same device twice. 199 // Open the same device twice.
169 TEST_F(VideoCaptureManagerTest, OpenTwice) { 200 TEST_F(VideoCaptureManagerTest, OpenTwice) {
170 StreamDeviceInfoArray devices; 201 StreamDeviceInfoArray devices;
171 202
172 InSequence s; 203 InSequence s;
173 EXPECT_CALL(*listener_, DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, _)) 204 EXPECT_CALL(*listener_, DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, _))
174 .Times(1).WillOnce(SaveArg<1>(&devices)); 205 .Times(1).WillOnce(SaveArg<1>(&devices));
175 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2); 206 EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2);
176 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2); 207 EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2);
177 208
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // VideoCaptureManager destructor otherwise. 320 // VideoCaptureManager destructor otherwise.
290 vcm_->Close(video_session_id); 321 vcm_->Close(video_session_id);
291 StopClient(client_id); 322 StopClient(client_id);
292 323
293 // Wait to check callbacks before removing the listener 324 // Wait to check callbacks before removing the listener
294 message_loop_->RunUntilIdle(); 325 message_loop_->RunUntilIdle();
295 vcm_->Unregister(); 326 vcm_->Unregister();
296 } 327 }
297 328
298 } // namespace content 329 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698