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

Unified Diff: talk/media/sctp/sctpdataengine_unittest.cc

Issue 1304063006: (try 2) Added send-thresholding and fixed text packet dumping (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Simplification of GetChannelFromSocket, and a dcheck moved. 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 | « talk/media/sctp/sctpdataengine.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/media/sctp/sctpdataengine_unittest.cc
diff --git a/talk/media/sctp/sctpdataengine_unittest.cc b/talk/media/sctp/sctpdataengine_unittest.cc
index 5b4c09e6a7b5dd187bbdc05de69a493eba707c62..d406fa18cdcafe60ffbb31db71572c7235e6d72b 100644
--- a/talk/media/sctp/sctpdataengine_unittest.cc
+++ b/talk/media/sctp/sctpdataengine_unittest.cc
@@ -240,10 +240,16 @@ class SctpDataMediaChannelTest : public testing::Test,
net2_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current()));
recv1_.reset(new SctpFakeDataReceiver());
recv2_.reset(new SctpFakeDataReceiver());
+ chan1_ready_to_send_count_ = 0;
+ chan2_ready_to_send_count_ = 0;
chan1_.reset(CreateChannel(net1_.get(), recv1_.get()));
chan1_->set_debug_name("chan1/connector");
+ chan1_->SignalReadyToSend.connect(
+ this, &SctpDataMediaChannelTest::OnChan1ReadyToSend);
chan2_.reset(CreateChannel(net2_.get(), recv2_.get()));
chan2_->set_debug_name("chan2/listener");
+ chan2_->SignalReadyToSend.connect(
+ this, &SctpDataMediaChannelTest::OnChan2ReadyToSend);
// Setup two connected channels ready to send and receive.
net1_->SetDestination(chan2_.get());
net2_->SetDestination(chan1_.get());
@@ -330,6 +336,8 @@ class SctpDataMediaChannelTest : public testing::Test,
SctpFakeDataReceiver* receiver1() { return recv1_.get(); }
SctpFakeDataReceiver* receiver2() { return recv2_.get(); }
+ int channel1_ready_to_send_count() { return chan1_ready_to_send_count_; }
+ int channel2_ready_to_send_count() { return chan2_ready_to_send_count_; }
private:
rtc::scoped_ptr<cricket::SctpDataEngine> engine_;
rtc::scoped_ptr<SctpFakeNetworkInterface> net1_;
@@ -338,6 +346,18 @@ class SctpDataMediaChannelTest : public testing::Test,
rtc::scoped_ptr<SctpFakeDataReceiver> recv2_;
rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan1_;
rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan2_;
+
+ int chan1_ready_to_send_count_;
+ int chan2_ready_to_send_count_;
+
+ void OnChan1ReadyToSend(bool send) {
+ if (send)
+ ++chan1_ready_to_send_count_;
+ }
+ void OnChan2ReadyToSend(bool send) {
+ if (send)
+ ++chan2_ready_to_send_count_;
+ }
};
// Verifies that SignalReadyToSend is fired.
@@ -486,6 +506,15 @@ TEST_F(SctpDataMediaChannelTest, ClosesStreamsOnBothSides) {
EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(4), 1000);
}
+TEST_F(SctpDataMediaChannelTest, EngineSignalsRightChannel) {
+ SetupConnectedChannels();
+ EXPECT_TRUE_WAIT(channel1()->socket() != NULL, 1000);
+ struct socket *sock = const_cast<struct socket*>(channel1()->socket());
+ int prior_count = channel1_ready_to_send_count();
+ cricket::SctpDataEngine::SendThresholdCallback(sock, 0);
+ EXPECT_GT(channel1_ready_to_send_count(), prior_count);
+}
+
// Flaky on Linux and Windows. See webrtc:4453.
#if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX)
#define MAYBE_ReusesAStream DISABLED_ReusesAStream
« no previous file with comments | « talk/media/sctp/sctpdataengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698