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

Unified Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 2721113002: getUserMedia: handle the device starting status report. (Closed)
Patch Set: Created 3 years, 10 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_controller_unittest.cc
diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
index eacde473aaba2d0af6af532539f5bf958e39d3ad..e3c2305be643dc8be222fc2a41f5478b529565a6 100644
--- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc
+++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc
@@ -803,4 +803,34 @@ TEST_F(VideoCaptureControllerTest,
Mock::VerifyAndClearExpectations(client_a_.get());
}
+// Because OnStarted event will be called only once from each device, it's the
+// job of VideoCaptureController to report OnStarted event to all the clients.
chfremer 2017/03/02 17:56:10 I like the test! For the description comment here
braveyao 2017/03/03 17:53:12 Done.
+TEST_F(VideoCaptureControllerTest, OnStartedForMultipleClients) {
+ media::VideoCaptureParams session_100;
+ session_100.requested_format = media::VideoCaptureFormat(
+ gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420);
+ media::VideoCaptureParams session_200 = session_100;
+ media::VideoCaptureParams session_300 = session_100;
+
+ const VideoCaptureControllerID client_a_route_1(1);
+ const VideoCaptureControllerID client_a_route_2(2);
+ const VideoCaptureControllerID client_b_route_1(3);
+
+ controller_->AddClient(client_a_route_1, client_a_.get(), 100, session_100);
+ controller_->AddClient(client_b_route_1, client_b_.get(), 300, session_300);
+ ASSERT_EQ(2, controller_->GetClientCount());
+
+ {
+ InSequence s;
+ // Simulate the OnStarted event from device.
+ EXPECT_CALL(*client_a_, OnStarted(_));
+ EXPECT_CALL(*client_b_, OnStarted(_));
+ device_client_->OnStarted();
+
+ // VideoCaptureController will take care of the OnStarted event for the
+ // clients who join later.
+ EXPECT_CALL(*client_a_, OnStarted(_));
+ controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200);
+ }
+}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698