OLD | NEW |
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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/test_runner/mock_constraints.h" |
11 #include "components/test_runner/web_test_delegate.h" | 12 #include "components/test_runner/web_test_delegate.h" |
12 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 13 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
13 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" | 14 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" |
14 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 15 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
15 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 16 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
16 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
17 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h
" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h
" |
18 #include "third_party/WebKit/public/platform/WebSourceInfo.h" | 19 #include "third_party/WebKit/public/platform/WebSourceInfo.h" |
19 #include "third_party/WebKit/public/platform/WebVector.h" | 20 #include "third_party/WebKit/public/platform/WebVector.h" |
20 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const WebUserMediaRequest& stream_request) { | 139 const WebUserMediaRequest& stream_request) { |
139 DCHECK(!stream_request.isNull()); | 140 DCHECK(!stream_request.isNull()); |
140 WebUserMediaRequest request = stream_request; | 141 WebUserMediaRequest request = stream_request; |
141 | 142 |
142 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) { | 143 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) { |
143 delegate_->PostTask( | 144 delegate_->PostTask( |
144 new UserMediaRequestPermissionDeniedTask(this, request)); | 145 new UserMediaRequestPermissionDeniedTask(this, request)); |
145 return; | 146 return; |
146 } | 147 } |
147 | 148 |
| 149 WebMediaConstraints constraints = request.audioConstraints(); |
| 150 WebString failed_constraint; |
| 151 if (!constraints.isNull() && |
| 152 !MockConstraints::VerifyConstraints(constraints, &failed_constraint)) { |
| 153 delegate_->PostTask(new UserMediaRequestConstraintFailedTask( |
| 154 this, request, failed_constraint)); |
| 155 return; |
| 156 } |
| 157 constraints = request.videoConstraints(); |
| 158 if (!constraints.isNull() && |
| 159 !MockConstraints::VerifyConstraints(constraints, &failed_constraint)) { |
| 160 delegate_->PostTask(new UserMediaRequestConstraintFailedTask( |
| 161 this, request, failed_constraint)); |
| 162 return; |
| 163 } |
| 164 |
148 WebMediaStream stream; | 165 WebMediaStream stream; |
149 stream.initialize(WebVector<WebMediaStreamTrack>(), | 166 stream.initialize(WebVector<WebMediaStreamTrack>(), |
150 WebVector<WebMediaStreamTrack>()); | 167 WebVector<WebMediaStreamTrack>()); |
151 stream.setExtraData(new MockExtraData()); | 168 stream.setExtraData(new MockExtraData()); |
152 | 169 |
153 if (request.audio() && | 170 if (request.audio() && |
154 !delegate_->AddMediaStreamAudioSourceAndTrack(&stream)) { | 171 !delegate_->AddMediaStreamAudioSourceAndTrack(&stream)) { |
155 WebMediaStreamSource source; | 172 WebMediaStreamSource source; |
156 source.initialize("MockAudioDevice#1", | 173 source.initialize("MockAudioDevice#1", |
157 WebMediaStreamSource::TypeAudio, | 174 WebMediaStreamSource::TypeAudio, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 sources[i].initialize(WebString::fromUTF8(test_sources[i].id), | 269 sources[i].initialize(WebString::fromUTF8(test_sources[i].id), |
253 test_sources[i].kind, | 270 test_sources[i].kind, |
254 WebString::fromUTF8(test_sources[i].label), | 271 WebString::fromUTF8(test_sources[i].label), |
255 test_sources[i].facing); | 272 test_sources[i].facing); |
256 } | 273 } |
257 | 274 |
258 delegate_->PostTask(new SourcesRequestTask(this, request, sources)); | 275 delegate_->PostTask(new SourcesRequestTask(this, request, sources)); |
259 } | 276 } |
260 | 277 |
261 } // namespace test_runner | 278 } // namespace test_runner |
OLD | NEW |