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

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 2709293004: RTCIceCandidatePairStats.nominated collected. (Closed)
Patch Set: Updated comment Created 3 years, 10 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/base/port.cc ('k') | webrtc/pc/rtcstats_integrationtest.cc » ('j') | 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 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 rconn->Ping(0); 1781 rconn->Ping(0);
1782 EXPECT_EQ(5U, rconn->stats().sent_ping_requests_total); 1782 EXPECT_EQ(5U, rconn->stats().sent_ping_requests_total);
1783 EXPECT_EQ(3U, rconn->stats().sent_ping_requests_before_first_response); 1783 EXPECT_EQ(3U, rconn->stats().sent_ping_requests_before_first_response);
1784 1784
1785 // Response should include same ping count. 1785 // Response should include same ping count.
1786 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); 1786 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT);
1787 ASSERT_TRUE(retransmit_attr != NULL); 1787 ASSERT_TRUE(retransmit_attr != NULL);
1788 EXPECT_EQ(2U, retransmit_attr->value()); 1788 EXPECT_EQ(2U, retransmit_attr->value());
1789 } 1789 }
1790 1790
1791 TEST_F(PortTest, TestNomination) {
1792 std::unique_ptr<TestPort> lport(
1793 CreateTestPort(kLocalAddr1, "lfrag", "lpass"));
1794 std::unique_ptr<TestPort> rport(
1795 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1796 lport->SetIceRole(cricket::ICEROLE_CONTROLLING);
1797 lport->SetIceTiebreaker(kTiebreaker1);
1798 rport->SetIceRole(cricket::ICEROLE_CONTROLLED);
1799 rport->SetIceTiebreaker(kTiebreaker2);
1800
1801 lport->PrepareAddress();
1802 rport->PrepareAddress();
1803 ASSERT_FALSE(lport->Candidates().empty());
1804 ASSERT_FALSE(rport->Candidates().empty());
1805 Connection* lconn = lport->CreateConnection(rport->Candidates()[0],
1806 Port::ORIGIN_MESSAGE);
1807 Connection* rconn = rport->CreateConnection(lport->Candidates()[0],
1808 Port::ORIGIN_MESSAGE);
1809
1810 // |lconn| is controlling, |rconn| is controlled.
1811 uint32_t nomination = 1234;
1812 lconn->set_nomination(nomination);
1813
1814 EXPECT_FALSE(lconn->nominated());
1815 EXPECT_FALSE(rconn->nominated());
1816 EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
1817 EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
1818
1819 // Send ping (including the nomination value) from |lconn| to |rconn|. This
1820 // should set the remote nomination of |rconn|.
1821 lconn->Ping(0);
1822 ASSERT_TRUE_WAIT(lport->last_stun_msg(), kDefaultTimeout);
1823 ASSERT_TRUE(lport->last_stun_buf());
1824 rconn->OnReadPacket(lport->last_stun_buf()->data<char>(),
1825 lport->last_stun_buf()->size(),
1826 rtc::PacketTime());
1827 EXPECT_EQ(nomination, rconn->remote_nomination());
1828 EXPECT_FALSE(lconn->nominated());
1829 EXPECT_TRUE(rconn->nominated());
1830 EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
1831 EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
1832
1833 // This should result in an acknowledgment sent back from |rconn| to |lconn|,
1834 // updating the acknowledged nomination of |lconn|.
1835 ASSERT_TRUE_WAIT(rport->last_stun_msg(), kDefaultTimeout);
1836 ASSERT_TRUE(rport->last_stun_buf());
1837 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(),
1838 rport->last_stun_buf()->size(),
1839 rtc::PacketTime());
1840 EXPECT_EQ(nomination, lconn->acked_nomination());
1841 EXPECT_TRUE(lconn->nominated());
1842 EXPECT_TRUE(rconn->nominated());
1843 EXPECT_EQ(lconn->nominated(), lconn->stats().nominated);
1844 EXPECT_EQ(rconn->nominated(), rconn->stats().nominated);
1845 }
1846
1791 TEST_F(PortTest, TestUseCandidateAttribute) { 1847 TEST_F(PortTest, TestUseCandidateAttribute) {
1792 std::unique_ptr<TestPort> lport( 1848 std::unique_ptr<TestPort> lport(
1793 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); 1849 CreateTestPort(kLocalAddr1, "lfrag", "lpass"));
1794 std::unique_ptr<TestPort> rport( 1850 std::unique_ptr<TestPort> rport(
1795 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); 1851 CreateTestPort(kLocalAddr2, "rfrag", "rpass"));
1796 lport->SetIceRole(cricket::ICEROLE_CONTROLLING); 1852 lport->SetIceRole(cricket::ICEROLE_CONTROLLING);
1797 lport->SetIceTiebreaker(kTiebreaker1); 1853 lport->SetIceTiebreaker(kTiebreaker1);
1798 rport->SetIceRole(cricket::ICEROLE_CONTROLLED); 1854 rport->SetIceRole(cricket::ICEROLE_CONTROLLED);
1799 rport->SetIceTiebreaker(kTiebreaker2); 1855 rport->SetIceTiebreaker(kTiebreaker2);
1800 1856
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); 2818 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
2763 EXPECT_NE(conn1, conn2); 2819 EXPECT_NE(conn1, conn2);
2764 conn_in_use = port->GetConnection(address); 2820 conn_in_use = port->GetConnection(address);
2765 EXPECT_EQ(conn2, conn_in_use); 2821 EXPECT_EQ(conn2, conn_in_use);
2766 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); 2822 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation());
2767 2823
2768 // Make sure the new connection was not deleted. 2824 // Make sure the new connection was not deleted.
2769 rtc::Thread::Current()->ProcessMessages(300); 2825 rtc::Thread::Current()->ProcessMessages(300);
2770 EXPECT_TRUE(port->GetConnection(address) != nullptr); 2826 EXPECT_TRUE(port->GetConnection(address) != nullptr);
2771 } 2827 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | webrtc/pc/rtcstats_integrationtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698