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

Unified Diff: webrtc/p2p/client/portallocator_unittest.cc

Issue 1361183004: When doing DisableEquivalentPhases, exclude those AllocationSequences (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 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 9ea22dd189487192cb56152c5117f102939454b0..28938075756328e5d9a2cdf319195101f4eb6f08 100644
--- a/webrtc/p2p/client/portallocator_unittest.cc
+++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -111,12 +111,18 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
void AddInterface(const SocketAddress& addr) {
network_manager_.AddInterface(addr);
}
+ void AddInterface(const SocketAddress& addr, const std::string& if_name) {
+ network_manager_.AddInterface(addr, if_name);
+ }
void AddInterfaceAsDefaultRoute(const SocketAddress& addr) {
AddInterface(addr);
// When a binding comes from the any address, the |addr| will be used as the
// srflx address.
vss_->SetDefaultRoute(addr.ipaddr());
}
+ void RemoveInterface(const SocketAddress& addr) {
+ network_manager_.RemoveInterface(addr);
+ }
bool SetPortRange(int min_port, int max_port) {
return allocator_->SetPortRange(min_port, max_port);
}
@@ -432,6 +438,61 @@ TEST_F(PortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) {
EXPECT_TRUE(candidate_allocation_done_);
}
+// Test that when the same network interface is brought down and up, the
+// port allocator session will restart a new allocation sequence if
+// it is not stopped.
+TEST_F(PortAllocatorTest, TestSameNetworkDownAndUpWhenSessionNotStopped) {
+ std::string if_name("test_net0");
+ AddInterface(kClientAddr, if_name);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+ ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(4U, ports_.size());
+ EXPECT_TRUE(candidate_allocation_done_);
+ candidate_allocation_done_ = false;
+ candidates_.clear();
+ ports_.clear();
+
+ RemoveInterface(kClientAddr);
+ ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(0U, ports_.size());
+ EXPECT_FALSE(candidate_allocation_done_);
+
+ // When the same interfaces are added again, new candidates/ports should be
+ // generated.
+ AddInterface(kClientAddr, if_name);
+ ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(4U, ports_.size());
+ EXPECT_TRUE(candidate_allocation_done_);
+}
+
+// Test that when the same network interface is brought down and up, the
+// port allocator session will not restart a new allocation sequence if
+// it is stopped.
+TEST_F(PortAllocatorTest, TestSameNetworkDownAndUpWhenSessionStopped) {
+ std::string if_name("test_net0");
+ AddInterface(kClientAddr, if_name);
+ EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP));
+ session_->StartGettingPorts();
+ ASSERT_EQ_WAIT(7U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(4U, ports_.size());
+ EXPECT_TRUE(candidate_allocation_done_);
+ session_->StopGettingPorts();
+ candidates_.clear();
+ ports_.clear();
+
+ RemoveInterface(kClientAddr);
+ ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(0U, ports_.size());
+
+ // When the same interfaces are added again, new candidates/ports should not
+ // be generated because the session has stopped.
+ AddInterface(kClientAddr, if_name);
+ ASSERT_EQ_WAIT(0U, candidates_.size(), kDefaultAllocationTimeout);
+ EXPECT_EQ(0U, ports_.size());
+ EXPECT_TRUE(candidate_allocation_done_);
+}
+
// Verify candidates with default step delay of 1sec.
TEST_F(PortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) {
AddInterface(kClientAddr);
« 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