| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shell/renderer/test_runner/WebUserMediaClientMock.h" | 5 #include "content/shell/renderer/test_runner/WebUserMediaClientMock.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/shell/renderer/test_runner/MockConstraints.h" | |
| 9 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
| 9 #include "content/shell/renderer/test_runner/mock_constraints.h" |
| 10 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 10 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 11 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" | 11 #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" |
| 12 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 12 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" | 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
| 17 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 17 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
| 18 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 18 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
| 19 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 19 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 DCHECK(!streamRequest.isNull()); | 114 DCHECK(!streamRequest.isNull()); |
| 115 WebUserMediaRequest request = streamRequest; | 115 WebUserMediaRequest request = streamRequest; |
| 116 | 116 |
| 117 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) { | 117 if (request.ownerDocument().isNull() || !request.ownerDocument().frame()) { |
| 118 m_delegate->postTask(new UserMediaRequestPermissionDeniedTask(this, requ
est)); | 118 m_delegate->postTask(new UserMediaRequestPermissionDeniedTask(this, requ
est)); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 | 121 |
| 122 WebMediaConstraints constraints = request.audioConstraints(); | 122 WebMediaConstraints constraints = request.audioConstraints(); |
| 123 WebString failedConstraint; | 123 WebString failedConstraint; |
| 124 if (!constraints.isNull() && !MockConstraints::verifyConstraints(constraints
, &failedConstraint)) { | 124 if (!constraints.isNull() && !MockConstraints::VerifyConstraints(constraints
, &failedConstraint)) { |
| 125 m_delegate->postTask(new UserMediaRequestConstraintFailedTask(this, requ
est, failedConstraint)); | 125 m_delegate->postTask(new UserMediaRequestConstraintFailedTask(this, requ
est, failedConstraint)); |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 constraints = request.videoConstraints(); | 128 constraints = request.videoConstraints(); |
| 129 if (!constraints.isNull() && !MockConstraints::verifyConstraints(constraints
, &failedConstraint)) { | 129 if (!constraints.isNull() && !MockConstraints::VerifyConstraints(constraints
, &failedConstraint)) { |
| 130 m_delegate->postTask(new UserMediaRequestConstraintFailedTask(this, requ
est, failedConstraint)); | 130 m_delegate->postTask(new UserMediaRequestConstraintFailedTask(this, requ
est, failedConstraint)); |
| 131 return; | 131 return; |
| 132 } | 132 } |
| 133 | 133 |
| 134 const size_t zero = 0; | 134 const size_t zero = 0; |
| 135 const size_t one = 1; | 135 const size_t one = 1; |
| 136 WebVector<WebMediaStreamTrack> audioTracks(request.audio() ? one : zero); | 136 WebVector<WebMediaStreamTrack> audioTracks(request.audio() ? one : zero); |
| 137 WebVector<WebMediaStreamTrack> videoTracks(request.video() ? one : zero); | 137 WebVector<WebMediaStreamTrack> videoTracks(request.video() ? one : zero); |
| 138 | 138 |
| 139 if (request.audio()) { | 139 if (request.audio()) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 170 devices[2].initialize("device3", WebMediaDeviceInfo::MediaDeviceKindVideoInp
ut, "Build-in webcam", "group2"); | 170 devices[2].initialize("device3", WebMediaDeviceInfo::MediaDeviceKindVideoInp
ut, "Build-in webcam", "group2"); |
| 171 | 171 |
| 172 m_delegate->postTask(new MediaDevicesRequestTask(this, request, devices)); | 172 m_delegate->postTask(new MediaDevicesRequestTask(this, request, devices)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void WebUserMediaClientMock::cancelMediaDevicesRequest(const WebMediaDevicesRequ
est&) | 175 void WebUserMediaClientMock::cancelMediaDevicesRequest(const WebMediaDevicesRequ
est&) |
| 176 { | 176 { |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace content | 179 } // namespace content |
| OLD | NEW |