| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "services/video_capture/test/mock_device_test.h" | 6 #include "services/video_capture/test/mock_device_test.h" |
| 7 | 7 |
| 8 using testing::_; | 8 using testing::_; |
| 9 using testing::Invoke; | 9 using testing::Invoke; |
| 10 | 10 |
| 11 namespace video_capture { | 11 namespace video_capture { |
| 12 | 12 |
| 13 // Tests that the service stops the capture device when the client closes the | 13 // Tests that the service stops the capture device when the client closes the |
| 14 // connection to the device proxy. | 14 // connection to the device proxy. |
| 15 TEST_F(MockDeviceTest, DISABLED_DeviceIsStoppedWhenDiscardingDeviceProxy) { | 15 TEST_F(MockDeviceTest, DeviceIsStoppedWhenDiscardingDeviceProxy) { |
| 16 base::RunLoop wait_loop; | 16 base::RunLoop wait_loop; |
| 17 | 17 |
| 18 // The mock device must hold on to the device client that is passed to it. | 18 // The mock device must hold on to the device client that is passed to it. |
| 19 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; | 19 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; |
| 20 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) | 20 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) |
| 21 .WillOnce(Invoke([&device_client]( | 21 .WillOnce(Invoke([&device_client]( |
| 22 const media::VideoCaptureParams& params, | 22 const media::VideoCaptureParams& params, |
| 23 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { | 23 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { |
| 24 device_client.reset(client->release()); | 24 device_client.reset(client->release()); |
| 25 })); | 25 })); |
| 26 EXPECT_CALL(mock_device_, StopAndDeAllocate()) | 26 EXPECT_CALL(mock_device_, StopAndDeAllocate()) |
| 27 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); | 27 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); |
| 28 | 28 |
| 29 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); | 29 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); |
| 30 device_proxy_.reset(); | 30 device_proxy_.reset(); |
| 31 | 31 |
| 32 wait_loop.Run(); | 32 wait_loop.Run(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Tests that the service stops the capture device when the client closes the | 35 // Tests that the service stops the capture device when the client closes the |
| 36 // connection to the client proxy it provided to the service. | 36 // connection to the client proxy it provided to the service. |
| 37 TEST_F(MockDeviceTest, DISABLED_DeviceIsStoppedWhenDiscardingDeviceClient) { | 37 TEST_F(MockDeviceTest, DeviceIsStoppedWhenDiscardingDeviceClient) { |
| 38 base::RunLoop wait_loop; | 38 base::RunLoop wait_loop; |
| 39 | 39 |
| 40 // The mock device must hold on to the device client that is passed to it. | 40 // The mock device must hold on to the device client that is passed to it. |
| 41 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; | 41 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; |
| 42 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) | 42 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) |
| 43 .WillOnce(Invoke([&device_client]( | 43 .WillOnce(Invoke([&device_client]( |
| 44 const media::VideoCaptureParams& params, | 44 const media::VideoCaptureParams& params, |
| 45 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { | 45 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { |
| 46 device_client.reset(client->release()); | 46 device_client.reset(client->release()); |
| 47 })); | 47 })); |
| 48 EXPECT_CALL(mock_device_, StopAndDeAllocate()) | 48 EXPECT_CALL(mock_device_, StopAndDeAllocate()) |
| 49 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); | 49 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); |
| 50 | 50 |
| 51 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); | 51 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); |
| 52 mock_receiver_.reset(); | 52 mock_receiver_.reset(); |
| 53 | 53 |
| 54 wait_loop.Run(); | 54 wait_loop.Run(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace video_capture | 57 } // namespace video_capture |
| OLD | NEW |