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

Side by Side Diff: webrtc/pc/peerconnectioninterface_unittest.cc

Issue 2985653003: Add "max_ipv6_networks" field to RTCConfiguration. (Closed)
Patch Set: Rebase Created 3 years, 4 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 | « webrtc/pc/peerconnection.cc ('k') | no next file » | 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 * 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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 static_cast<const cricket::FakePortAllocatorSession*>( 1278 static_cast<const cricket::FakePortAllocatorSession*>(
1279 port_allocator_->GetPooledSession()); 1279 port_allocator_->GetPooledSession());
1280 ASSERT_NE(nullptr, session); 1280 ASSERT_NE(nullptr, session);
1281 EXPECT_EQ(1UL, session->stun_servers().size()); 1281 EXPECT_EQ(1UL, session->stun_servers().size());
1282 EXPECT_EQ(0U, session->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6); 1282 EXPECT_EQ(0U, session->flags() & cricket::PORTALLOCATOR_ENABLE_IPV6);
1283 EXPECT_LT(0U, session->flags() & cricket::PORTALLOCATOR_DISABLE_TCP); 1283 EXPECT_LT(0U, session->flags() & cricket::PORTALLOCATOR_DISABLE_TCP);
1284 EXPECT_LT(0U, 1284 EXPECT_LT(0U,
1285 session->flags() & cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS); 1285 session->flags() & cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS);
1286 } 1286 }
1287 1287
1288 // Test that network-related RTCConfiguration members are applied to the
1289 // PortAllocator when CreatePeerConnection is called. Specifically:
1290 // - disable_ipv6_on_wifi
1291 // - max_ipv6_networks
1292 // - tcp_candidate_policy
1293 // - candidate_network_policy
1294 // - prune_turn_ports
1295 //
1296 // Note that the candidate filter (RTCConfiguration::type) is already tested
1297 // above.
1298 TEST_F(PeerConnectionInterfaceTest,
1299 CreatePeerConnectionAppliesNetworkConfigToPortAllocator) {
1300 // Create fake port allocator.
1301 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
1302 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
1303 cricket::FakePortAllocator* raw_port_allocator = port_allocator.get();
1304
1305 // Create RTCConfiguration with some network-related fields relevant to
1306 // PortAllocator populated.
1307 PeerConnectionInterface::RTCConfiguration config;
1308 config.disable_ipv6_on_wifi = true;
1309 config.max_ipv6_networks = 10;
1310 config.tcp_candidate_policy =
1311 PeerConnectionInterface::kTcpCandidatePolicyDisabled;
1312 config.candidate_network_policy =
1313 PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
1314 config.prune_turn_ports = true;
1315
1316 // Create the PC factory and PC with the above config.
1317 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory(
1318 webrtc::CreatePeerConnectionFactory(
1319 rtc::Thread::Current(), rtc::Thread::Current(),
1320 rtc::Thread::Current(), nullptr, nullptr, nullptr));
1321 rtc::scoped_refptr<PeerConnectionInterface> pc(
1322 pc_factory->CreatePeerConnection(
1323 config, nullptr, std::move(port_allocator), nullptr, &observer_));
1324
1325 // Now validate that the config fields set above were applied to the
1326 // PortAllocator, as flags or otherwise.
1327 EXPECT_FALSE(raw_port_allocator->flags() &
1328 cricket::PORTALLOCATOR_ENABLE_IPV6_ON_WIFI);
1329 EXPECT_EQ(10, raw_port_allocator->max_ipv6_networks());
1330 EXPECT_TRUE(raw_port_allocator->flags() & cricket::PORTALLOCATOR_DISABLE_TCP);
1331 EXPECT_TRUE(raw_port_allocator->flags() &
1332 cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS);
1333 EXPECT_TRUE(raw_port_allocator->prune_turn_ports());
1334 }
1335
1288 // Test that the PeerConnection initializes the port allocator passed into it, 1336 // Test that the PeerConnection initializes the port allocator passed into it,
1289 // and on the correct thread. 1337 // and on the correct thread.
1290 TEST_F(PeerConnectionInterfaceTest, 1338 TEST_F(PeerConnectionInterfaceTest,
1291 CreatePeerConnectionInitializesPortAllocator) { 1339 CreatePeerConnectionInitializesPortAllocatorOnNetworkThread) {
1292 std::unique_ptr<rtc::Thread> network_thread( 1340 std::unique_ptr<rtc::Thread> network_thread(
1293 rtc::Thread::CreateWithSocketServer()); 1341 rtc::Thread::CreateWithSocketServer());
1294 network_thread->Start(); 1342 network_thread->Start();
1295 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory( 1343 rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory(
1296 webrtc::CreatePeerConnectionFactory( 1344 webrtc::CreatePeerConnectionFactory(
1297 network_thread.get(), rtc::Thread::Current(), rtc::Thread::Current(), 1345 network_thread.get(), rtc::Thread::Current(), rtc::Thread::Current(),
1298 nullptr, nullptr, nullptr)); 1346 nullptr, nullptr, nullptr));
1299 std::unique_ptr<cricket::FakePortAllocator> port_allocator( 1347 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
1300 new cricket::FakePortAllocator(network_thread.get(), nullptr)); 1348 new cricket::FakePortAllocator(network_thread.get(), nullptr));
1301 cricket::FakePortAllocator* raw_port_allocator = port_allocator.get(); 1349 cricket::FakePortAllocator* raw_port_allocator = port_allocator.get();
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3763 observer_.renegotiation_needed_ = false; 3811 observer_.renegotiation_needed_ = false;
3764 3812
3765 stream->RemoveTrack(audio_track); 3813 stream->RemoveTrack(audio_track);
3766 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); 3814 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3767 observer_.renegotiation_needed_ = false; 3815 observer_.renegotiation_needed_ = false;
3768 3816
3769 stream->RemoveTrack(video_track); 3817 stream->RemoveTrack(video_track);
3770 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout); 3818 EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
3771 observer_.renegotiation_needed_ = false; 3819 observer_.renegotiation_needed_ = false;
3772 } 3820 }
OLDNEW
« no previous file with comments | « webrtc/pc/peerconnection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698