Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1669993003: Remove deprecated PeerConnectionObserver::OnStateChange and OnIceComplete (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed tests. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | webrtc/examples/peerconnection/client/conductor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE }; 172 enum RTCCertificateGenerationMethod { ALREADY_GENERATED, DTLS_IDENTITY_STORE };
173 173
174 class MockIceObserver : public webrtc::IceObserver { 174 class MockIceObserver : public webrtc::IceObserver {
175 public: 175 public:
176 MockIceObserver() 176 MockIceObserver()
177 : oncandidatesready_(false), 177 : oncandidatesready_(false),
178 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 178 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
179 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { 179 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) {
180 } 180 }
181 181
182 virtual void OnIceConnectionChange( 182 void OnIceConnectionChange(
183 PeerConnectionInterface::IceConnectionState new_state) { 183 PeerConnectionInterface::IceConnectionState new_state) override {
184 ice_connection_state_ = new_state; 184 ice_connection_state_ = new_state;
185 } 185 }
186 virtual void OnIceGatheringChange( 186 void OnIceGatheringChange(
187 PeerConnectionInterface::IceGatheringState new_state) { 187 PeerConnectionInterface::IceGatheringState new_state) override {
188 // We can never transition back to "new". 188 // We can never transition back to "new".
189 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state); 189 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, new_state);
190 ice_gathering_state_ = new_state; 190 ice_gathering_state_ = new_state;
191 191 oncandidatesready_ =
192 // oncandidatesready_ really means "ICE gathering is complete". 192 new_state == PeerConnectionInterface::kIceGatheringComplete;
193 // This if statement ensures that this value remains correct when we
194 // transition from kIceGatheringComplete to kIceGatheringGathering.
195 if (new_state == PeerConnectionInterface::kIceGatheringGathering) {
196 oncandidatesready_ = false;
197 }
198 } 193 }
199 194
200 // Found a new candidate. 195 // Found a new candidate.
201 virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { 196 void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override {
202 switch (candidate->sdp_mline_index()) { 197 switch (candidate->sdp_mline_index()) {
203 case kMediaContentIndex0: 198 case kMediaContentIndex0:
204 mline_0_candidates_.push_back(candidate->candidate()); 199 mline_0_candidates_.push_back(candidate->candidate());
205 break; 200 break;
206 case kMediaContentIndex1: 201 case kMediaContentIndex1:
207 mline_1_candidates_.push_back(candidate->candidate()); 202 mline_1_candidates_.push_back(candidate->candidate());
208 break; 203 break;
209 default: 204 default:
210 ASSERT(false); 205 ASSERT(false);
211 } 206 }
212 207
213 // The ICE gathering state should always be Gathering when a candidate is 208 // The ICE gathering state should always be Gathering when a candidate is
214 // received (or possibly Completed in the case of the final candidate). 209 // received (or possibly Completed in the case of the final candidate).
215 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, ice_gathering_state_); 210 EXPECT_NE(PeerConnectionInterface::kIceGatheringNew, ice_gathering_state_);
216 } 211 }
217 212
218 // TODO(bemasc): Remove this once callers transition to OnIceGatheringChange.
219 virtual void OnIceComplete() {
220 EXPECT_FALSE(oncandidatesready_);
221 oncandidatesready_ = true;
222
223 // OnIceGatheringChange(IceGatheringCompleted) and OnIceComplete() should
224 // be called approximately simultaneously. For ease of testing, this
225 // check additionally requires that they be called in the above order.
226 EXPECT_EQ(PeerConnectionInterface::kIceGatheringComplete,
227 ice_gathering_state_);
228 }
229
230 bool oncandidatesready_; 213 bool oncandidatesready_;
231 std::vector<cricket::Candidate> mline_0_candidates_; 214 std::vector<cricket::Candidate> mline_0_candidates_;
232 std::vector<cricket::Candidate> mline_1_candidates_; 215 std::vector<cricket::Candidate> mline_1_candidates_;
233 PeerConnectionInterface::IceConnectionState ice_connection_state_; 216 PeerConnectionInterface::IceConnectionState ice_connection_state_;
234 PeerConnectionInterface::IceGatheringState ice_gathering_state_; 217 PeerConnectionInterface::IceGatheringState ice_gathering_state_;
235 }; 218 };
236 219
237 class WebRtcSessionForTest : public webrtc::WebRtcSession { 220 class WebRtcSessionForTest : public webrtc::WebRtcSession {
238 public: 221 public:
239 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller, 222 WebRtcSessionForTest(webrtc::MediaControllerInterface* media_controller,
(...skipping 4070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4310 } 4293 }
4311 4294
4312 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4295 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4313 // currently fails because upon disconnection and reconnection OnIceComplete is 4296 // currently fails because upon disconnection and reconnection OnIceComplete is
4314 // called more than once without returning to IceGatheringGathering. 4297 // called more than once without returning to IceGatheringGathering.
4315 4298
4316 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4299 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4317 WebRtcSessionTest, 4300 WebRtcSessionTest,
4318 testing::Values(ALREADY_GENERATED, 4301 testing::Values(ALREADY_GENERATED,
4319 DTLS_IDENTITY_STORE)); 4302 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « talk/app/webrtc/webrtcsession.cc ('k') | webrtc/examples/peerconnection/client/conductor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698