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

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

Issue 1996693002: Fire a signal when the transport channel state changes (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Changed signal name to SignalStateChanged Created 4 years, 7 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 | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.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 d645c578947b5a23085b73312527693dd5fb33ba..e2c50031268a8dd5025bc252a8b532317dfc5ced 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -2008,6 +2008,8 @@ class P2PTransportChannelPingTest : public testing::Test,
this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged);
ch->SignalReadyToSend.connect(this,
&P2PTransportChannelPingTest::OnReadyToSend);
+ ch->SignalStateChanged.connect(
+ this, &P2PTransportChannelPingTest::OnChannelStateChanged);
}
cricket::Candidate CreateHostCandidate(const std::string& ip,
@@ -2077,6 +2079,9 @@ class P2PTransportChannelPingTest : public testing::Test,
void OnReadyToSend(cricket::TransportChannel* channel) {
channel_ready_to_send_ = true;
}
+ void OnChannelStateChanged(cricket::TransportChannelImpl* channel) {
+ channel_state_ = channel->GetState();
+ }
cricket::CandidatePairInterface* last_selected_candidate_pair() {
return last_selected_candidate_pair_;
@@ -2084,6 +2089,7 @@ class P2PTransportChannelPingTest : public testing::Test,
int last_sent_packet_id() { return last_sent_packet_id_; }
bool channel_ready_to_send() { return channel_ready_to_send_; }
void reset_channel_ready_to_send() { channel_ready_to_send_ = false; }
+ cricket::TransportChannelState channel_state() { return channel_state_; }
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
@@ -2092,6 +2098,7 @@ class P2PTransportChannelPingTest : public testing::Test,
cricket::CandidatePairInterface* last_selected_candidate_pair_ = nullptr;
int last_sent_packet_id_ = -1;
bool channel_ready_to_send_ = false;
+ cricket::TransportChannelState channel_state_ = cricket::STATE_INIT;
};
TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) {
@@ -2145,6 +2152,21 @@ TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
}
+TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) {
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("state change", 1, &pa);
+ PrepareChannel(&ch);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateHostCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+ ASSERT_TRUE(conn1 != nullptr);
+ // Pruning the connection reduces the set of active connections and changes
+ // the channel state.
+ conn1->Prune();
+ EXPECT_EQ_WAIT(cricket::STATE_FAILED, channel_state(), kDefaultTimeout);
+}
+
// Test adding remote candidates with different ufrags. If a remote candidate
// is added with an old ufrag, it will be discarded. If it is added with a
// ufrag that was not seen before, it will be used to create connections
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698