OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 } | 2251 } |
2252 | 2252 |
2253 // Test that local candidates are added to the local session description and | 2253 // Test that local candidates are added to the local session description and |
2254 // that they are retained if the local session description is changed. And if | 2254 // that they are retained if the local session description is changed. And if |
2255 // continual gathering is enabled, they are removed from the local session | 2255 // continual gathering is enabled, they are removed from the local session |
2256 // description when the network is down. | 2256 // description when the network is down. |
2257 TEST_F(WebRtcSessionTest, | 2257 TEST_F(WebRtcSessionTest, |
2258 TestLocalCandidatesAddedAndRemovedIfGatherContinually) { | 2258 TestLocalCandidatesAddedAndRemovedIfGatherContinually) { |
2259 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2259 AddInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
2260 Init(); | 2260 Init(); |
| 2261 // Enable Continual Gathering. |
| 2262 cricket::IceConfig config; |
| 2263 config.continual_gathering_policy = cricket::GATHER_CONTINUALLY; |
| 2264 session_->SetIceConfig(config); |
2261 SendAudioVideoStream1(); | 2265 SendAudioVideoStream1(); |
2262 CreateAndSetRemoteOfferAndLocalAnswer(); | 2266 CreateAndSetRemoteOfferAndLocalAnswer(); |
2263 | 2267 |
2264 const SessionDescriptionInterface* local_desc = session_->local_description(); | 2268 const SessionDescriptionInterface* local_desc = session_->local_description(); |
2265 const IceCandidateCollection* candidates = | 2269 const IceCandidateCollection* candidates = |
2266 local_desc->candidates(kMediaContentIndex0); | 2270 local_desc->candidates(kMediaContentIndex0); |
2267 ASSERT_TRUE(candidates != NULL); | 2271 ASSERT_TRUE(candidates != NULL); |
2268 EXPECT_EQ(0u, candidates->count()); | 2272 EXPECT_EQ(0u, candidates->count()); |
2269 | 2273 |
2270 EXPECT_TRUE_WAIT(observer_.oncandidatesready_, kIceCandidatesTimeout); | 2274 // Since we're using continual gathering, we won't get "gathering done". |
| 2275 EXPECT_EQ_WAIT(2u, candidates->count(), kIceCandidatesTimeout); |
2271 | 2276 |
2272 local_desc = session_->local_description(); | 2277 local_desc = session_->local_description(); |
2273 candidates = local_desc->candidates(kMediaContentIndex0); | 2278 candidates = local_desc->candidates(kMediaContentIndex0); |
2274 ASSERT_TRUE(candidates != NULL); | 2279 ASSERT_TRUE(candidates != NULL); |
2275 EXPECT_LT(0u, candidates->count()); | 2280 EXPECT_LT(0u, candidates->count()); |
2276 candidates = local_desc->candidates(1); | 2281 candidates = local_desc->candidates(1); |
2277 ASSERT_TRUE(candidates != NULL); | 2282 ASSERT_TRUE(candidates != NULL); |
2278 EXPECT_EQ(0u, candidates->count()); | 2283 EXPECT_EQ(0u, candidates->count()); |
2279 | 2284 |
2280 // Update the session descriptions. | 2285 // Update the session descriptions. |
2281 SendAudioVideoStream1(); | 2286 SendAudioVideoStream1(); |
2282 CreateAndSetRemoteOfferAndLocalAnswer(); | 2287 CreateAndSetRemoteOfferAndLocalAnswer(); |
2283 | 2288 |
2284 local_desc = session_->local_description(); | 2289 local_desc = session_->local_description(); |
2285 candidates = local_desc->candidates(kMediaContentIndex0); | 2290 candidates = local_desc->candidates(kMediaContentIndex0); |
2286 ASSERT_TRUE(candidates != NULL); | 2291 ASSERT_TRUE(candidates != NULL); |
2287 EXPECT_LT(0u, candidates->count()); | 2292 EXPECT_LT(0u, candidates->count()); |
2288 candidates = local_desc->candidates(1); | 2293 candidates = local_desc->candidates(1); |
2289 ASSERT_TRUE(candidates != NULL); | 2294 ASSERT_TRUE(candidates != NULL); |
2290 EXPECT_EQ(0u, candidates->count()); | 2295 EXPECT_EQ(0u, candidates->count()); |
2291 | 2296 |
2292 candidates = local_desc->candidates(kMediaContentIndex0); | 2297 candidates = local_desc->candidates(kMediaContentIndex0); |
2293 size_t num_local_candidates = candidates->count(); | 2298 size_t num_local_candidates = candidates->count(); |
2294 // Enable Continual Gathering | |
2295 cricket::IceConfig config; | |
2296 config.continual_gathering_policy = cricket::GATHER_CONTINUALLY; | |
2297 session_->SetIceConfig(config); | |
2298 // Bring down the network interface to trigger candidate removals. | 2299 // Bring down the network interface to trigger candidate removals. |
2299 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); | 2300 RemoveInterface(rtc::SocketAddress(kClientAddrHost1, kClientAddrPort)); |
2300 // Verify that all local candidates are removed. | 2301 // Verify that all local candidates are removed. |
2301 EXPECT_EQ(0, observer_.num_candidates_removed_); | 2302 EXPECT_EQ(0, observer_.num_candidates_removed_); |
2302 EXPECT_EQ_WAIT(num_local_candidates, observer_.num_candidates_removed_, | 2303 EXPECT_EQ_WAIT(num_local_candidates, observer_.num_candidates_removed_, |
2303 kIceCandidatesTimeout); | 2304 kIceCandidatesTimeout); |
2304 EXPECT_EQ_WAIT(0u, candidates->count(), kIceCandidatesTimeout); | 2305 EXPECT_EQ_WAIT(0u, candidates->count(), kIceCandidatesTimeout); |
2305 } | 2306 } |
2306 | 2307 |
2307 // Tests that if continual gathering is disabled, local candidates won't be | 2308 // Tests that if continual gathering is disabled, local candidates won't be |
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4345 } | 4346 } |
4346 | 4347 |
4347 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4348 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4348 // currently fails because upon disconnection and reconnection OnIceComplete is | 4349 // currently fails because upon disconnection and reconnection OnIceComplete is |
4349 // called more than once without returning to IceGatheringGathering. | 4350 // called more than once without returning to IceGatheringGathering. |
4350 | 4351 |
4351 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4352 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4352 WebRtcSessionTest, | 4353 WebRtcSessionTest, |
4353 testing::Values(ALREADY_GENERATED, | 4354 testing::Values(ALREADY_GENERATED, |
4354 DTLS_IDENTITY_STORE)); | 4355 DTLS_IDENTITY_STORE)); |
OLD | NEW |