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

Side by Side Diff: components/test_runner/mock_web_user_media_client.cc

Issue 2471803002: Remove MediaStreamTrack.getSources(). (Closed)
Patch Set: Fix platform-specific expectations file Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/mock_web_user_media_client.h" 5 #include "components/test_runner/mock_web_user_media_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/test_runner/web_test_delegate.h" 13 #include "components/test_runner/web_test_delegate.h"
14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
15 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" 15 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
16 #include "third_party/WebKit/public/platform/WebMediaStream.h" 16 #include "third_party/WebKit/public/platform/WebMediaStream.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
19 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h "
20 #include "third_party/WebKit/public/platform/WebSourceInfo.h"
21 #include "third_party/WebKit/public/platform/WebVector.h" 19 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 20 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" 21 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h"
24 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" 22 #include "third_party/WebKit/public/web/WebUserMediaRequest.h"
25 23
26 using blink::WebMediaConstraints; 24 using blink::WebMediaConstraints;
27 using blink::WebMediaDeviceInfo; 25 using blink::WebMediaDeviceInfo;
28 using blink::WebMediaDevicesRequest; 26 using blink::WebMediaDevicesRequest;
29 using blink::WebMediaStream; 27 using blink::WebMediaStream;
30 using blink::WebMediaStreamSource; 28 using blink::WebMediaStreamSource;
31 using blink::WebMediaStreamTrack; 29 using blink::WebMediaStreamTrack;
32 using blink::WebMediaStreamTrackSourcesRequest;
33 using blink::WebSourceInfo;
34 using blink::WebString; 30 using blink::WebString;
35 using blink::WebUserMediaRequest; 31 using blink::WebUserMediaRequest;
36 using blink::WebVector; 32 using blink::WebVector;
37 33
38 namespace test_runner { 34 namespace test_runner {
39 35
40 class MockExtraData : public WebMediaStream::ExtraData { 36 class MockExtraData : public WebMediaStream::ExtraData {
41 }; 37 };
42 38
43 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate) 39 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 140
145 delegate_->PostTask( 141 delegate_->PostTask(
146 base::Bind(&WebMediaDevicesRequest::requestSucceeded, 142 base::Bind(&WebMediaDevicesRequest::requestSucceeded,
147 base::Owned(new WebMediaDevicesRequest(request)), devices)); 143 base::Owned(new WebMediaDevicesRequest(request)), devices));
148 144
149 should_enumerate_extra_device_ = !should_enumerate_extra_device_; 145 should_enumerate_extra_device_ = !should_enumerate_extra_device_;
150 if (!media_device_change_observer_.isNull()) 146 if (!media_device_change_observer_.isNull())
151 media_device_change_observer_.didChangeMediaDevices(); 147 media_device_change_observer_.didChangeMediaDevices();
152 } 148 }
153 149
154 void MockWebUserMediaClient::requestSources(
155 const blink::WebMediaStreamTrackSourcesRequest& request) {
156 struct {
157 const char* id;
158 WebSourceInfo::SourceKind kind;
159 const char* label;
160 WebSourceInfo::VideoFacingMode facing;
161 } test_sources[] = {
162 {
163 "device1",
164 WebSourceInfo::SourceKindAudio,
165 "Built-in microphone",
166 WebSourceInfo::VideoFacingModeNone,
167 },
168 {
169 "device2",
170 WebSourceInfo::SourceKindVideo,
171 "Build-in webcam",
172 WebSourceInfo::VideoFacingModeEnvironment,
173 },
174 };
175
176 WebVector<WebSourceInfo> sources(arraysize(test_sources));
177 for (size_t i = 0; i < arraysize(test_sources); ++i) {
178 sources[i].initialize(WebString::fromUTF8(test_sources[i].id),
179 test_sources[i].kind,
180 WebString::fromUTF8(test_sources[i].label),
181 test_sources[i].facing);
182 }
183
184 delegate_->PostTask(base::Bind(
185 &WebMediaStreamTrackSourcesRequest::requestSucceeded,
186 base::Owned(new WebMediaStreamTrackSourcesRequest(request)), sources));
187 }
188
189 void MockWebUserMediaClient::setMediaDeviceChangeObserver( 150 void MockWebUserMediaClient::setMediaDeviceChangeObserver(
190 const blink::WebMediaDeviceChangeObserver& observer) { 151 const blink::WebMediaDeviceChangeObserver& observer) {
191 media_device_change_observer_ = observer; 152 media_device_change_observer_ = observer;
192 } 153 }
193 154
194 } // namespace test_runner 155 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/mock_web_user_media_client.h ('k') | content/renderer/media/media_stream_center.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698