Chromium Code Reviews| 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 "content/shell/renderer/test_runner/mock_web_user_media_client.h" | 5 #include "content/shell/renderer/test_runner/mock_web_user_media_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #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" | 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/WebMediaStreamTrackSourcesRequest.h " | |
| 16 #include "third_party/WebKit/public/platform/WebSourceInfo.h" | |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
| 16 #include "third_party/WebKit/public/web/WebDocument.h" | 18 #include "third_party/WebKit/public/web/WebDocument.h" |
| 17 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" | 19 #include "third_party/WebKit/public/web/WebMediaDevicesRequest.h" |
| 18 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 20 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
| 19 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" | 21 #include "third_party/WebKit/public/web/WebUserMediaRequest.h" |
| 20 | 22 |
| 21 using blink::WebMediaConstraints; | 23 using blink::WebMediaConstraints; |
| 22 using blink::WebMediaDeviceInfo; | 24 using blink::WebMediaDeviceInfo; |
| 23 using blink::WebMediaDevicesRequest; | 25 using blink::WebMediaDevicesRequest; |
| 24 using blink::WebMediaStream; | 26 using blink::WebMediaStream; |
| 25 using blink::WebMediaStreamSource; | 27 using blink::WebMediaStreamSource; |
| 26 using blink::WebMediaStreamTrack; | 28 using blink::WebMediaStreamTrack; |
| 29 using blink::WebMediaStreamTrackSourcesRequest; | |
| 30 using blink::WebSourceInfo; | |
| 27 using blink::WebString; | 31 using blink::WebString; |
| 28 using blink::WebUserMediaRequest; | 32 using blink::WebUserMediaRequest; |
| 29 using blink::WebVector; | 33 using blink::WebVector; |
| 30 | 34 |
| 31 namespace content { | 35 namespace content { |
| 32 | 36 |
| 33 class UserMediaRequestTask : public WebMethodTask<MockWebUserMediaClient> { | 37 class UserMediaRequestTask : public WebMethodTask<MockWebUserMediaClient> { |
| 34 public: | 38 public: |
| 35 UserMediaRequestTask(MockWebUserMediaClient* object, | 39 UserMediaRequestTask(MockWebUserMediaClient* object, |
| 36 const WebUserMediaRequest& request, | 40 const WebUserMediaRequest& request, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 request_(request), | 94 request_(request), |
| 91 result_(result) {} | 95 result_(result) {} |
| 92 | 96 |
| 93 virtual void RunIfValid() OVERRIDE { request_.requestSucceeded(result_); } | 97 virtual void RunIfValid() OVERRIDE { request_.requestSucceeded(result_); } |
| 94 | 98 |
| 95 private: | 99 private: |
| 96 WebMediaDevicesRequest request_; | 100 WebMediaDevicesRequest request_; |
| 97 WebVector<WebMediaDeviceInfo> result_; | 101 WebVector<WebMediaDeviceInfo> result_; |
| 98 }; | 102 }; |
| 99 | 103 |
| 104 class SourcesRequestTask : public WebMethodTask<MockWebUserMediaClient> { | |
| 105 public: | |
| 106 SourcesRequestTask(MockWebUserMediaClient* object, | |
| 107 const WebMediaStreamTrackSourcesRequest& request, | |
| 108 const WebVector<WebSourceInfo>& result) | |
| 109 : WebMethodTask<MockWebUserMediaClient>(object), | |
| 110 request_(request), | |
| 111 result_(result) {} | |
| 112 | |
| 113 virtual void RunIfValid() OVERRIDE { request_.requestSucceeded(result_); } | |
| 114 | |
| 115 private: | |
| 116 WebMediaStreamTrackSourcesRequest request_; | |
| 117 WebVector<WebSourceInfo> result_; | |
| 118 }; | |
|
jochen (gone - plz use gerrit)
2014/09/16 14:19:14
nit. disallow_copy_and_assign
Henrik Grunell
2014/09/16 15:18:48
Done.
| |
| 119 | |
| 100 class MockExtraData : public WebMediaStream::ExtraData { | 120 class MockExtraData : public WebMediaStream::ExtraData { |
| 101 public: | 121 public: |
| 102 int foo; | 122 int foo; |
| 103 }; | 123 }; |
| 104 | 124 |
| 105 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate) | 125 MockWebUserMediaClient::MockWebUserMediaClient(WebTestDelegate* delegate) |
| 106 : delegate_(delegate) {} | 126 : delegate_(delegate) {} |
| 107 | 127 |
| 108 void MockWebUserMediaClient::requestUserMedia( | 128 void MockWebUserMediaClient::requestUserMedia( |
| 109 const WebUserMediaRequest& stream_request) { | 129 const WebUserMediaRequest& stream_request) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 "Build-in webcam", | 203 "Build-in webcam", |
| 184 "group2"); | 204 "group2"); |
| 185 | 205 |
| 186 delegate_->postTask(new MediaDevicesRequestTask(this, request, devices)); | 206 delegate_->postTask(new MediaDevicesRequestTask(this, request, devices)); |
| 187 } | 207 } |
| 188 | 208 |
| 189 void MockWebUserMediaClient::cancelMediaDevicesRequest( | 209 void MockWebUserMediaClient::cancelMediaDevicesRequest( |
| 190 const WebMediaDevicesRequest&) { | 210 const WebMediaDevicesRequest&) { |
| 191 } | 211 } |
| 192 | 212 |
| 213 void MockWebUserMediaClient::requestSources( | |
| 214 const blink::WebMediaStreamTrackSourcesRequest& request) { | |
| 215 const size_t size = 2; | |
|
Mike West
2014/09/16 12:56:09
I see that other bits of this file use the same pa
Henrik Grunell
2014/09/16 13:22:35
This will be used in layout tests, can it be contr
Mike West
2014/09/16 13:36:29
No. My point was that if you're going to hard-code
Henrik Grunell
2014/09/16 15:18:48
Ah, of course. :) Done.
| |
| 216 WebVector<WebSourceInfo> sources(size); | |
| 217 | |
| 218 sources[0].initialize("device1", | |
| 219 WebSourceInfo::SourceKindAudio, | |
| 220 "Built-in microphone", | |
| 221 WebSourceInfo::VideoFacingModeNone); | |
| 222 sources[1].initialize("device2", | |
| 223 WebSourceInfo::SourceKindVideo, | |
| 224 "Build-in webcam", | |
| 225 WebSourceInfo::VideoFacingModeEnvironment); | |
|
Mike West
2014/09/16 12:56:09
Is this enough flexibility for you? It might make
Henrik Grunell
2014/09/16 13:22:35
Well, this will be used in layout tests, can it be
Mike West
2014/09/16 13:36:29
There are a number of mocks with setter methods th
Henrik Grunell
2014/09/16 15:18:48
OK, thanks for the pointer.
| |
| 226 | |
| 227 delegate_->postTask(new SourcesRequestTask(this, request, sources)); | |
| 228 } | |
| 229 | |
| 193 } // namespace content | 230 } // namespace content |
| OLD | NEW |