| 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/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" |
| 19 #include "third_party/WebKit/public/platform/WebVector.h" | 21 #include "third_party/WebKit/public/platform/WebVector.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
| 21 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 23 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
| 22 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 24 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| 23 | 25 |
| 24 using blink::WebMediaConstraints; | 26 using blink::WebMediaConstraints; |
| 25 using blink::WebMediaDeviceInfo; | 27 using blink::WebMediaDeviceInfo; |
| 26 using blink::WebMediaDevicesRequest; | 28 using blink::WebMediaDevicesRequest; |
| 27 using blink::WebMediaStream; | 29 using blink::WebMediaStream; |
| 28 using blink::WebMediaStreamSource; | 30 using blink::WebMediaStreamSource; |
| 29 using blink::WebMediaStreamTrack; | 31 using blink::WebMediaStreamTrack; |
| 32 using blink::WebMediaStreamTrackSourcesRequest; |
| 33 using blink::WebSourceInfo; |
| 30 using blink::WebString; | 34 using blink::WebString; |
| 31 using blink::WebUserMediaRequest; | 35 using blink::WebUserMediaRequest; |
| 32 using blink::WebVector; | 36 using blink::WebVector; |
| 33 | 37 |
| 34 namespace test_runner { | 38 namespace test_runner { |
| 35 | 39 |
| 36 class MockExtraData : public WebMediaStream::ExtraData { | 40 class MockExtraData : public WebMediaStream::ExtraData { |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate) | 43 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 144 |
| 141 delegate_->PostTask( | 145 delegate_->PostTask( |
| 142 base::Bind(&WebMediaDevicesRequest::requestSucceeded, | 146 base::Bind(&WebMediaDevicesRequest::requestSucceeded, |
| 143 base::Owned(new WebMediaDevicesRequest(request)), devices)); | 147 base::Owned(new WebMediaDevicesRequest(request)), devices)); |
| 144 | 148 |
| 145 should_enumerate_extra_device_ = !should_enumerate_extra_device_; | 149 should_enumerate_extra_device_ = !should_enumerate_extra_device_; |
| 146 if (!media_device_change_observer_.isNull()) | 150 if (!media_device_change_observer_.isNull()) |
| 147 media_device_change_observer_.didChangeMediaDevices(); | 151 media_device_change_observer_.didChangeMediaDevices(); |
| 148 } | 152 } |
| 149 | 153 |
| 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 |
| 150 void MockWebUserMediaClient::setMediaDeviceChangeObserver( | 189 void MockWebUserMediaClient::setMediaDeviceChangeObserver( |
| 151 const blink::WebMediaDeviceChangeObserver& observer) { | 190 const blink::WebMediaDeviceChangeObserver& observer) { |
| 152 media_device_change_observer_ = observer; | 191 media_device_change_observer_ = observer; |
| 153 } | 192 } |
| 154 | 193 |
| 155 } // namespace test_runner | 194 } // namespace test_runner |
| OLD | NEW |