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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/test/mock_callback.h" | 7 #include "base/test/mock_callback.h" |
8 #include "services/video_capture/public/interfaces/device_factory.mojom.h" | 8 #include "services/video_capture/public/interfaces/device_factory.mojom.h" |
9 #include "services/video_capture/test/service_test.h" | 9 #include "services/video_capture/test/video_capture_service_test.h" |
10 | 10 |
11 using testing::Exactly; | 11 using testing::Exactly; |
12 using testing::_; | 12 using testing::_; |
13 using testing::Invoke; | 13 using testing::Invoke; |
14 using testing::InvokeWithoutArgs; | 14 using testing::InvokeWithoutArgs; |
15 | 15 |
16 namespace video_capture { | 16 namespace video_capture { |
17 | 17 |
18 // Tests that an answer arrives from the service when calling | 18 // Tests that an answer arrives from the service when calling |
19 // EnumerateDeviceDescriptors(). | 19 // EnumerateDeviceDescriptors(). |
20 TEST_F(ServiceTest, DISABLED_EnumerateDeviceDescriptorsCallbackArrives) { | 20 TEST_F(VideoCaptureServiceTest, |
| 21 DISABLED_EnumerateDeviceDescriptorsCallbackArrives) { |
21 base::RunLoop wait_loop; | 22 base::RunLoop wait_loop; |
22 EXPECT_CALL(descriptor_receiver_, Run(_)) | 23 EXPECT_CALL(descriptor_receiver_, Run(_)) |
23 .Times(Exactly(1)) | 24 .Times(Exactly(1)) |
24 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); | 25 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); |
25 | 26 |
26 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); | 27 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); |
27 wait_loop.Run(); | 28 wait_loop.Run(); |
28 } | 29 } |
29 | 30 |
30 TEST_F(ServiceTest, DISABLED_FakeDeviceFactoryEnumeratesOneDevice) { | 31 TEST_F(VideoCaptureServiceTest, DISABLED_FakeDeviceFactoryEnumeratesOneDevice) { |
31 base::RunLoop wait_loop; | 32 base::RunLoop wait_loop; |
32 size_t num_devices_enumerated = 0; | 33 size_t num_devices_enumerated = 0; |
33 EXPECT_CALL(descriptor_receiver_, Run(_)) | 34 EXPECT_CALL(descriptor_receiver_, Run(_)) |
34 .Times(Exactly(1)) | 35 .Times(Exactly(1)) |
35 .WillOnce(Invoke([&wait_loop, &num_devices_enumerated]( | 36 .WillOnce(Invoke([&wait_loop, &num_devices_enumerated]( |
36 const std::vector<media::VideoCaptureDeviceDescriptor>& descriptors) { | 37 const std::vector<media::VideoCaptureDeviceDescriptor>& descriptors) { |
37 num_devices_enumerated = descriptors.size(); | 38 num_devices_enumerated = descriptors.size(); |
38 wait_loop.Quit(); | 39 wait_loop.Quit(); |
39 })); | 40 })); |
40 | 41 |
41 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); | 42 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); |
42 wait_loop.Run(); | 43 wait_loop.Run(); |
43 ASSERT_EQ(1u, num_devices_enumerated); | 44 ASSERT_EQ(1u, num_devices_enumerated); |
44 } | 45 } |
45 | 46 |
46 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error | 47 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error |
47 // code when trying to create a device for an invalid descriptor. | 48 // code when trying to create a device for an invalid descriptor. |
48 TEST_F(ServiceTest, DISABLED_ErrorCodeOnCreateDeviceForInvalidDescriptor) { | 49 TEST_F(VideoCaptureServiceTest, |
| 50 DISABLED_ErrorCodeOnCreateDeviceForInvalidDescriptor) { |
49 const std::string invalid_device_id = "invalid"; | 51 const std::string invalid_device_id = "invalid"; |
50 base::RunLoop wait_loop; | 52 base::RunLoop wait_loop; |
51 mojom::DevicePtr fake_device_proxy; | 53 mojom::DevicePtr fake_device_proxy; |
52 base::MockCallback<mojom::DeviceFactory::CreateDeviceCallback> | 54 base::MockCallback<mojom::DeviceFactory::CreateDeviceCallback> |
53 create_device_proxy_callback; | 55 create_device_proxy_callback; |
54 EXPECT_CALL(create_device_proxy_callback, | 56 EXPECT_CALL(create_device_proxy_callback, |
55 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) | 57 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) |
56 .Times(1) | 58 .Times(1) |
57 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); | 59 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); |
58 factory_->CreateDevice(invalid_device_id, | 60 factory_->CreateDevice(invalid_device_id, |
59 mojo::MakeRequest(&fake_device_proxy), | 61 mojo::MakeRequest(&fake_device_proxy), |
60 create_device_proxy_callback.Get()); | 62 create_device_proxy_callback.Get()); |
61 wait_loop.Run(); | 63 wait_loop.Run(); |
62 } | 64 } |
63 | 65 |
64 } // namespace video_capture | 66 } // namespace video_capture |
OLD | NEW |