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

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: push_messaging fix 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const char kFakeAudioOutputDeviceId1[] = "fake_audio_output 1"; 112 const char kFakeAudioOutputDeviceId1[] = "fake_audio_output 1";
113 113
114 class MockMediaDevicesDispatcherHost 114 class MockMediaDevicesDispatcherHost
115 : public ::mojom::MediaDevicesDispatcherHost { 115 : public ::mojom::MediaDevicesDispatcherHost {
116 public: 116 public:
117 MockMediaDevicesDispatcherHost() {} 117 MockMediaDevicesDispatcherHost() {}
118 void EnumerateDevices(bool request_audio_input, 118 void EnumerateDevices(bool request_audio_input,
119 bool request_video_input, 119 bool request_video_input,
120 bool request_audio_output, 120 bool request_audio_output,
121 const url::Origin& security_origin, 121 const url::Origin& security_origin,
122 const EnumerateDevicesCallback& callback) override { 122 EnumerateDevicesCallback callback) override {
123 std::vector<std::vector<MediaDeviceInfo>> result(NUM_MEDIA_DEVICE_TYPES); 123 std::vector<std::vector<MediaDeviceInfo>> result(NUM_MEDIA_DEVICE_TYPES);
124 if (request_audio_input) { 124 if (request_audio_input) {
125 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo( 125 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo(
126 kFakeAudioInputDeviceId1, "Fake Audio Input 1", "fake_group 1")); 126 kFakeAudioInputDeviceId1, "Fake Audio Input 1", "fake_group 1"));
127 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo( 127 result[MEDIA_DEVICE_TYPE_AUDIO_INPUT].push_back(MediaDeviceInfo(
128 kFakeAudioInputDeviceId2, "Fake Audio Input 2", "fake_group 2")); 128 kFakeAudioInputDeviceId2, "Fake Audio Input 2", "fake_group 2"));
129 } 129 }
130 if (request_video_input) { 130 if (request_video_input) {
131 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back( 131 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back(
132 MediaDeviceInfo(kFakeVideoInputDeviceId1, "Fake Video Input 1", "")); 132 MediaDeviceInfo(kFakeVideoInputDeviceId1, "Fake Video Input 1", ""));
133 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back( 133 result[MEDIA_DEVICE_TYPE_VIDEO_INPUT].push_back(
134 MediaDeviceInfo(kFakeVideoInputDeviceId2, "Fake Video Input 2", "")); 134 MediaDeviceInfo(kFakeVideoInputDeviceId2, "Fake Video Input 2", ""));
135 } 135 }
136 if (request_audio_output) { 136 if (request_audio_output) {
137 result[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].push_back(MediaDeviceInfo( 137 result[MEDIA_DEVICE_TYPE_AUDIO_OUTPUT].push_back(MediaDeviceInfo(
138 kFakeAudioOutputDeviceId1, "Fake Audio Input 1", "fake_group 1")); 138 kFakeAudioOutputDeviceId1, "Fake Audio Input 1", "fake_group 1"));
139 } 139 }
140 callback.Run(result); 140 std::move(callback).Run(result);
141 } 141 }
142 142
143 void GetVideoInputCapabilities( 143 void GetVideoInputCapabilities(
144 const url::Origin& security_origin, 144 const url::Origin& security_origin,
145 const GetVideoInputCapabilitiesCallback& client_callback) override { 145 GetVideoInputCapabilitiesCallback client_callback) override {
146 ::mojom::VideoInputDeviceCapabilitiesPtr device = 146 ::mojom::VideoInputDeviceCapabilitiesPtr device =
147 ::mojom::VideoInputDeviceCapabilities::New(); 147 ::mojom::VideoInputDeviceCapabilities::New();
148 device->device_id = kFakeVideoInputDeviceId1; 148 device->device_id = kFakeVideoInputDeviceId1;
149 device->facing_mode = ::mojom::FacingMode::USER; 149 device->facing_mode = ::mojom::FacingMode::USER;
150 device->formats.push_back(media::VideoCaptureFormat( 150 device->formats.push_back(media::VideoCaptureFormat(
151 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420)); 151 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420));
152 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> result; 152 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> result;
153 result.push_back(std::move(device)); 153 result.push_back(std::move(device));
154 154
155 device = ::mojom::VideoInputDeviceCapabilities::New(); 155 device = ::mojom::VideoInputDeviceCapabilities::New();
156 device->device_id = kFakeVideoInputDeviceId2; 156 device->device_id = kFakeVideoInputDeviceId2;
157 device->facing_mode = ::mojom::FacingMode::ENVIRONMENT; 157 device->facing_mode = ::mojom::FacingMode::ENVIRONMENT;
158 device->formats.push_back(media::VideoCaptureFormat( 158 device->formats.push_back(media::VideoCaptureFormat(
159 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420)); 159 gfx::Size(640, 480), 30.0f, media::PIXEL_FORMAT_I420));
160 result.push_back(std::move(device)); 160 result.push_back(std::move(device));
161 161
162 client_callback.Run(std::move(result)); 162 std::move(client_callback).Run(std::move(result));
163 } 163 }
164 164
165 MOCK_METHOD3(SubscribeDeviceChangeNotifications, 165 MOCK_METHOD3(SubscribeDeviceChangeNotifications,
166 void(MediaDeviceType type, 166 void(MediaDeviceType type,
167 uint32_t subscription_id, 167 uint32_t subscription_id,
168 const url::Origin& security_origin)); 168 const url::Origin& security_origin));
169 MOCK_METHOD2(UnsubscribeDeviceChangeNotifications, 169 MOCK_METHOD2(UnsubscribeDeviceChangeNotifications,
170 void(MediaDeviceType type, uint32_t subscription_id)); 170 void(MediaDeviceType type, uint32_t subscription_id));
171 }; 171 };
172 172
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 CreateDeviceConstraints(kFakeAudioInputDeviceId1); 925 CreateDeviceConstraints(kFakeAudioInputDeviceId1);
926 blink::WebMediaConstraints video_constraints = 926 blink::WebMediaConstraints video_constraints =
927 CreateFacingModeConstraints("environment"); 927 CreateFacingModeConstraints("environment");
928 // kFakeVideoInputDeviceId2 has environment facing mode. 928 // kFakeVideoInputDeviceId2 has environment facing mode.
929 TestValidRequestWithConstraints(audio_constraints, video_constraints, 929 TestValidRequestWithConstraints(audio_constraints, video_constraints,
930 kFakeAudioInputDeviceId1, 930 kFakeAudioInputDeviceId1,
931 kFakeVideoInputDeviceId2); 931 kFakeVideoInputDeviceId2);
932 } 932 }
933 933
934 } // namespace content 934 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698