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 "services/video_capture/public/interfaces/video_capture_device_factory.
mojom.h" | 7 #include "services/video_capture/public/interfaces/video_capture_device_factory.
mojom.h" |
8 #include "services/video_capture/video_capture_service_test.h" | 8 #include "services/video_capture/video_capture_service_test.h" |
9 | 9 |
10 using testing::Exactly; | 10 using testing::Exactly; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 factory_->EnumerateDeviceDescriptors(base::Bind( | 47 factory_->EnumerateDeviceDescriptors(base::Bind( |
48 &MockDeviceDescriptorReceiver::OnEnumerateDeviceDescriptorsCallback, | 48 &MockDeviceDescriptorReceiver::OnEnumerateDeviceDescriptorsCallback, |
49 base::Unretained(&descriptor_receiver_))); | 49 base::Unretained(&descriptor_receiver_))); |
50 wait_loop.Run(); | 50 wait_loop.Run(); |
51 ASSERT_EQ(1u, num_devices_enumerated); | 51 ASSERT_EQ(1u, num_devices_enumerated); |
52 } | 52 } |
53 | 53 |
54 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error | 54 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error |
55 // code when trying to create a device for an invalid descriptor. | 55 // code when trying to create a device for an invalid descriptor. |
56 TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) { | 56 TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) { |
57 media::VideoCaptureDeviceDescriptor invalid_descriptor; | 57 const std::string invalid_device_id = "invalid"; |
58 invalid_descriptor.device_id = "invalid"; | |
59 invalid_descriptor.model_id = "invalid"; | |
60 base::RunLoop wait_loop; | 58 base::RunLoop wait_loop; |
61 mojom::VideoCaptureDeviceProxyPtr fake_device_proxy; | 59 mojom::VideoCaptureDeviceProxyPtr fake_device_proxy; |
62 MockCreateDeviceProxyCallback create_device_proxy_callback; | 60 MockCreateDeviceProxyCallback create_device_proxy_callback; |
63 EXPECT_CALL(create_device_proxy_callback, | 61 EXPECT_CALL(create_device_proxy_callback, |
64 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) | 62 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) |
65 .Times(1) | 63 .Times(1) |
66 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); | 64 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); |
67 factory_->CreateDeviceProxy( | 65 factory_->CreateDeviceProxy( |
68 std::move(invalid_descriptor), mojo::GetProxy(&fake_device_proxy), | 66 invalid_device_id, mojo::GetProxy(&fake_device_proxy), |
69 base::Bind(&MockCreateDeviceProxyCallback::Run, | 67 base::Bind(&MockCreateDeviceProxyCallback::Run, |
70 base::Unretained(&create_device_proxy_callback))); | 68 base::Unretained(&create_device_proxy_callback))); |
71 wait_loop.Run(); | 69 wait_loop.Run(); |
72 } | 70 } |
73 | 71 |
74 } // namespace video_capture | 72 } // namespace video_capture |
OLD | NEW |