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 #ifndef SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ | 5 #ifndef SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ |
6 #define SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ | 6 #define SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ |
7 | 7 |
8 #include "base/test/mock_callback.h" | 8 #include "base/test/mock_callback.h" |
9 #include "media/capture/video/video_capture_device.h" | 9 #include "media/capture/video/video_capture_device.h" |
10 #include "services/video_capture/device_factory_media_to_mojo_adapter.h" | 10 #include "services/video_capture/device_factory_media_to_mojo_adapter.h" |
11 #include "services/video_capture/public/cpp/capture_settings.h" | |
12 #include "services/video_capture/public/interfaces/service.mojom.h" | 11 #include "services/video_capture/public/interfaces/service.mojom.h" |
13 #include "services/video_capture/test/mock_device_factory.h" | 12 #include "services/video_capture/test/mock_device_factory.h" |
14 #include "services/video_capture/test/mock_receiver.h" | 13 #include "services/video_capture/test/mock_receiver.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 | 15 |
17 namespace base { | 16 namespace base { |
18 class MessageLoop; | 17 class MessageLoop; |
19 } | 18 } |
20 | 19 |
21 namespace video_capture { | 20 namespace video_capture { |
22 | 21 |
23 class MockDevice : public media::VideoCaptureDevice { | 22 class MockDevice : public media::VideoCaptureDevice { |
24 public: | 23 public: |
25 MockDevice(); | 24 MockDevice(); |
26 ~MockDevice() override; | 25 ~MockDevice() override; |
27 | 26 |
28 // media::VideoCaptureDevice: | 27 // media::VideoCaptureDevice: |
29 MOCK_METHOD2(DoAllocateAndStart, | 28 MOCK_METHOD2(DoAllocateAndStart, |
30 void(const media::VideoCaptureParams& params, | 29 void(const media::VideoCaptureParams& params, |
31 std::unique_ptr<Client>* client)); | 30 std::unique_ptr<Client>* client)); |
32 MOCK_METHOD0(RequestRefreshFrame, void()); | 31 MOCK_METHOD0(RequestRefreshFrame, void()); |
33 MOCK_METHOD0(StopAndDeAllocate, void()); | 32 MOCK_METHOD0(StopAndDeAllocate, void()); |
34 MOCK_METHOD1(DoGetPhotoCapabilities, | 33 MOCK_METHOD1(DoGetPhotoCapabilities, |
35 void(GetPhotoCapabilitiesCallback* callback)); | 34 void(GetPhotoCapabilitiesCallback* callback)); |
36 MOCK_METHOD2(DoSetPhotoOptions, | 35 MOCK_METHOD2(DoSetPhotoOptions, |
37 void(media::mojom::PhotoSettingsPtr* settings, | 36 void(media::mojom::PhotoSettingsPtr* settings, |
38 SetPhotoOptionsCallback* callback)); | 37 SetPhotoOptionsCallback* callback)); |
39 MOCK_METHOD1(DoTakePhoto, void(TakePhotoCallback* callback)); | 38 MOCK_METHOD1(DoTakePhoto, void(TakePhotoCallback* callback)); |
| 39 MOCK_METHOD2(OnUtilizationReport, |
| 40 void(int frame_feedback_id, double utilization)); |
40 | 41 |
41 void AllocateAndStart(const media::VideoCaptureParams& params, | 42 void AllocateAndStart(const media::VideoCaptureParams& params, |
42 std::unique_ptr<Client> client) override; | 43 std::unique_ptr<Client> client) override; |
43 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; | 44 void GetPhotoCapabilities(GetPhotoCapabilitiesCallback callback) override; |
44 void SetPhotoOptions(media::mojom::PhotoSettingsPtr settings, | 45 void SetPhotoOptions(media::mojom::PhotoSettingsPtr settings, |
45 SetPhotoOptionsCallback callback) override; | 46 SetPhotoOptionsCallback callback) override; |
46 void TakePhoto(TakePhotoCallback callback) override; | 47 void TakePhoto(TakePhotoCallback callback) override; |
47 }; | 48 }; |
48 | 49 |
49 // Reusable test setup for testing with a single mock device. | 50 // Reusable test setup for testing with a single mock device. |
50 class MockDeviceTest : public ::testing::Test { | 51 class MockDeviceTest : public ::testing::Test { |
51 public: | 52 public: |
52 MockDeviceTest(); | 53 MockDeviceTest(); |
53 ~MockDeviceTest() override; | 54 ~MockDeviceTest() override; |
54 | 55 |
55 void SetUp() override; | 56 void SetUp() override; |
56 | 57 |
57 protected: | 58 protected: |
58 MockDeviceFactory* mock_device_factory_; | 59 MockDeviceFactory* mock_device_factory_; |
59 std::unique_ptr<DeviceFactoryMediaToMojoAdapter> mock_device_factory_adapter_; | 60 std::unique_ptr<DeviceFactoryMediaToMojoAdapter> mock_device_factory_adapter_; |
60 | 61 |
61 mojom::DeviceFactoryPtr factory_; | 62 mojom::DeviceFactoryPtr factory_; |
62 std::unique_ptr<mojo::Binding<mojom::DeviceFactory>> mock_factory_binding_; | 63 std::unique_ptr<mojo::Binding<mojom::DeviceFactory>> mock_factory_binding_; |
63 base::MockCallback<mojom::DeviceFactory::EnumerateDeviceDescriptorsCallback> | 64 base::MockCallback<mojom::DeviceFactory::GetDeviceInfosCallback> |
64 descriptor_receiver_; | 65 device_infos_receiver_; |
65 | 66 |
66 MockDevice mock_device_; | 67 MockDevice mock_device_; |
67 std::unique_ptr<MockReceiver> mock_receiver_; | 68 std::unique_ptr<MockReceiver> mock_receiver_; |
68 mojom::DevicePtr device_proxy_; | 69 mojom::DevicePtr device_proxy_; |
69 mojom::ReceiverPtr mock_receiver_proxy_; | 70 mojom::ReceiverPtr mock_receiver_proxy_; |
70 CaptureSettings requested_settings_; | 71 media::VideoCaptureParams requested_settings_; |
71 | 72 |
72 private: | 73 private: |
73 std::unique_ptr<base::MessageLoop> message_loop_; | 74 std::unique_ptr<base::MessageLoop> message_loop_; |
74 }; | 75 }; |
75 | 76 |
76 } // namespace video_capture | 77 } // namespace video_capture |
77 | 78 |
78 #endif // SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ | 79 #endif // SERVICES_VIDEO_CAPTURE_TEST_MOCK_DEVICE_TEST_H_ |
OLD | NEW |