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

Side by Side Diff: webrtc/p2p/client/portallocator_unittest.cc

Issue 1241943002: Fix an NPE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Updated the comments. Created 5 years, 5 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/p2p/client/basicportallocator.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 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 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
11 #include "webrtc/p2p/base/basicpacketsocketfactory.h" 11 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
12 #include "webrtc/p2p/base/constants.h" 12 #include "webrtc/p2p/base/constants.h"
13 #include "webrtc/p2p/base/p2ptransportchannel.h" 13 #include "webrtc/p2p/base/p2ptransportchannel.h"
14 #include "webrtc/p2p/base/testrelayserver.h" 14 #include "webrtc/p2p/base/testrelayserver.h"
15 #include "webrtc/p2p/base/teststunserver.h" 15 #include "webrtc/p2p/base/teststunserver.h"
16 #include "webrtc/p2p/base/testturnserver.h" 16 #include "webrtc/p2p/base/testturnserver.h"
17 #include "webrtc/p2p/client/basicportallocator.h" 17 #include "webrtc/p2p/client/basicportallocator.h"
18 #include "webrtc/p2p/client/httpportallocator.h" 18 #include "webrtc/p2p/client/httpportallocator.h"
19 #include "webrtc/base/fakenetwork.h" 19 #include "webrtc/base/fakenetwork.h"
20 #include "webrtc/base/firewallsocketserver.h" 20 #include "webrtc/base/firewallsocketserver.h"
21 #include "webrtc/base/gunit.h" 21 #include "webrtc/base/gunit.h"
22 #include "webrtc/base/helpers.h" 22 #include "webrtc/base/helpers.h"
23 #include "webrtc/base/ipaddress.h"
23 #include "webrtc/base/logging.h" 24 #include "webrtc/base/logging.h"
24 #include "webrtc/base/natserver.h" 25 #include "webrtc/base/natserver.h"
25 #include "webrtc/base/natsocketfactory.h" 26 #include "webrtc/base/natsocketfactory.h"
26 #include "webrtc/base/network.h" 27 #include "webrtc/base/network.h"
27 #include "webrtc/base/physicalsocketserver.h" 28 #include "webrtc/base/physicalsocketserver.h"
28 #include "webrtc/base/socketaddress.h" 29 #include "webrtc/base/socketaddress.h"
29 #include "webrtc/base/ssladapter.h" 30 #include "webrtc/base/ssladapter.h"
30 #include "webrtc/base/thread.h" 31 #include "webrtc/base/thread.h"
31 #include "webrtc/base/virtualsocketserver.h" 32 #include "webrtc/base/virtualsocketserver.h"
32 33
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); 1046 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1046 session_->StartGettingPorts(); 1047 session_->StartGettingPorts();
1047 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout); 1048 ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
1048 EXPECT_EQ(4U, ports_.size()); 1049 EXPECT_EQ(4U, ports_.size());
1049 1050
1050 auto it = ports_.begin(); 1051 auto it = ports_.begin();
1051 for (; it != ports_.end(); ++it) { 1052 for (; it != ports_.end(); ++it) {
1052 (reinterpret_cast<cricket::Port*>(*it))->Destroy(); 1053 (reinterpret_cast<cricket::Port*>(*it))->Destroy();
1053 } 1054 }
1054 } 1055 }
1056
1057 class AllocationSequenceForTest : public cricket::AllocationSequence {
1058 public:
1059 AllocationSequenceForTest(cricket::BasicPortAllocatorSession* session,
1060 rtc::Network* network,
1061 cricket::PortConfiguration* config,
1062 uint32 flags)
1063 : cricket::AllocationSequence(session, network, config, flags) {}
1064 using cricket::AllocationSequence::CreateTurnPort;
1065 };
1066
1067 TEST_F(PortAllocatorTest, TestCreateTurnPortWithNullSocket) {
1068 EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
1069 session_->StartGettingPorts();
1070
1071 cricket::ServerAddresses stun_servers;
1072 stun_servers.insert(kStunAddr);
1073 cricket::PortConfiguration config(stun_servers, kIceUfrag0, kIcePwd0);
1074 rtc::Network network1("test_eth0", "Test Network Adapter 1",
1075 rtc::IPAddress(0x12345600U), 24);
1076 uint32 flag = cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
1077 AllocationSequenceForTest alloc_sequence(
1078 static_cast<cricket::BasicPortAllocatorSession*>(session_.get()),
1079 &network1, &config, flag);
1080 // This simply tests it will not crash if udp_socket_ in the
1081 // AllocationSequence is null, which is chosen in the constructor.
1082 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
1083 relay_server.ports.push_back(
1084 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false));
1085 alloc_sequence.CreateTurnPort(relay_server);
1086 }
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698