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 MockPeerConnectionImpl::MockPeerConnectionImpl( |
40 : stream_changes_committed_(false), | 41 MockMediaStreamDependencyFactory* factory) |
41 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>) { | 42 : kDummyOffer("dummy offer"), |
| 43 dependency_factory_(factory), |
| 44 stream_changes_committed_(false), |
| 45 remote_streams_(new talk_base::RefCountedObject<MockStreamCollection>), |
| 46 hint_audio_(false), |
| 47 hint_video_(false), |
| 48 action_(kAnswer), |
| 49 ice_options_(kOnlyRelay), |
| 50 ready_state_(kNew) { |
42 } | 51 } |
43 | 52 |
44 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} | 53 MockPeerConnectionImpl::~MockPeerConnectionImpl() {} |
45 | 54 |
46 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { | 55 void MockPeerConnectionImpl::ProcessSignalingMessage(const std::string& msg) { |
47 signaling_message_ = msg; | 56 signaling_message_ = msg; |
48 } | 57 } |
49 | 58 |
50 bool MockPeerConnectionImpl::Send(const std::string& msg) { | 59 bool MockPeerConnectionImpl::Send(const std::string& msg) { |
51 NOTIMPLEMENTED(); | 60 NOTIMPLEMENTED(); |
(...skipping 23 matching lines...) Expand all Loading... |
75 stream_changes_committed_ = true; | 84 stream_changes_committed_ = true; |
76 } | 85 } |
77 | 86 |
78 void MockPeerConnectionImpl::Close() { | 87 void MockPeerConnectionImpl::Close() { |
79 signaling_message_.clear(); | 88 signaling_message_.clear(); |
80 stream_label_.clear(); | 89 stream_label_.clear(); |
81 stream_changes_committed_ = false; | 90 stream_changes_committed_ = false; |
82 } | 91 } |
83 | 92 |
84 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { | 93 MockPeerConnectionImpl::ReadyState MockPeerConnectionImpl::ready_state() { |
85 NOTIMPLEMENTED(); | 94 return ready_state_; |
86 return kNew; | |
87 } | 95 } |
88 | 96 |
89 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { | 97 MockPeerConnectionImpl::SdpState MockPeerConnectionImpl::sdp_state() { |
90 NOTIMPLEMENTED(); | 98 NOTIMPLEMENTED(); |
91 return kSdpNew; | 99 return kSdpNew; |
92 } | 100 } |
93 | 101 |
94 bool MockPeerConnectionImpl::StartIce(IceOptions options) { | 102 bool MockPeerConnectionImpl::StartIce(IceOptions options) { |
95 NOTIMPLEMENTED(); | 103 ice_options_ = options; |
96 return false; | 104 return true; |
97 } | 105 } |
98 | 106 |
99 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( | 107 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateOffer( |
100 const webrtc::MediaHints& hints) { | 108 const webrtc::MediaHints& hints) { |
101 NOTIMPLEMENTED(); | 109 hint_audio_ = hints.has_audio(); |
102 return NULL; | 110 hint_video_ = hints.has_video(); |
| 111 return dependency_factory_->CreateSessionDescription(kDummyOffer); |
103 } | 112 } |
104 | 113 |
105 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( | 114 webrtc::SessionDescriptionInterface* MockPeerConnectionImpl::CreateAnswer( |
106 const webrtc::MediaHints& hints, | 115 const webrtc::MediaHints& hints, |
107 const webrtc::SessionDescriptionInterface* offer) { | 116 const webrtc::SessionDescriptionInterface* offer) { |
108 NOTIMPLEMENTED(); | 117 hint_audio_ = hints.has_audio(); |
109 return NULL; | 118 hint_video_ = hints.has_video(); |
| 119 offer->ToString(&description_sdp_); |
| 120 return dependency_factory_->CreateSessionDescription(description_sdp_); |
110 } | 121 } |
111 | 122 |
112 bool MockPeerConnectionImpl::SetLocalDescription( | 123 bool MockPeerConnectionImpl::SetLocalDescription( |
113 Action action, | 124 Action action, |
114 webrtc::SessionDescriptionInterface* desc) { | 125 webrtc::SessionDescriptionInterface* desc) { |
115 NOTIMPLEMENTED(); | 126 action_ = action; |
116 return false; | 127 return desc->ToString(&description_sdp_); |
117 } | 128 } |
118 | 129 |
119 bool MockPeerConnectionImpl::SetRemoteDescription( | 130 bool MockPeerConnectionImpl::SetRemoteDescription( |
120 Action action, | 131 Action action, |
121 webrtc::SessionDescriptionInterface* desc) { | 132 webrtc::SessionDescriptionInterface* desc) { |
122 NOTIMPLEMENTED(); | 133 action_ = action; |
123 return false; | 134 return desc->ToString(&description_sdp_); |
124 } | 135 } |
125 | 136 |
126 bool MockPeerConnectionImpl::ProcessIceMessage( | 137 bool MockPeerConnectionImpl::ProcessIceMessage( |
127 const webrtc::IceCandidateInterface* ice_candidate) { | 138 const webrtc::IceCandidateInterface* ice_candidate) { |
128 NOTIMPLEMENTED(); | 139 ice_label_ = ice_candidate->label(); |
129 return false; | 140 return ice_candidate->ToString(&ice_sdp_); |
130 } | 141 } |
131 | 142 |
132 const webrtc::SessionDescriptionInterface* | 143 const webrtc::SessionDescriptionInterface* |
133 MockPeerConnectionImpl::local_description() | 144 MockPeerConnectionImpl::local_description() |
134 const { | 145 const { |
135 NOTIMPLEMENTED(); | 146 return dependency_factory_->CreateSessionDescription(description_sdp_); |
136 return NULL; | |
137 } | 147 } |
138 | 148 |
139 const webrtc::SessionDescriptionInterface* | 149 const webrtc::SessionDescriptionInterface* |
140 MockPeerConnectionImpl::remote_description() | 150 MockPeerConnectionImpl::remote_description() |
141 const { | 151 const { |
142 NOTIMPLEMENTED(); | 152 return dependency_factory_->CreateSessionDescription(description_sdp_); |
143 return NULL; | |
144 } | 153 } |
145 | 154 |
146 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { | 155 void MockPeerConnectionImpl::AddRemoteStream(MediaStreamInterface* stream) { |
147 remote_streams_->AddStream(stream); | 156 remote_streams_->AddStream(stream); |
148 } | 157 } |
149 | 158 |
150 } // namespace webrtc | 159 } // namespace webrtc |
OLD | NEW |