Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "content/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 // second frame. Since the new |device_client_| is still alive, the second | 796 // second frame. Since the new |device_client_| is still alive, the second |
| 797 // buffer is expected to stay alive. | 797 // buffer is expected to stay alive. |
| 798 EXPECT_CALL(*client_a_, DoBufferDestroyed(_, first_buffer_id)).Times(0); | 798 EXPECT_CALL(*client_a_, DoBufferDestroyed(_, first_buffer_id)).Times(0); |
| 799 EXPECT_CALL(*client_a_, DoBufferDestroyed(_, second_buffer_id)).Times(0); | 799 EXPECT_CALL(*client_a_, DoBufferDestroyed(_, second_buffer_id)).Times(0); |
| 800 controller_->ReturnBuffer(arbitrary_route_id_, client_a_.get(), | 800 controller_->ReturnBuffer(arbitrary_route_id_, client_a_.get(), |
| 801 second_buffer_id, arbitrary_utilization); | 801 second_buffer_id, arbitrary_utilization); |
| 802 base::RunLoop().RunUntilIdle(); | 802 base::RunLoop().RunUntilIdle(); |
| 803 Mock::VerifyAndClearExpectations(client_a_.get()); | 803 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 804 } | 804 } |
| 805 | 805 |
| 806 // Because OnStarted event will be called only once from each device, it's the | |
| 807 // 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.
| |
| 808 TEST_F(VideoCaptureControllerTest, OnStartedForMultipleClients) { | |
| 809 media::VideoCaptureParams session_100; | |
| 810 session_100.requested_format = media::VideoCaptureFormat( | |
| 811 gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420); | |
| 812 media::VideoCaptureParams session_200 = session_100; | |
| 813 media::VideoCaptureParams session_300 = session_100; | |
| 814 | |
| 815 const VideoCaptureControllerID client_a_route_1(1); | |
| 816 const VideoCaptureControllerID client_a_route_2(2); | |
| 817 const VideoCaptureControllerID client_b_route_1(3); | |
| 818 | |
| 819 controller_->AddClient(client_a_route_1, client_a_.get(), 100, session_100); | |
| 820 controller_->AddClient(client_b_route_1, client_b_.get(), 300, session_300); | |
| 821 ASSERT_EQ(2, controller_->GetClientCount()); | |
| 822 | |
| 823 { | |
| 824 InSequence s; | |
| 825 // Simulate the OnStarted event from device. | |
| 826 EXPECT_CALL(*client_a_, OnStarted(_)); | |
| 827 EXPECT_CALL(*client_b_, OnStarted(_)); | |
| 828 device_client_->OnStarted(); | |
| 829 | |
| 830 // VideoCaptureController will take care of the OnStarted event for the | |
| 831 // clients who join later. | |
| 832 EXPECT_CALL(*client_a_, OnStarted(_)); | |
| 833 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); | |
| 834 } | |
| 835 } | |
| 806 } // namespace content | 836 } // namespace content |
| OLD | NEW |