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

Side by Side Diff: services/video_capture/test/mock_device_unittest.cc

Issue 2660743002: Merge video_capture tests into service_unittests (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 unified diff | Download patch
OLDNEW
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 // This alias ensures test output is easily attributed to this service's tests.
14 // TODO(rockot/chfremer): Consider just renaming the type.
15 using MockVideoCaptureDeviceTest = MockDeviceTest;
16
13 // Tests that the service stops the capture device when the client closes the 17 // Tests that the service stops the capture device when the client closes the
14 // connection to the device proxy. 18 // connection to the device proxy.
15 TEST_F(MockDeviceTest, DISABLED_DeviceIsStoppedWhenDiscardingDeviceProxy) { 19 TEST_F(MockVideoCaptureDeviceTest,
20 DISABLED_DeviceIsStoppedWhenDiscardingDeviceProxy) {
16 base::RunLoop wait_loop; 21 base::RunLoop wait_loop;
17 22
18 // The mock device must hold on to the device client that is passed to it. 23 // The mock device must hold on to the device client that is passed to it.
19 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; 24 std::unique_ptr<media::VideoCaptureDevice::Client> device_client;
20 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) 25 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _))
21 .WillOnce(Invoke([&device_client]( 26 .WillOnce(Invoke([&device_client](
22 const media::VideoCaptureParams& params, 27 const media::VideoCaptureParams& params,
23 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { 28 std::unique_ptr<media::VideoCaptureDevice::Client>* client) {
24 device_client.reset(client->release()); 29 device_client.reset(client->release());
25 })); 30 }));
26 EXPECT_CALL(mock_device_, StopAndDeAllocate()) 31 EXPECT_CALL(mock_device_, StopAndDeAllocate())
27 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); 32 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
28 33
29 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); 34 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
30 device_proxy_.reset(); 35 device_proxy_.reset();
31 36
32 wait_loop.Run(); 37 wait_loop.Run();
33 } 38 }
34 39
35 // Tests that the service stops the capture device when the client closes the 40 // Tests that the service stops the capture device when the client closes the
36 // connection to the client proxy it provided to the service. 41 // connection to the client proxy it provided to the service.
37 TEST_F(MockDeviceTest, DISABLED_DeviceIsStoppedWhenDiscardingDeviceClient) { 42 TEST_F(MockVideoCaptureDeviceTest,
43 DISABLED_DeviceIsStoppedWhenDiscardingDeviceClient) {
38 base::RunLoop wait_loop; 44 base::RunLoop wait_loop;
39 45
40 // The mock device must hold on to the device client that is passed to it. 46 // The mock device must hold on to the device client that is passed to it.
41 std::unique_ptr<media::VideoCaptureDevice::Client> device_client; 47 std::unique_ptr<media::VideoCaptureDevice::Client> device_client;
42 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _)) 48 EXPECT_CALL(mock_device_, DoAllocateAndStart(_, _))
43 .WillOnce(Invoke([&device_client]( 49 .WillOnce(Invoke([&device_client](
44 const media::VideoCaptureParams& params, 50 const media::VideoCaptureParams& params,
45 std::unique_ptr<media::VideoCaptureDevice::Client>* client) { 51 std::unique_ptr<media::VideoCaptureDevice::Client>* client) {
46 device_client.reset(client->release()); 52 device_client.reset(client->release());
47 })); 53 }));
48 EXPECT_CALL(mock_device_, StopAndDeAllocate()) 54 EXPECT_CALL(mock_device_, StopAndDeAllocate())
49 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); 55 .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
50 56
51 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); 57 device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
52 mock_receiver_.reset(); 58 mock_receiver_.reset();
53 59
54 wait_loop.Run(); 60 wait_loop.Run();
55 } 61 }
56 62
57 } // namespace video_capture 63 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/test/fake_device_unittest.cc ('k') | services/video_capture/test/service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698