Home | History | Annotate | Download | only in runner
      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/WebRTCPeerConnectionHandler.h"
     36 #include "public/platform/WebRTCSessionDescription.h"
     37 #include "public/platform/WebRTCSessionDescriptionRequest.h"
     38 #include "public/platform/WebRTCStatsRequest.h"
     39 #include "public/testing/WebTask.h"
     40 
     41 namespace WebKit {
     42 class WebRTCPeerConnectionHandlerClient;
     43 };
     44 
     45 namespace WebTestRunner {
     46 
     47 class TestInterfaces;
     48 
     49 class MockWebRTCPeerConnectionHandler : public WebKit::WebRTCPeerConnectionHandler {
     50 public:
     51     MockWebRTCPeerConnectionHandler(WebKit::WebRTCPeerConnectionHandlerClient*, TestInterfaces*);
     52 
     53     virtual bool initialize(const WebKit::WebRTCConfiguration&, const WebKit::WebMediaConstraints&) OVERRIDE;
     54 
     55     virtual void createOffer(const WebKit::WebRTCSessionDescriptionRequest&, const WebKit::WebMediaConstraints&) OVERRIDE;
     56     virtual void createAnswer(const WebKit::WebRTCSessionDescriptionRequest&, const WebKit::WebMediaConstraints&) OVERRIDE;
     57     virtual void setLocalDescription(const WebKit::WebRTCVoidRequest&, const WebKit::WebRTCSessionDescription&) OVERRIDE;
     58     virtual void setRemoteDescription(const WebKit::WebRTCVoidRequest&, const WebKit::WebRTCSessionDescription&) OVERRIDE;
     59     virtual WebKit::WebRTCSessionDescription localDescription() OVERRIDE;
     60     virtual WebKit::WebRTCSessionDescription remoteDescription() OVERRIDE;
     61     virtual bool updateICE(const WebKit::WebRTCConfiguration&, const WebKit::WebMediaConstraints&) OVERRIDE;
     62     virtual bool addICECandidate(const WebKit::WebRTCICECandidate&) OVERRIDE;
     63     virtual bool addStream(const WebKit::WebMediaStream&, const WebKit::WebMediaConstraints&) OVERRIDE;
     64     virtual void removeStream(const WebKit::WebMediaStream&) OVERRIDE;
     65     virtual void getStats(const WebKit::WebRTCStatsRequest&) OVERRIDE;
     66     virtual WebKit::WebRTCDataChannelHandler* createDataChannel(const WebKit::WebString& label, const WebKit::WebRTCDataChannelInit&) OVERRIDE;
     67     virtual WebKit::WebRTCDTMFSenderHandler* createDTMFSender(const WebKit::WebMediaStreamTrack&) OVERRIDE;
     68     virtual void stop() OVERRIDE;
     69 
     70     // WebTask related methods
     71     WebTaskList* taskList() { return &m_taskList; }
     72 
     73 private:
     74     MockWebRTCPeerConnectionHandler() { }
     75 
     76     WebKit::WebRTCPeerConnectionHandlerClient* m_client;
     77     bool m_stopped;
     78     WebTaskList m_taskList;
     79     WebKit::WebRTCSessionDescription m_localDescription;
     80     WebKit::WebRTCSessionDescription m_remoteDescription;
     81     int m_streamCount;
     82     TestInterfaces* m_interfaces;
     83 };
     84 
     85 }
     86 
     87 #endif // MockWebRTCPeerConnectionHandler_h
     88 
     89