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

Unified Diff: webrtc/p2p/base/port_unittest.cc

Issue 1815473002: Add 16-bit network id to the candidate signaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Remove the old NETWORK_COST attribute. Created 4 years, 9 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/base/port.cc ('k') | webrtc/p2p/base/stun.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index be5ced97c0b0085170c30dc0715fb3998fb348e5..d27be2944275995d46b9433328f54d248831be4b 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/p2p/base/port_unittest.cc
@@ -559,6 +559,10 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
}
}
+ void SetNetworkType(rtc::AdapterType adapter_type) {
+ network_.set_type(adapter_type);
+ }
+
void TestCrossFamilyPorts(int type);
void ExpectPortsCanConnect(bool can_connect, Port* p1, Port* p2);
@@ -1757,6 +1761,51 @@ TEST_F(PortTest, TestUseCandidateAttribute) {
ASSERT_TRUE(use_candidate_attr != NULL);
}
+TEST_F(PortTest, TestNetworkInfoAttribute) {
+ rtc::scoped_ptr<TestPort> lport(
+ CreateTestPort(kLocalAddr1, "lfrag", "lpass"));
+ // Set the network type for rport to be cellular so its cost will be 999.
+ SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR);
+ rtc::scoped_ptr<TestPort> rport(
+ CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
+ lport->SetIceRole(cricket::ICEROLE_CONTROLLING);
+ lport->SetIceTiebreaker(kTiebreaker1);
+ rport->SetIceRole(cricket::ICEROLE_CONTROLLED);
+ rport->SetIceTiebreaker(kTiebreaker2);
+
+ uint16_t lnetwork_id = 9;
+ lport->Network()->set_id(lnetwork_id);
+ // Send a fake ping from lport to rport.
+ lport->PrepareAddress();
+ rport->PrepareAddress();
+ Connection* lconn =
+ lport->CreateConnection(rport->Candidates()[0], Port::ORIGIN_MESSAGE);
+ lconn->Ping(0);
+ ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000);
+ IceMessage* msg = lport->last_stun_msg();
+ const StunUInt32Attribute* network_info_attr =
+ msg->GetUInt32(STUN_ATTR_NETWORK_INFO);
+ ASSERT_TRUE(network_info_attr != NULL);
+ uint32_t network_info = network_info_attr->value();
+ EXPECT_EQ(lnetwork_id, network_info >> 16);
+ // Default network cost is 0.
+ EXPECT_EQ(0U, network_info & 0xFFFF);
+
+ // Send a fake ping from rport to lport.
+ uint16_t rnetwork_id = 8;
+ rport->Network()->set_id(rnetwork_id);
+ Connection* rconn =
+ rport->CreateConnection(lport->Candidates()[0], Port::ORIGIN_MESSAGE);
+ rconn->Ping(0);
+ ASSERT_TRUE_WAIT(rport->last_stun_msg() != NULL, 1000);
+ msg = rport->last_stun_msg();
+ network_info_attr = msg->GetUInt32(STUN_ATTR_NETWORK_INFO);
+ ASSERT_TRUE(network_info_attr != NULL);
+ network_info = network_info_attr->value();
+ EXPECT_EQ(rnetwork_id, network_info >> 16);
+ EXPECT_EQ(cricket::kMaxNetworkCost, network_info & 0xFFFF);
+}
+
// Test handling STUN messages.
TEST_F(PortTest, TestHandleStunMessage) {
// Our port will act as the "remote" port.
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/p2p/base/stun.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698