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

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: Overhauled following all the inputs. 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..b74a126535be17f0be461da60fdab35692640ca0 100644
--- a/content/browser/renderer_host/media/video_capture_manager_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_manager_unittest.cc
@@ -161,32 +161,62 @@ TEST_F(VideoCaptureManagerTest, CreateAndClose) {
vcm_->Unregister();
}
-// Open the same device twice.
-TEST_F(VideoCaptureManagerTest, OpenTwice) {
+// Enumerate devices and open the first, then check the capabilities. Then start
+// the opened device. The capability list should be reduced to just one format,
+// and this should be the one used when configuring-starting the device. Finally
+// stop the device and check that the capabilities have been restored.
+TEST_F(VideoCaptureManagerTest, ManipulateDeviceAndCheckCapabilities) {
StreamDeviceInfoArray devices;
InSequence s;
EXPECT_CALL(*listener_, DevicesEnumerated(MEDIA_DEVICE_VIDEO_CAPTURE, _))
- .Times(1).WillOnce(SaveArg<1>(&devices));
- EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2);
- EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(2);
-
+ .Times(1)
+ .WillOnce(SaveArg<1>(&devices));
vcm_->EnumerateDevices(MEDIA_DEVICE_VIDEO_CAPTURE);
+ message_loop_->RunUntilIdle();
- // Wait to get device callback.
+ EXPECT_CALL(*listener_, Opened(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(1);
+ int video_session_id = vcm_->Open(devices.front());
message_loop_->RunUntilIdle();
- int video_session_id_first = vcm_->Open(devices.front());
+ // When the device has been opened, we should see all the devices'
+ // capabilities.
+ media::VideoCaptureCapabilities device_capabilities;
+ device_capabilities = vcm_->GetDeviceCapabilities(video_session_id);
+ ASSERT_EQ(device_capabilities.size(), 2u);
+ media::VideoCaptureCapabilities::const_iterator format;
+ EXPECT_EQ(device_capabilities[0].width, 640);
+ EXPECT_EQ(device_capabilities[0].height, 480);
+ EXPECT_EQ(device_capabilities[0].frame_rate, 20);
+ EXPECT_EQ(device_capabilities[1].width, 320);
+ EXPECT_EQ(device_capabilities[1].height, 240);
+ EXPECT_EQ(device_capabilities[1].frame_rate, 20);
- // This should trigger an error callback with error code
- // 'kDeviceAlreadyInUse'.
- int video_session_id_second = vcm_->Open(devices.front());
- EXPECT_NE(video_session_id_first, video_session_id_second);
+ VideoCaptureControllerID client_id = StartClient(video_session_id, true);
+ message_loop_->RunUntilIdle();
+ // After StartClient(), the device's list of capabilities should be reduced
+ // to one, coinciding with the configured inside that method: 320x240@30fps.
+ device_capabilities = vcm_->GetDeviceCapabilities(video_session_id);
+ ASSERT_EQ(device_capabilities.size(), 1u);
+ EXPECT_EQ(device_capabilities[0].width, 320);
+ EXPECT_EQ(device_capabilities[0].height, 240);
+ EXPECT_EQ(device_capabilities[0].frame_rate, 30);
- vcm_->Close(video_session_id_first);
- vcm_->Close(video_session_id_second);
+ EXPECT_CALL(*listener_, Closed(MEDIA_DEVICE_VIDEO_CAPTURE, _)).Times(1);
+ StopClient(client_id);
+ message_loop_->RunUntilIdle();
+ // After StopClient(), the device's list of capabilities should be restored
+ // to the original one.
+ device_capabilities = vcm_->GetDeviceCapabilities(video_session_id);
+ ASSERT_EQ(device_capabilities.size(), 2u);
+ EXPECT_EQ(device_capabilities[0].width, 640);
+ EXPECT_EQ(device_capabilities[0].height, 480);
+ EXPECT_EQ(device_capabilities[0].frame_rate, 20);
+ EXPECT_EQ(device_capabilities[1].width, 320);
+ EXPECT_EQ(device_capabilities[1].height, 240);
+ EXPECT_EQ(device_capabilities[1].frame_rate, 20);
- // Wait to check callbacks before removing the listener.
+ vcm_->Close(video_session_id);
message_loop_->RunUntilIdle();
vcm_->Unregister();
}

Powered by Google App Engine
This is Rietveld 408576698