Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / media / mock_peer_connection_impl.h
blobef7d63bee5b4d7733a7a8e771d5a2871521e5558
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_PEER_CONNECTION_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_MOCK_PEER_CONNECTION_IMPL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h"
17 namespace content {
19 class MockPeerConnectionDependencyFactory;
20 class MockStreamCollection;
22 class MockPeerConnectionImpl : public webrtc::PeerConnectionInterface {
23 public:
24 explicit MockPeerConnectionImpl(MockPeerConnectionDependencyFactory* factory,
25 webrtc::PeerConnectionObserver* observer);
27 // PeerConnectionInterface implementation.
28 rtc::scoped_refptr<webrtc::StreamCollectionInterface>
29 local_streams() override;
30 rtc::scoped_refptr<webrtc::StreamCollectionInterface>
31 remote_streams() override;
32 bool AddStream(
33 webrtc::MediaStreamInterface* local_stream) override;
34 void RemoveStream(
35 webrtc::MediaStreamInterface* local_stream) override;
36 rtc::scoped_refptr<webrtc::DtmfSenderInterface>
37 CreateDtmfSender(webrtc::AudioTrackInterface* track) override;
38 rtc::scoped_refptr<webrtc::DataChannelInterface>
39 CreateDataChannel(const std::string& label,
40 const webrtc::DataChannelInit* config) override;
41 bool GetStats(webrtc::StatsObserver* observer,
42 webrtc::MediaStreamTrackInterface* track,
43 StatsOutputLevel level) override;
45 // Set Call this function to make sure next call to GetStats fail.
46 void SetGetStatsResult(bool result) { getstats_result_ = result; }
48 SignalingState signaling_state() override {
49 NOTIMPLEMENTED();
50 return PeerConnectionInterface::kStable;
52 IceState ice_state() override {
53 NOTIMPLEMENTED();
54 return PeerConnectionInterface::kIceNew;
56 IceConnectionState ice_connection_state() override {
57 NOTIMPLEMENTED();
58 return PeerConnectionInterface::kIceConnectionNew;
60 IceGatheringState ice_gathering_state() override {
61 NOTIMPLEMENTED();
62 return PeerConnectionInterface::kIceGatheringNew;
64 void Close() override {
65 NOTIMPLEMENTED();
68 const webrtc::SessionDescriptionInterface* local_description() const override;
69 const webrtc::SessionDescriptionInterface* remote_description()
70 const override;
72 // JSEP01 APIs
73 void CreateOffer(
74 webrtc::CreateSessionDescriptionObserver* observer,
75 const webrtc::MediaConstraintsInterface* constraints) override;
76 void CreateAnswer(
77 webrtc::CreateSessionDescriptionObserver* observer,
78 const webrtc::MediaConstraintsInterface* constraints) override;
79 MOCK_METHOD2(SetLocalDescription,
80 void(webrtc::SetSessionDescriptionObserver* observer,
81 webrtc::SessionDescriptionInterface* desc));
82 void SetLocalDescriptionWorker(
83 webrtc::SetSessionDescriptionObserver* observer,
84 webrtc::SessionDescriptionInterface* desc) ;
85 MOCK_METHOD2(SetRemoteDescription,
86 void(webrtc::SetSessionDescriptionObserver* observer,
87 webrtc::SessionDescriptionInterface* desc));
88 void SetRemoteDescriptionWorker(
89 webrtc::SetSessionDescriptionObserver* observer,
90 webrtc::SessionDescriptionInterface* desc);
91 bool UpdateIce(const IceServers& configuration,
92 const webrtc::MediaConstraintsInterface* constraints) override;
93 bool AddIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
94 void RegisterUMAObserver(webrtc::UMAObserver* observer) override;
96 void AddRemoteStream(webrtc::MediaStreamInterface* stream);
98 const std::string& stream_label() const { return stream_label_; }
99 bool hint_audio() const { return hint_audio_; }
100 bool hint_video() const { return hint_video_; }
101 const std::string& description_sdp() const { return description_sdp_; }
102 const std::string& sdp_mid() const { return sdp_mid_; }
103 int sdp_mline_index() const { return sdp_mline_index_; }
104 const std::string& ice_sdp() const { return ice_sdp_; }
105 webrtc::SessionDescriptionInterface* created_session_description() const {
106 return created_sessiondescription_.get();
108 webrtc::PeerConnectionObserver* observer() {
109 return observer_;
111 static const char kDummyOffer[];
112 static const char kDummyAnswer[];
114 protected:
115 virtual ~MockPeerConnectionImpl();
117 private:
118 // Used for creating MockSessionDescription.
119 MockPeerConnectionDependencyFactory* dependency_factory_;
121 std::string stream_label_;
122 rtc::scoped_refptr<MockStreamCollection> local_streams_;
123 rtc::scoped_refptr<MockStreamCollection> remote_streams_;
124 scoped_ptr<webrtc::SessionDescriptionInterface> local_desc_;
125 scoped_ptr<webrtc::SessionDescriptionInterface> remote_desc_;
126 scoped_ptr<webrtc::SessionDescriptionInterface> created_sessiondescription_;
127 bool hint_audio_;
128 bool hint_video_;
129 bool getstats_result_;
130 std::string description_sdp_;
131 std::string sdp_mid_;
132 int sdp_mline_index_;
133 std::string ice_sdp_;
134 webrtc::PeerConnectionObserver* observer_;
136 DISALLOW_COPY_AND_ASSIGN(MockPeerConnectionImpl);
139 } // namespace content
141 #endif // CONTENT_RENDERER_MEDIA_MOCK_PEER_CONNECTION_IMPL_H_