| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public: | 36 public: |
| 37 FakeDataChannelObserver() | 37 FakeDataChannelObserver() |
| 38 : messages_received_(0), | 38 : messages_received_(0), |
| 39 on_state_change_count_(0), | 39 on_state_change_count_(0), |
| 40 on_buffered_amount_change_count_(0) {} | 40 on_buffered_amount_change_count_(0) {} |
| 41 | 41 |
| 42 void OnStateChange() { | 42 void OnStateChange() { |
| 43 ++on_state_change_count_; | 43 ++on_state_change_count_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void OnBufferedAmountChange(uint64 previous_amount) { | 46 void OnBufferedAmountChange(uint64_t previous_amount) { |
| 47 ++on_buffered_amount_change_count_; | 47 ++on_buffered_amount_change_count_; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void OnMessage(const webrtc::DataBuffer& buffer) { | 50 void OnMessage(const webrtc::DataBuffer& buffer) { |
| 51 ++messages_received_; | 51 ++messages_received_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 size_t messages_received() const { | 54 size_t messages_received() const { |
| 55 return messages_received_; | 55 return messages_received_; |
| 56 } | 56 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 // Tests that the queued control message is sent when channel is ready. | 209 // Tests that the queued control message is sent when channel is ready. |
| 210 TEST_F(SctpDataChannelTest, OpenMessageSent) { | 210 TEST_F(SctpDataChannelTest, OpenMessageSent) { |
| 211 // Initially the id is unassigned. | 211 // Initially the id is unassigned. |
| 212 EXPECT_EQ(-1, webrtc_data_channel_->id()); | 212 EXPECT_EQ(-1, webrtc_data_channel_->id()); |
| 213 | 213 |
| 214 SetChannelReady(); | 214 SetChannelReady(); |
| 215 EXPECT_GE(webrtc_data_channel_->id(), 0); | 215 EXPECT_GE(webrtc_data_channel_->id(), 0); |
| 216 EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); | 216 EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); |
| 217 EXPECT_EQ(provider_.last_send_data_params().ssrc, | 217 EXPECT_EQ(provider_.last_send_data_params().ssrc, |
| 218 static_cast<uint32>(webrtc_data_channel_->id())); | 218 static_cast<uint32_t>(webrtc_data_channel_->id())); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) { | 221 TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) { |
| 222 provider_.set_send_blocked(true); | 222 provider_.set_send_blocked(true); |
| 223 SetChannelReady(); | 223 SetChannelReady(); |
| 224 provider_.set_send_blocked(false); | 224 provider_.set_send_blocked(false); |
| 225 | 225 |
| 226 EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); | 226 EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); |
| 227 EXPECT_EQ(provider_.last_send_data_params().ssrc, | 227 EXPECT_EQ(provider_.last_send_data_params().ssrc, |
| 228 static_cast<uint32>(webrtc_data_channel_->id())); | 228 static_cast<uint32_t>(webrtc_data_channel_->id())); |
| 229 } | 229 } |
| 230 | 230 |
| 231 // Tests that the DataChannel created after transport gets ready can enter OPEN | 231 // Tests that the DataChannel created after transport gets ready can enter OPEN |
| 232 // state. | 232 // state. |
| 233 TEST_F(SctpDataChannelTest, LateCreatedChannelTransitionToOpen) { | 233 TEST_F(SctpDataChannelTest, LateCreatedChannelTransitionToOpen) { |
| 234 SetChannelReady(); | 234 SetChannelReady(); |
| 235 webrtc::InternalDataChannelInit init; | 235 webrtc::InternalDataChannelInit init; |
| 236 init.id = 1; | 236 init.id = 1; |
| 237 rtc::scoped_refptr<DataChannel> dc = DataChannel::Create( | 237 rtc::scoped_refptr<DataChannel> dc = DataChannel::Create( |
| 238 &provider_, cricket::DCT_SCTP, "test1", init); | 238 &provider_, cricket::DCT_SCTP, "test1", init); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 EXPECT_EQ(webrtc::DataChannelInterface::kOpen, | 499 EXPECT_EQ(webrtc::DataChannelInterface::kOpen, |
| 500 webrtc_data_channel_->state()); | 500 webrtc_data_channel_->state()); |
| 501 } | 501 } |
| 502 | 502 |
| 503 // Tests that a channel can be closed without being opened or assigned an sid. | 503 // Tests that a channel can be closed without being opened or assigned an sid. |
| 504 TEST_F(SctpDataChannelTest, NeverOpened) { | 504 TEST_F(SctpDataChannelTest, NeverOpened) { |
| 505 provider_.set_transport_available(true); | 505 provider_.set_transport_available(true); |
| 506 webrtc_data_channel_->OnTransportChannelCreated(); | 506 webrtc_data_channel_->OnTransportChannelCreated(); |
| 507 webrtc_data_channel_->Close(); | 507 webrtc_data_channel_->Close(); |
| 508 } | 508 } |
| OLD | NEW |