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 "services/video_capture/mock_device_video_capture_service_test.h" | 5 #include "services/video_capture/mock_device_video_capture_service_test.h" |
6 | 6 |
7 namespace video_capture { | 7 namespace video_capture { |
8 | 8 |
9 MockDeviceVideoCaptureServiceTest::MockDeviceVideoCaptureServiceTest() | 9 MockDeviceVideoCaptureServiceTest::MockDeviceVideoCaptureServiceTest() |
10 : shell::test::ServiceTest("exe:video_capture_unittests") {} | 10 : shell::test::ServiceTest("exe:video_capture_unittests") {} |
11 | 11 |
12 MockDeviceVideoCaptureServiceTest::~MockDeviceVideoCaptureServiceTest() = | 12 MockDeviceVideoCaptureServiceTest::~MockDeviceVideoCaptureServiceTest() = |
13 default; | 13 default; |
14 | 14 |
15 void MockDeviceVideoCaptureServiceTest::SetUp() { | 15 void MockDeviceVideoCaptureServiceTest::SetUp() { |
16 ServiceTest::SetUp(); | 16 ServiceTest::SetUp(); |
17 connector()->ConnectToInterface("mojo:video_capture", &service_); | 17 connector()->ConnectToInterface("service:video_capture", &service_); |
18 service_->ConnectToMockDeviceFactory(mojo::GetProxy(&factory_)); | 18 service_->ConnectToMockDeviceFactory(mojo::GetProxy(&factory_)); |
19 | 19 |
20 // Set up a mock device and add it to the factory | 20 // Set up a mock device and add it to the factory |
21 mock_device_ = base::MakeUnique<MockVideoCaptureDeviceImpl>( | 21 mock_device_ = base::MakeUnique<MockVideoCaptureDeviceImpl>( |
22 mojo::GetProxy(&mock_device_proxy_)); | 22 mojo::GetProxy(&mock_device_proxy_)); |
23 auto mock_descriptor = mojom::VideoCaptureDeviceDescriptor::New(); | 23 auto mock_descriptor = mojom::VideoCaptureDeviceDescriptor::New(); |
24 mock_descriptor->device_id = "MockDeviceId"; | 24 mock_descriptor->device_id = "MockDeviceId"; |
25 ASSERT_TRUE(service_->AddDeviceToMockFactory(std::move(mock_device_proxy_), | 25 ASSERT_TRUE(service_->AddDeviceToMockFactory(std::move(mock_device_proxy_), |
26 mock_descriptor->Clone())); | 26 mock_descriptor->Clone())); |
27 | 27 |
28 // Obtain the mock device from the factory | 28 // Obtain the mock device from the factory |
29 factory_->CreateDeviceProxy( | 29 factory_->CreateDeviceProxy( |
30 mock_descriptor->Clone(), mojo::GetProxy(&device_proxy_), | 30 mock_descriptor->Clone(), mojo::GetProxy(&device_proxy_), |
31 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); | 31 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); |
32 | 32 |
33 // Start the mock device with an arbitrary format | 33 // Start the mock device with an arbitrary format |
34 requested_format_.frame_size = gfx::Size(800, 600); | 34 requested_format_.frame_size = gfx::Size(800, 600); |
35 requested_format_.frame_rate = 15; | 35 requested_format_.frame_rate = 15; |
36 requested_format_.pixel_format = media::PIXEL_FORMAT_I420; | 36 requested_format_.pixel_format = media::PIXEL_FORMAT_I420; |
37 requested_format_.pixel_storage = media::PIXEL_STORAGE_CPU; | 37 requested_format_.pixel_storage = media::PIXEL_STORAGE_CPU; |
38 mock_client_ = base::MakeUnique<MockVideoCaptureDeviceClient>( | 38 mock_client_ = base::MakeUnique<MockVideoCaptureDeviceClient>( |
39 mojo::GetProxy(&mock_client_proxy_)); | 39 mojo::GetProxy(&mock_client_proxy_)); |
40 } | 40 } |
41 | 41 |
42 } // namespace video_capture | 42 } // namespace video_capture |
OLD | NEW |