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

Side by Side Diff: content/renderer/media/user_media_client_impl_unittest.cc

Issue 2824193002: Enable use_once_callback for //content/common/*.mojom (Closed)
Patch Set: rebase Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/media/user_media_client_impl.h" 5 #include "content/renderer/media/user_media_client_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const char kFakeAudioOutputDeviceId1[] = "fake_audio_output 1"; 111 const char kFakeAudioOutputDeviceId1[] = "fake_audio_output 1";
112 112
113 class MockMediaDevicesDispatcherHost 113 class MockMediaDevicesDispatcherHost
114 : public ::mojom::MediaDevicesDispatcherHost { 114 : public ::mojom::MediaDevicesDispatcherHost {
115 public: 115 public:
116 MockMediaDevicesDispatcherHost() {} 116 MockMediaDevicesDispatcherHost() {}
117 void EnumerateDevices(bool request_audio_input, 117 void EnumerateDevices(bool request_audio_input,
118 bool request_video_input, 118 bool request_video_input,
119 bool request_audio_output, 119 bool request_audio_output,
120 const url::Origin& security_origin, 120 const url::Origin& security_origin,
121 const EnumerateDevicesCallback& callback) override { 121 EnumerateDevicesCallback callback) override {
122 std::vector<std::vector<MediaDeviceInfo>> result(NUM_MEDIA_DEVICE_TYPES); 122 std::vector<std::vector<MediaDeviceInfo>> result(NUM_MEDIA_DEVICE_TYPES);
123 if (request_audio_input) { 123 if (request_audio_input) {
124 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo( 124 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo(
125 kFakeAudioInputDeviceId1, "Fake Audio Input 1", "fake_group 1")); 125 kFakeAudioInputDeviceId1, "Fake Audio Input 1", "fake_group 1"));
126 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo( 126 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo(
127 kFakeAudioInputDeviceId2, "Fake Audio Input 2", "fake_group 2")); 127 kFakeAudioInputDeviceId2, "Fake Audio Input 2", "fake_group 2"));
128 } 128 }
129 if (request_video_input) { 129 if (request_video_input) {
130 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back( 130 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back(
131 MediaDeviceInfo(kFakeVideoInputDeviceId1, "Fake Video Input 1", "")); 131 MediaDeviceInfo(kFakeVideoInputDeviceId1, "Fake Video Input 1", ""));
132 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back( 132 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back(
133 MediaDeviceInfo(kFakeVideoInputDeviceId2, "Fake Video Input 2", "")); 133 MediaDeviceInfo(kFakeVideoInputDeviceId2, "Fake Video Input 2", ""));
134 } 134 }
135 if (request_audio_output) { 135 if (request_audio_output) {
136 result[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].push_back(MediaDeviceInfo( 136 result[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].push_back(MediaDeviceInfo(
137 kFakeAudioOutputDeviceId1, "Fake Audio Input 1", "fake_group 1")); 137 kFakeAudioOutputDeviceId1, "Fake Audio Input 1", "fake_group 1"));
138 } 138 }
139 callback.Run(result); 139 std::move(callback).Run(result);
140 } 140 }
141 141
142 void GetVideoInputCapabilities( 142 void GetVideoInputCapabilities(
143 const url::Origin& security_origin, 143 const url::Origin& security_origin,
144 const GetVideoInputCapabilitiesCallback& client_callback) override { 144 GetVideoInputCapabilitiesCallback client_callback) override {
145 ::mojom::VideoInputDeviceCapabilitiesPtr device = 145 ::mojom::VideoInputDeviceCapabilitiesPtr device =
146 ::mojom::VideoInputDeviceCapabilities::New(); 146 ::mojom::VideoInputDeviceCapabilities::New();
147 device->device_id = kFakeVideoInputDeviceId1; 147 device->device_id = kFakeVideoInputDeviceId1;
148 device->facing_mode = ::mojom::FacingMode::USER; 148 device->facing_mode = ::mojom::FacingMode::USER;
149 device->formats.push_back(media::VideoCaptureFormat( 149 device->formats.push_back(media::VideoCaptureFormat(
150 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420)); 150 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420));
151 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> result; 151 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> result;
152 result.push_back(std::move(device)); 152 result.push_back(std::move(device));
153 153
154 device = ::mojom::VideoInputDeviceCapabilities::New(); 154 device = ::mojom::VideoInputDeviceCapabilities::New();
155 device->device_id = kFakeVideoInputDeviceId2; 155 device->device_id = kFakeVideoInputDeviceId2;
156 device->facing_mode = ::mojom::FacingMode::ENVIRONMENT; 156 device->facing_mode = ::mojom::FacingMode::ENVIRONMENT;
157 device->formats.push_back(media::VideoCaptureFormat( 157 device->formats.push_back(media::VideoCaptureFormat(
158 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420)); 158 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420));
159 result.push_back(std::move(device)); 159 result.push_back(std::move(device));
160 160
161 client_callback.Run(std::move(result)); 161 std::move(client_callback).Run(std::move(result));
162 } 162 }
163 163
164 MOCK_METHOD3(SubscribeDeviceChangeNotifications, 164 MOCK_METHOD3(SubscribeDeviceChangeNotifications,
165 void(MediaDeviceType type, 165 void(MediaDeviceType type,
166 uint32_t subscription_id, 166 uint32_t subscription_id,
167 const url::Origin& security_origin)); 167 const url::Origin& security_origin));
168 MOCK_METHOD2(UnsubscribeDeviceChangeNotifications, 168 MOCK_METHOD2(UnsubscribeDeviceChangeNotifications,
169 void(MediaDeviceType type, uint32_t subscription_id)); 169 void(MediaDeviceType type, uint32_t subscription_id));
170 }; 170 };
171 171
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 CreateDeviceConstraints(kFakeAudioInputDeviceId1); 923 CreateDeviceConstraints(kFakeAudioInputDeviceId1);
924 blink::WebMediaConstraints video_constraints = 924 blink::WebMediaConstraints video_constraints =
925 CreateFacingModeConstraints("environment"); 925 CreateFacingModeConstraints("environment");
926 // kFakeVideoInputDeviceId2 has environment facing mode. 926 // kFakeVideoInputDeviceId2 has environment facing mode.
927 TestValidRequestWithConstraints(audio_constraints, video_constraints, 927 TestValidRequestWithConstraints(audio_constraints, video_constraints,
928 kFakeAudioInputDeviceId1, 928 kFakeAudioInputDeviceId1,
929 kFakeVideoInputDeviceId2); 929 kFakeVideoInputDeviceId2);
930 } 930 }
931 931
932 } // namespace content 932 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698