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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/client/basicportallocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/client/portallocator_unittest.cc
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc
index 017c37a6f6e673cee11f721905fdbe93761b58ac..c6807a01f4bf41432d9ea443d697514093f31ff1 100644
--- a/webrtc/p2p/client/portallocator_unittest.cc
+++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -20,6 +20,7 @@
#include "webrtc/base/firewallsocketserver.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
+#include "webrtc/base/ipaddress.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/natsocketfactory.h"
@@ -1052,3 +1053,34 @@ TEST_F(PortAllocatorTest, TestDestroyPortsNonSharedSockets) {
(reinterpret_cast<cricket::Port*>(*it))->Destroy();
}
}
+
+class AllocationSequenceForTest : public cricket::AllocationSequence {
+ public:
+ AllocationSequenceForTest(cricket::BasicPortAllocatorSession* session,
+ rtc::Network* network,
+ cricket::PortConfiguration* config,
+ uint32 flags)
+ : cricket::AllocationSequence(session, network, config, flags) {}
+ using cricket::AllocationSequence::CreateTurnPort;
+};
+
+TEST_F(PortAllocatorTest, TestCreateTurnPortWithNullSocket) {
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+
+ cricket::ServerAddresses stun_servers;
+ stun_servers.insert(kStunAddr);
+ cricket::PortConfiguration config(stun_servers, kIceUfrag0, kIcePwd0);
+ rtc::Network network1("test_eth0", "Test Network Adapter 1",
+ rtc::IPAddress(0x12345600U), 24);
+ uint32 flag = cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET;
+ AllocationSequenceForTest alloc_sequence(
+ static_cast<cricket::BasicPortAllocatorSession*>(session_.get()),
+ &network1, &config, flag);
+ // This simply tests it will not crash if udp_socket_ in the
+ // AllocationSequence is null, which is chosen in the constructor.
+ cricket::RelayServerConfig relay_server(cricket::RELAY_TURN);
+ relay_server.ports.push_back(
+ cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP, false));
+ alloc_sequence.CreateTurnPort(relay_server);
+}
« 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