OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/renderer/media/mock_media_stream_dependency_factory.h" |
5 #include "content/renderer/media/mock_peer_connection_impl.h" | 6 #include "content/renderer/media/mock_peer_connection_impl.h" |
6 | 7 |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 | 11 |
11 namespace webrtc { | 12 namespace webrtc { |
12 | 13 |
13 class MockStreamCollection : public StreamCollectionInterface { | 14 class MockStreamCollection : public StreamCollectionInterface { |
14 public: | 15 public: |
(...skipping 14 matching lines...) Expand all Loading... |
29 streams_.push_back(stream); | 30 streams_.push_back(stream); |
30 } | 31 } |
31 | 32 |
32 protected: | 33 protected: |
33 virtual ~MockStreamCollection() {} | 34 virtual ~MockStreamCollection() {} |
34 | 35 |
35 private: | 36 private: |
36 std::vector<MediaStreamInterface*> streams_; | 37 std::vector<MediaStreamInterface*> streams_; |
37 }; | 38 }; |
38 | 39 |
39 MockPeerConnectionImpl::MockPeerConnectionImpl() | 40 const char MockPeerConnectionImpl::kDummyOffer[] = "dummy offer"; |
40 : stream_changes_committed_(false), | 41 |
41 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>) { | 42 MockPeerConnectionImpl::MockPeerConnectionImpl( |
| 43 MockMediaStreamDependencyFactory* factory) |
| 44 : dependency_factory_(factory), |
| 45 stream_changes_committed_(false), |
| 46 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
| 47 hint_audio_(false), |
| 48 hint_video_(false), |
| 49 action_(kAnswer), |
| 50 ice_options_(kOnlyRelay), |
| 51 ready_state_(kNew) { |
42 } | 52 } |
43 | 53 |
44 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 54 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
45 | 55 |
46 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { | 56 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { |
47 signaling_message_ = msg; | 57 signaling_message_ = msg; |
48 } | 58 } |
49 | 59 |
50 bool MockPeerConnectionImpl::Send(const std::string& msg) { | 60 bool MockPeerConnectionImpl::Send(const std::string& msg) { |
51 NOTIMPLEMENTED(); | 61 NOTIMPLEMENTED(); |
(...skipping 23 matching lines...) Expand all Loading... |
75 stream_changes_committed_ = true; | 85 stream_changes_committed_ = true; |
76 } | 86 } |
77 | 87 |
78 void MockPeerConnectionImpl::Close() { | 88 void MockPeerConnectionImpl::Close() { |
79 signaling_message_.clear(); | 89 signaling_message_.clear(); |
80 stream_label_.clear(); | 90 stream_label_.clear(); |
81 stream_changes_committed_ = false; | 91 stream_changes_committed_ = false; |
82 } | 92 } |
83 | 93 |
84 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 94 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
85 NOTIMPLEMENTED(); | 95 return ready_state_; |
86 return kNew; | |
87 } | 96 } |
88 | 97 |
89 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { | 98 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { |
90 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
91 return kSdpNew; | 100 return kSdpNew; |
92 } | 101 } |
93 | 102 |
94 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 103 bool MockPeerConnectionImpl::StartIce(IceOptions options) { |
95 NOTIMPLEMENTED(); | 104 ice_options_ = options; |
96 return false; | 105 return true; |
97 } | 106 } |
98 | 107 |
99 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( | 108 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( |
100 const webrtc::MediaHints& hints) { | 109 const webrtc::MediaHints& hints) { |
101 NOTIMPLEMENTED(); | 110 hint_audio_ = hints.has_audio(); |
102 return NULL; | 111 hint_video_ = hints.has_video(); |
| 112 return dependency_factory_->CreateSessionDescription(kDummyOffer); |
103 } | 113 } |
104 | 114 |
105 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( | 115 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( |
106 const webrtc::MediaHints& hints, | 116 const webrtc::MediaHints& hints, |
107 const webrtc::SessionDescriptionInterface* offer) { | 117 const webrtc::SessionDescriptionInterface* offer) { |
108 NOTIMPLEMENTED(); | 118 hint_audio_ = hints.has_audio(); |
109 return NULL; | 119 hint_video_ = hints.has_video(); |
| 120 offer->ToString(&description_sdp_); |
| 121 return dependency_factory_->CreateSessionDescription(description_sdp_); |
110 } | 122 } |
111 | 123 |
112 bool MockPeerConnectionImpl::SetLocalDescription( | 124 bool MockPeerConnectionImpl::SetLocalDescription( |
113 Action action, | 125 Action action, |
114 webrtc::SessionDescriptionInterface* desc) { | 126 webrtc::SessionDescriptionInterface* desc) { |
115 NOTIMPLEMENTED(); | 127 action_ = action; |
116 return false; | 128 return desc->ToString(&description_sdp_); |
117 } | 129 } |
118 | 130 |
119 bool MockPeerConnectionImpl::SetRemoteDescription( | 131 bool MockPeerConnectionImpl::SetRemoteDescription( |
120 Action action, | 132 Action action, |
121 webrtc::SessionDescriptionInterface* desc) { | 133 webrtc::SessionDescriptionInterface* desc) { |
122 NOTIMPLEMENTED(); | 134 action_ = action; |
123 return false; | 135 return desc->ToString(&description_sdp_); |
124 } | 136 } |
125 | 137 |
126 bool MockPeerConnectionImpl::ProcessIceMessage( | 138 bool MockPeerConnectionImpl::ProcessIceMessage( |
127 const webrtc::IceCandidateInterface* ice_candidate) { | 139 const webrtc::IceCandidateInterface* ice_candidate) { |
128 NOTIMPLEMENTED(); | 140 ice_label_ = ice_candidate->label(); |
129 return false; | 141 return ice_candidate->ToString(&ice_sdp_); |
130 } | 142 } |
131 | 143 |
132 const webrtc::SessionDescriptionInterface* | 144 const webrtc::SessionDescriptionInterface* |
133 MockPeerConnectionImpl::local_description() | 145 MockPeerConnectionImpl::local_description() |
134 const { | 146 const { |
135 NOTIMPLEMENTED(); | 147 return dependency_factory_->CreateSessionDescription(description_sdp_); |
136 return NULL; | |
137 } | 148 } |
138 | 149 |
139 const webrtc::SessionDescriptionInterface* | 150 const webrtc::SessionDescriptionInterface* |
140 MockPeerConnectionImpl::remote_description() | 151 MockPeerConnectionImpl::remote_description() |
141 const { | 152 const { |
142 NOTIMPLEMENTED(); | 153 return dependency_factory_->CreateSessionDescription(description_sdp_); |
143 return NULL; | |
144 } | 154 } |
145 | 155 |
146 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { | 156 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { |
147 remote_streams_->AddStream(stream); | 157 remote_streams_->AddStream(stream); |
148 } | 158 } |
149 | 159 |
150 } // namespace webrtc | 160 } // namespace webrtc |
OLD | NEW |