Chromium Code Reviews| 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..37d8f7a1285ca149427b84cae5439ac068f1f07a 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) { |
|
perkj_chrome
2013/11/05 09:34:34
Please keep the old test and add a new test for te
mcasas
2013/11/05 22:46:06
Sure, I don't know how I removed the old one :S
|
| 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; |
| + vcm_->GetDeviceCapabilities(video_session_id, &device_capabilities); |
| + ASSERT_EQ(device_capabilities.size(), 2u); |
| + media::VideoCaptureCapabilities::const_iterator format; |
|
perkj_chrome
2013/11/05 09:34:34
declare where you use it.
mcasas
2013/11/05 22:46:06
Interestingly enough, the compiler did not warn ab
|
| + EXPECT_EQ(device_capabilities[0].width, 640); |
|
perkj_chrome
2013/11/05 09:34:34
Is this relevant? ie - do you really care about ab
mcasas
2013/11/05 22:46:06
Wouldn't we like to break-adapt if fake device cha
|
| + 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. |
| + vcm_->GetDeviceCapabilities(video_session_id, &device_capabilities); |
| + ASSERT_EQ(device_capabilities.size(), 1u); |
| + EXPECT_EQ(device_capabilities[0].width, 320); |
|
perkj_chrome
2013/11/05 09:34:34
This should probably verify that device_capabiliti
mcasas
2013/11/05 22:46:06
Again, overly cautious but hey, you're the owner.
|
| + 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. |
| + vcm_->GetDeviceCapabilities(video_session_id, &device_capabilities); |
| + 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(); |
| } |