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..7acaa8c55be0a47de76919d4b49c1e769f364678 100644 |
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
@@ -650,6 +650,25 @@ 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) { |
+ Endpoint* ed = GetEndpoint(endpoint); |
+ std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); |
juberti
2015/11/17 02:01:05
can this be done as a c++ foreach? (e.g. for (cand
|
+ for (; it != ed->saved_candidates_.end(); ++it) { |
+ EXPECT_EQ((*it)->candidate.protocol(),cricket::TCP_PROTOCOL_NAME); |
juberti
2015/11/17 02:01:05
space after comma
|
+ EXPECT_EQ((*it)->candidate.tcptype(), tcptype); |
+ if ((*it)->candidate.tcptype() == cricket::TCPTYPE_ACTIVE_STR) { |
+ EXPECT_EQ((*it)->candidate.address().port(), cricket::DISCARD_PORT); |
+ continue; |
juberti
2015/11/17 02:01:05
this is kind of weird structure; I think
if (a) {
|
+ } |
+ if ((*it)->candidate.tcptype() == cricket::TCPTYPE_PASSIVE_STR) { |
+ EXPECT_NE((*it)->candidate.address().port(), cricket::DISCARD_PORT); |
+ continue; |
+ } |
+ RTC_DCHECK(false); |
+ } |
+ } |
+ |
void ResumeCandidates(int endpoint) { |
Endpoint* ed = GetEndpoint(endpoint); |
std::vector<CandidateData*>::iterator it = ed->saved_candidates_.begin(); |
@@ -1290,8 +1309,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 +1330,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(); |
} |