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

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

Issue 1288553010: TcpPort Reconnect should inform upper layer to start sending again (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 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 | « 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/port_unittest.cc
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index 4877af3c4ed050dff9e31355a69031ff236e9afa..2fe104487e53126ece41de1924707c5832af9503 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);
+ connection_ready_to_send_ = false;
}
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_connection_ready_to_send(bool ready) {
+ connection_ready_to_send_ = ready;
+ }
+ bool connection_ready_to_send() const {
+ return connection_ready_to_send_;
+ }
+
private:
+ // ReadyToSend will only issue after a Connection recovers from EWOULDBLOCK.
+ void OnConnectionReadyToSend(Connection* conn) {
+ ASSERT_EQ(conn, conn_);
+ connection_ready_to_send_ = 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 connection_ready_to_send_ = 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.connection_ready_to_send());
+ EXPECT_FALSE(ch2.connection_ready_to_send());
+
// 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.connection_ready_to_send(),
+ kTcpReconnectTimeout);
+ // Channel2 is the passive one so a new connection is created during
+ // reconnect. This new connection should never have issued EWOULDBLOCK
+ // hence the connection_ready_to_send() should be false.
+ EXPECT_FALSE(ch2.connection_ready_to_send());
} 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.connection_ready_to_send());
+ EXPECT_FALSE(ch2.connection_ready_to_send());
}
// Tear down and ensure that goes smoothly.
« 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