| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #include "MockWebMediaStreamCenter.h" | 33 #include "MockWebMediaStreamCenter.h" |
| 34 | 34 |
| 35 #include "TestInterfaces.h" |
| 36 #include "WebTestDelegate.h" |
| 35 #include "public/platform/WebAudioDestinationConsumer.h" | 37 #include "public/platform/WebAudioDestinationConsumer.h" |
| 36 #include "public/platform/WebMediaStream.h" | 38 #include "public/platform/WebMediaStream.h" |
| 37 #include "public/platform/WebMediaStreamCenterClient.h" | 39 #include "public/platform/WebMediaStreamCenterClient.h" |
| 38 #include "public/platform/WebMediaStreamSource.h" | 40 #include "public/platform/WebMediaStreamSource.h" |
| 39 #include "public/platform/WebMediaStreamSourcesRequest.h" | 41 #include "public/platform/WebMediaStreamSourcesRequest.h" |
| 40 #include "public/platform/WebMediaStreamTrack.h" | 42 #include "public/platform/WebMediaStreamTrack.h" |
| 43 #include "public/platform/WebMediaStreamTrackSourcesRequest.h" |
| 41 #include "public/platform/WebSourceInfo.h" | 44 #include "public/platform/WebSourceInfo.h" |
| 42 #include "public/platform/WebVector.h" | 45 #include "public/platform/WebVector.h" |
| 43 | 46 |
| 44 using namespace WebKit; | 47 using namespace WebKit; |
| 45 | 48 |
| 46 namespace WebTestRunner { | 49 namespace WebTestRunner { |
| 47 | 50 |
| 48 MockWebMediaStreamCenter::MockWebMediaStreamCenter(WebMediaStreamCenterClient* c
lient) | 51 class MediaStreamTrackSourcesRequestTask : public WebMethodTask<MockWebMediaStre
amCenter> { |
| 52 public: |
| 53 MediaStreamTrackSourcesRequestTask(MockWebMediaStreamCenter* object, const W
ebMediaStreamTrackSourcesRequest& request) |
| 54 : WebMethodTask<MockWebMediaStreamCenter>(object) |
| 55 , m_request(request) |
| 56 { |
| 57 } |
| 58 |
| 59 virtual void runIfValid() OVERRIDE |
| 60 { |
| 61 size_t size = 2; |
| 62 WebVector<WebSourceInfo> results(size); |
| 63 results[0].initialize("MockAudioDevice#1", WebSourceInfo::SourceKindAudi
o, "Mock audio device", WebSourceInfo::VideoFacingModeNone); |
| 64 results[1].initialize("MockVideoDevice#1", WebSourceInfo::SourceKindVide
o, "Mock video device", WebSourceInfo::VideoFacingModeEnvironment); |
| 65 m_request.requestSucceeded(results); |
| 66 } |
| 67 |
| 68 private: |
| 69 WebMediaStreamTrackSourcesRequest m_request; |
| 70 }; |
| 71 |
| 72 MockWebMediaStreamCenter::MockWebMediaStreamCenter(WebMediaStreamCenterClient* c
lient, TestInterfaces* interfaces) |
| 73 : m_interfaces(interfaces) |
| 49 { | 74 { |
| 50 } | 75 } |
| 51 | 76 |
| 52 void MockWebMediaStreamCenter::queryMediaStreamSources(const WebMediaStreamSourc
esRequest& request) | 77 void MockWebMediaStreamCenter::queryMediaStreamSources(const WebMediaStreamSourc
esRequest& request) |
| 53 { | 78 { |
| 54 WebVector<WebMediaStreamSource> audioSources, videoSources; | 79 WebVector<WebMediaStreamSource> audioSources, videoSources; |
| 55 request.didCompleteQuery(audioSources, videoSources); | 80 request.didCompleteQuery(audioSources, videoSources); |
| 56 } | 81 } |
| 57 | 82 |
| 58 bool MockWebMediaStreamCenter::getSourceInfos(const WebString& url, WebVector<We
bSourceInfo>& webSourceInfoVector) | 83 bool MockWebMediaStreamCenter::getMediaStreamTrackSources(const WebMediaStreamTr
ackSourcesRequest& request) |
| 59 { | 84 { |
| 60 size_t size = 2; | 85 m_interfaces->delegate()->postTask(new MediaStreamTrackSourcesRequestTask(th
is, request)); |
| 61 WebVector<WebSourceInfo> results(size); | |
| 62 results[0].initialize("MockAudioDevice#1", WebSourceInfo::SourceKindAudio, "
Mock audio device", WebSourceInfo::VideoFacingModeNone); | |
| 63 results[1].initialize("MockVideoDevice#1", WebSourceInfo::SourceKindVideo, "
Mock video device", WebSourceInfo::VideoFacingModeEnvironment); | |
| 64 webSourceInfoVector.swap(results); | |
| 65 return true; | 86 return true; |
| 66 } | 87 } |
| 67 | 88 |
| 68 void MockWebMediaStreamCenter::didEnableMediaStreamTrack(const WebMediaStream&,
const WebMediaStreamTrack& component) | 89 void MockWebMediaStreamCenter::didEnableMediaStreamTrack(const WebMediaStream&,
const WebMediaStreamTrack& component) |
| 69 { | 90 { |
| 70 component.source().setReadyState(WebMediaStreamSource::ReadyStateLive); | 91 component.source().setReadyState(WebMediaStreamSource::ReadyStateLive); |
| 71 } | 92 } |
| 72 | 93 |
| 73 void MockWebMediaStreamCenter::didDisableMediaStreamTrack(const WebMediaStream&,
const WebMediaStreamTrack& component) | 94 void MockWebMediaStreamCenter::didDisableMediaStreamTrack(const WebMediaStream&,
const WebMediaStreamTrack& component) |
| 74 { | 95 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 105 if (source.requiresAudioConsumer()) { | 126 if (source.requiresAudioConsumer()) { |
| 106 MockWebAudioDestinationConsumer* consumer = new MockWebAudioDestinat
ionConsumer(); | 127 MockWebAudioDestinationConsumer* consumer = new MockWebAudioDestinat
ionConsumer(); |
| 107 source.addAudioConsumer(consumer); | 128 source.addAudioConsumer(consumer); |
| 108 source.removeAudioConsumer(consumer); | 129 source.removeAudioConsumer(consumer); |
| 109 delete consumer; | 130 delete consumer; |
| 110 } | 131 } |
| 111 } | 132 } |
| 112 } | 133 } |
| 113 | 134 |
| 114 } | 135 } |
| OLD | NEW |