1 /* 2 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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. 29 */ 30 31 #ifndef MockWebRTCPeerConnectionHandler_h 32 #define MockWebRTCPeerConnectionHandler_h 33 34 #include "TestCommon.h" 35 #include "public/platform/WebNonCopyable.h" 36 #include "public/platform/WebRTCPeerConnectionHandler.h" 37 #include "public/platform/WebRTCSessionDescription.h" 38 #include "public/platform/WebRTCSessionDescriptionRequest.h" 39 #include "public/platform/WebRTCStatsRequest.h" 40 #include "public/testing/WebTask.h" 41 42 namespace blink { 43 class WebRTCPeerConnectionHandlerClient; 44 }; 45 46 namespace WebTestRunner { 47 48 class TestInterfaces; 49 50 class MockWebRTCPeerConnectionHandler : public blink::WebRTCPeerConnectionHandler, public blink::WebNonCopyable { 51 public: 52 MockWebRTCPeerConnectionHandler(blink::WebRTCPeerConnectionHandlerClient*, TestInterfaces*); 53 54 virtual bool initialize(const blink::WebRTCConfiguration&, const blink::WebMediaConstraints&) OVERRIDE; 55 56 virtual void createOffer(const blink::WebRTCSessionDescriptionRequest&, const blink::WebMediaConstraints&) OVERRIDE; 57 virtual void createAnswer(const blink::WebRTCSessionDescriptionRequest&, const blink::WebMediaConstraints&) OVERRIDE; 58 virtual void setLocalDescription(const blink::WebRTCVoidRequest&, const blink::WebRTCSessionDescription&) OVERRIDE; 59 virtual void setRemoteDescription(const blink::WebRTCVoidRequest&, const blink::WebRTCSessionDescription&) OVERRIDE; 60 virtual blink::WebRTCSessionDescription localDescription() OVERRIDE; 61 virtual blink::WebRTCSessionDescription remoteDescription() OVERRIDE; 62 virtual bool updateICE(const blink::WebRTCConfiguration&, const blink::WebMediaConstraints&) OVERRIDE; 63 virtual bool addICECandidate(const blink::WebRTCICECandidate&) OVERRIDE; 64 virtual bool addICECandidate(const blink::WebRTCVoidRequest&, const blink::WebRTCICECandidate&) OVERRIDE; 65 virtual bool addStream(const blink::WebMediaStream&, const blink::WebMediaConstraints&) OVERRIDE; 66 virtual void removeStream(const blink::WebMediaStream&) OVERRIDE; 67 virtual void getStats(const blink::WebRTCStatsRequest&) OVERRIDE; 68 virtual blink::WebRTCDataChannelHandler* createDataChannel(const blink::WebString& label, const blink::WebRTCDataChannelInit&) OVERRIDE; 69 virtual blink::WebRTCDTMFSenderHandler* createDTMFSender(const blink::WebMediaStreamTrack&) OVERRIDE; 70 virtual void stop() OVERRIDE; 71 72 // WebTask related methods 73 WebTaskList* taskList() { return &m_taskList; } 74 75 private: 76 MockWebRTCPeerConnectionHandler() { } 77 78 blink::WebRTCPeerConnectionHandlerClient* m_client; 79 bool m_stopped; 80 WebTaskList m_taskList; 81 blink::WebRTCSessionDescription m_localDescription; 82 blink::WebRTCSessionDescription m_remoteDescription; 83 int m_streamCount; 84 TestInterfaces* m_interfaces; 85 }; 86 87 } 88 89 #endif // MockWebRTCPeerConnectionHandler_h 90 91