Index: webrtc/p2p/base/port_unittest.cc |
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc |
index 4877af3c4ed050dff9e31355a69031ff236e9afa..a960e71aeb749918ebe3c920fb13a6e99480abc7 100644 |
--- a/webrtc/p2p/base/port_unittest.cc |
+++ b/webrtc/p2p/base/port_unittest.cc |
@@ -232,6 +232,9 @@ class TestChannel : public sigslot::has_slots<> { |
conn_->SignalStateChange.connect( |
this, &TestChannel::OnConnectionStateChange); |
conn_->SignalDestroyed.connect(this, &TestChannel::OnDestroyed); |
+ conn_->SignalReadyToSend.connect(this, |
+ &TestChannel::OnConnectionReadyToSend); |
+ is_recovered_from_ewouldblock_ = false; |
pthatcher1
2015/08/20 03:47:27
Would it make sense to call this connection_ready_
juberti1
2015/08/20 05:33:00
+1
|
} |
void OnConnectionStateChange(Connection* conn) { |
if (conn->write_state() == Connection::STATE_WRITABLE) { |
@@ -321,7 +324,20 @@ class TestChannel : public sigslot::has_slots<> { |
bool nominated() const { return nominated_; } |
+ void set_is_recovered_from_ewouldblock(bool ready) { |
+ is_recovered_from_ewouldblock_ = ready; |
+ } |
+ bool is_recovered_from_ewouldblock() const { |
+ return is_recovered_from_ewouldblock_; |
+ } |
+ |
private: |
+ // ReadyToSend will only issue after a Connection recovers from EWOULDBLOCK. |
+ void OnConnectionReadyToSend(Connection* conn) { |
+ ASSERT_EQ(conn, conn_); |
+ is_recovered_from_ewouldblock_ = true; |
+ } |
+ |
IceMode ice_mode_; |
rtc::scoped_ptr<Port> src_; |
Port* dst_; |
@@ -332,6 +348,7 @@ class TestChannel : public sigslot::has_slots<> { |
rtc::scoped_ptr<StunMessage> remote_request_; |
std::string remote_frag_; |
bool nominated_; |
+ bool is_recovered_from_ewouldblock_ = false; |
}; |
class PortTest : public testing::Test, public sigslot::has_slots<> { |
@@ -624,6 +641,9 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { |
static_cast<TCPConnection*>(ch2.conn()) |
->set_reconnection_timeout(kTcpReconnectTimeout); |
+ EXPECT_FALSE(ch1.is_recovered_from_ewouldblock()); |
+ EXPECT_FALSE(ch2.is_recovered_from_ewouldblock()); |
+ |
// Once connected, disconnect them. |
DisconnectTcpTestChannels(&ch1, &ch2); |
@@ -644,11 +664,19 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { |
// Verify that we could still connect channels. |
ConnectStartedChannels(&ch1, &ch2); |
+ EXPECT_TRUE_WAIT(ch1.is_recovered_from_ewouldblock(), |
+ kTcpReconnectTimeout); |
+ // Channel2 is the passive one so a new connection is created during |
+ // reconnect. This new connection should never have issued EWOULDBLOCK |
+ // hence the is_recovered_from_ewouldblock() should be false. |
+ EXPECT_FALSE(ch2.is_recovered_from_ewouldblock()); |
} else { |
EXPECT_EQ(ch1.conn()->write_state(), Connection::STATE_WRITABLE); |
EXPECT_TRUE_WAIT( |
ch1.conn()->write_state() == Connection::STATE_WRITE_TIMEOUT, |
kTcpReconnectTimeout + kTimeout); |
+ EXPECT_FALSE(ch1.is_recovered_from_ewouldblock()); |
+ EXPECT_FALSE(ch2.is_recovered_from_ewouldblock()); |
} |
// Tear down and ensure that goes smoothly. |