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

Unified Diff: talk/app/webrtc/datachannel_unittest.cc

Issue 1207613006: Support for onbufferedamountlow (Closed) Base URL: https://chromium.googlesource.com/external/webrtc/trunk/talk.git@master
Patch Set: Remove unnecessary comment Created 5 years, 6 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/app/webrtc/datachannel.cc ('k') | talk/app/webrtc/datachannelinterface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/datachannel_unittest.cc
diff --git a/talk/app/webrtc/datachannel_unittest.cc b/talk/app/webrtc/datachannel_unittest.cc
index bc4f81c09f7e121519798112b4cf252dd54d038f..e3c290bd9b5739072f4b1b87c544354542a51364 100644
--- a/talk/app/webrtc/datachannel_unittest.cc
+++ b/talk/app/webrtc/datachannel_unittest.cc
@@ -35,12 +35,18 @@ using webrtc::DataChannel;
class FakeDataChannelObserver : public webrtc::DataChannelObserver {
public:
FakeDataChannelObserver()
- : messages_received_(0), on_state_change_count_(0) {}
+ : messages_received_(0),
+ on_state_change_count_(0),
+ on_buffered_amount_change_count_(0) {}
void OnStateChange() {
++on_state_change_count_;
}
+ void OnBufferedAmountChange(uint64 previous_amount) {
+ ++on_buffered_amount_change_count_;
+ }
+
void OnMessage(const webrtc::DataBuffer& buffer) {
++messages_received_;
}
@@ -53,13 +59,22 @@ class FakeDataChannelObserver : public webrtc::DataChannelObserver {
on_state_change_count_ = 0;
}
+ void ResetOnBufferedAmountChangeCount() {
+ on_buffered_amount_change_count_ = 0;
+ }
+
size_t on_state_change_count() const {
return on_state_change_count_;
}
+ size_t on_buffered_amount_change_count() const {
+ return on_buffered_amount_change_count_;
+ }
+
private:
size_t messages_received_;
size_t on_state_change_count_;
+ size_t on_buffered_amount_change_count_;
};
class SctpDataChannelTest : public testing::Test {
@@ -133,11 +148,13 @@ TEST_F(SctpDataChannelTest, StateTransition) {
// Tests that DataChannel::buffered_amount() is correct after the channel is
// blocked.
TEST_F(SctpDataChannelTest, BufferedAmountWhenBlocked) {
+ AddObserver();
SetChannelReady();
webrtc::DataBuffer buffer("abcd");
EXPECT_TRUE(webrtc_data_channel_->Send(buffer));
EXPECT_EQ(0U, webrtc_data_channel_->buffered_amount());
+ EXPECT_EQ(0U, observer_->on_buffered_amount_change_count());
provider_.set_send_blocked(true);
@@ -147,37 +164,46 @@ TEST_F(SctpDataChannelTest, BufferedAmountWhenBlocked) {
}
EXPECT_EQ(buffer.data.size() * number_of_packets,
webrtc_data_channel_->buffered_amount());
+ EXPECT_EQ(number_of_packets, observer_->on_buffered_amount_change_count());
}
// Tests that the queued data are sent when the channel transitions from blocked
// to unblocked.
TEST_F(SctpDataChannelTest, QueuedDataSentWhenUnblocked) {
+ AddObserver();
SetChannelReady();
webrtc::DataBuffer buffer("abcd");
provider_.set_send_blocked(true);
EXPECT_TRUE(webrtc_data_channel_->Send(buffer));
+ EXPECT_EQ(1U, observer_->on_buffered_amount_change_count());
+
provider_.set_send_blocked(false);
SetChannelReady();
EXPECT_EQ(0U, webrtc_data_channel_->buffered_amount());
+ EXPECT_EQ(2U, observer_->on_buffered_amount_change_count());
}
// Tests that no crash when the channel is blocked right away while trying to
// send queued data.
TEST_F(SctpDataChannelTest, BlockedWhenSendQueuedDataNoCrash) {
+ AddObserver();
SetChannelReady();
webrtc::DataBuffer buffer("abcd");
provider_.set_send_blocked(true);
EXPECT_TRUE(webrtc_data_channel_->Send(buffer));
+ EXPECT_EQ(1U, observer_->on_buffered_amount_change_count());
// Set channel ready while it is still blocked.
SetChannelReady();
EXPECT_EQ(buffer.size(), webrtc_data_channel_->buffered_amount());
+ EXPECT_EQ(1U, observer_->on_buffered_amount_change_count());
// Unblock the channel to send queued data again, there should be no crash.
provider_.set_send_blocked(false);
SetChannelReady();
EXPECT_EQ(0U, webrtc_data_channel_->buffered_amount());
+ EXPECT_EQ(2U, observer_->on_buffered_amount_change_count());
}
// Tests that the queued control message is sent when channel is ready.
« no previous file with comments | « talk/app/webrtc/datachannel.cc ('k') | talk/app/webrtc/datachannelinterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698