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

Unified 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: Changed mechanics of Caps enumeration to be asynchronous and 2 threaded. UT adapted. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_manager_unittest.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager_unittest.cc b/content/browser/renderer_host/media/video_capture_manager_unittest.cc
index a986e0bc3702eca982798687eb0dbc9f17821b82..aa6cb7f7637e158360ef8faaa7033e3a3ed7f06c 100644
--- a/content/browser/renderer_host/media/video_capture_manager_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_manager_unittest.cc
@@ -40,6 +40,9 @@ class MockMediaStreamProviderListener : public MediaStreamProviderListener {
const StreamDeviceInfoArray&));
MOCK_METHOD3(Error, void(MediaStreamType, int,
MediaStreamProviderError));
+ MOCK_METHOD2(
+ DeviceCapabilitiesEnumerated,
+ void(const StreamDeviceInfo&, const media::VideoCaptureCapabilities&));
}; // class MockMediaStreamProviderListener
// Needed as an input argument to StartCaptureForClient().
@@ -161,6 +164,42 @@ TEST_F(VideoCaptureManagerTest, CreateAndClose) {
vcm_->Unregister();
}
+// Try to enumerate devices, then check their capture capabilities.
+TEST_F(VideoCaptureManagerTest, EnumerateDevicesAndCheckCapabilities) {
+ StreamDeviceInfoArray devices;
+
+ InSequence s;
+ EXPECT_CALL(*listener_, DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, _))
+ .Times(1).WillOnce(SaveArg<1>(&devices));
+ vcm_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE);
+ message_loop_->RunUntilIdle();
+
tommi (sloooow) - chröme 2013/10/25 14:15:34 1 empty line
mcasas 2013/10/28 12:50:08 Done.
+
+ media::VideoCaptureCapabilities device_capabilities;
+ StreamDeviceInfoArray::iterator device_it;
+ for (device_it = devices.begin(); device_it != devices.end(); ++device_it) {
+ EXPECT_CALL(*listener_, DeviceCapabilitiesEnumerated(_, _))
+ .Times(1).WillOnce(SaveArg<1>(&device_capabilities));
+
+ vcm_->EnumerateDeviceCapabilities(*device_it);
+ message_loop_->RunUntilIdle();
tommi (sloooow) - chröme 2013/10/25 14:15:34 can you add a comment that explains what happens d
mcasas 2013/10/28 12:50:08 (Tentatively) Done.
+ DCHECK_GE(device_capabilities.size(), 1u);
tommi (sloooow) - chröme 2013/10/25 14:15:34 ASSERT_GE?
mcasas 2013/10/28 12:50:08 Hmm device documentation says devices may return e
+
+ media::VideoCaptureCapabilities::const_iterator format;
+ for (format = device_capabilities.begin();
+ format != device_capabilities.end();
+ ++format) {
+ DCHECK_GE(format->width, 1);
tommi (sloooow) - chröme 2013/10/25 14:15:34 EXPECT_GE? (same below)
mcasas 2013/10/28 12:50:08 Oops :) Yes, all should be EXPECT_GE
+ DCHECK_GE(format->height, 1);
+ DCHECK_GE(format->frame_rate, 1);
+ DVLOG(1) << " Device name: " << device_it->device.name << ", format ("
+ << format->width << "x" << format->height << ")@"
+ << format->frame_rate << "fps";
+ }
+ }
+ vcm_->Unregister();
+}
+
// Open the same device twice.
TEST_F(VideoCaptureManagerTest, OpenTwice) {
StreamDeviceInfoArray devices;

Powered by Google App Engine
This is Rietveld 408576698