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

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

Issue 1217463004: Fix active tcp port to 9 (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: address comment. Created 5 years, 1 month 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 | « no previous file | webrtc/p2p/base/tcpport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index 8ec6474a2d9567101942467a5985ff0029c1c3e9..195ee8402d0af950c378939003227cf77068b6cc 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -650,6 +650,21 @@ class P2PTransportChannelTestBase : public testing::Test,
GetEndpoint(endpoint)->save_candidates_ = true;
}
+ // Tcp candidate verification has to be done when they are generated.
+ void VerifySavedTcpCandidates(int endpoint, const std::string& tcptype) {
+ for (auto& it : GetEndpoint(endpoint)->saved_candidates_) {
juberti 2015/11/17 21:48:03 |it| is probably a bad name here, since it's not a
+ EXPECT_EQ(it->candidate.protocol(), cricket::TCP_PROTOCOL_NAME);
+ EXPECT_EQ(it->candidate.tcptype(), tcptype);
+ if (it->candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) {
+ EXPECT_EQ(it->candidate.address().port(), cricket::DISCARD_PORT);
+ } else if (it->candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) {
+ EXPECT_NE(it->candidate.address().port(), cricket::DISCARD_PORT);
+ } else {
+ RTC_DCHECK(false) << "Unknown tcptype: " << it->candidate.tcptype();
juberti 2015/11/17 21:48:03 Use the gtest FAIL() macro
+ }
+ }
+ }
+
void ResumeCandidates(int endpoint) {
Endpoint* ed = GetEndpoint(endpoint);
std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin();
@@ -1290,8 +1305,19 @@ TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
SetAllowTcpListen(0, true); // actpass.
SetAllowTcpListen(1, false); // active.
+ // Pause candidate so we could verify the candidate properties.
+ PauseCandidates(0);
+ PauseCandidates(1);
CreateChannels(1);
+ // Verify tcp candidates.
+ VerifySavedTcpCandidates(0, cricket::TCPTYPE_PASSIVE_STR);
+ VerifySavedTcpCandidates(1, cricket::TCPTYPE_ACTIVE_STR);
+
+ // Resume candidates.
+ ResumeCandidates(0);
+ ResumeCandidates(1);
+
EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() &&
ep2_ch1()->receiving() && ep2_ch1()->writable(),
1000);
@@ -1300,12 +1326,6 @@ TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) {
LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) &&
RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1]));
- std::string kTcpProtocol = "tcp";
- EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep1_ch1())->protocol());
- EXPECT_EQ(kTcpProtocol, LocalCandidate(ep1_ch1())->protocol());
- EXPECT_EQ(kTcpProtocol, RemoteCandidate(ep2_ch1())->protocol());
- EXPECT_EQ(kTcpProtocol, LocalCandidate(ep2_ch1())->protocol());
-
TestSendRecv(1);
DestroyChannels();
}
« no previous file with comments | « no previous file | webrtc/p2p/base/tcpport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698