OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 239 |
240 // Sends a message and verifies it's ordered. | 240 // Sends a message and verifies it's ordered. |
241 webrtc::DataBuffer buffer("some data"); | 241 webrtc::DataBuffer buffer("some data"); |
242 ASSERT_TRUE(dc->Send(buffer)); | 242 ASSERT_TRUE(dc->Send(buffer)); |
243 EXPECT_TRUE(provider_.last_send_data_params().ordered); | 243 EXPECT_TRUE(provider_.last_send_data_params().ordered); |
244 | 244 |
245 // Emulates receiving an OPEN_ACK message. | 245 // Emulates receiving an OPEN_ACK message. |
246 cricket::ReceiveDataParams params; | 246 cricket::ReceiveDataParams params; |
247 params.ssrc = init.id; | 247 params.ssrc = init.id; |
248 params.type = cricket::DMT_CONTROL; | 248 params.type = cricket::DMT_CONTROL; |
249 rtc::Buffer payload; | 249 rtc::CopyOnWriteBuffer payload; |
250 webrtc::WriteDataChannelOpenAckMessage(&payload); | 250 webrtc::WriteDataChannelOpenAckMessage(&payload); |
251 dc->OnDataReceived(NULL, params, payload); | 251 dc->OnDataReceived(NULL, params, payload); |
252 | 252 |
253 // Sends another message and verifies it's unordered. | 253 // Sends another message and verifies it's unordered. |
254 ASSERT_TRUE(dc->Send(buffer)); | 254 ASSERT_TRUE(dc->Send(buffer)); |
255 EXPECT_FALSE(provider_.last_send_data_params().ordered); | 255 EXPECT_FALSE(provider_.last_send_data_params().ordered); |
256 } | 256 } |
257 | 257 |
258 // Tests that an unordered DataChannel sends unordered data after any DATA | 258 // Tests that an unordered DataChannel sends unordered data after any DATA |
259 // message is received. | 259 // message is received. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 webrtc::DataChannelInit base; | 397 webrtc::DataChannelInit base; |
398 base.negotiated = true; | 398 base.negotiated = true; |
399 webrtc::InternalDataChannelInit init2(base); | 399 webrtc::InternalDataChannelInit init2(base); |
400 EXPECT_EQ(webrtc::InternalDataChannelInit::kNone, init2.open_handshake_role); | 400 EXPECT_EQ(webrtc::InternalDataChannelInit::kNone, init2.open_handshake_role); |
401 } | 401 } |
402 | 402 |
403 // Tests that the DataChannel is closed if the sending buffer is full. | 403 // Tests that the DataChannel is closed if the sending buffer is full. |
404 TEST_F(SctpDataChannelTest, ClosedWhenSendBufferFull) { | 404 TEST_F(SctpDataChannelTest, ClosedWhenSendBufferFull) { |
405 SetChannelReady(); | 405 SetChannelReady(); |
406 | 406 |
407 rtc::Buffer buffer(1024); | 407 rtc::CopyOnWriteBuffer buffer(1024); |
408 memset(buffer.data(), 0, buffer.size()); | 408 memset(buffer.data(), 0, buffer.size()); |
409 | 409 |
410 webrtc::DataBuffer packet(buffer, true); | 410 webrtc::DataBuffer packet(buffer, true); |
411 provider_.set_send_blocked(true); | 411 provider_.set_send_blocked(true); |
412 | 412 |
413 for (size_t i = 0; i < 16 * 1024 + 1; ++i) { | 413 for (size_t i = 0; i < 16 * 1024 + 1; ++i) { |
414 EXPECT_TRUE(webrtc_data_channel_->Send(packet)); | 414 EXPECT_TRUE(webrtc_data_channel_->Send(packet)); |
415 } | 415 } |
416 | 416 |
417 EXPECT_TRUE( | 417 EXPECT_TRUE( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 // OnStateChange called for kClosing and kClosed. | 451 // OnStateChange called for kClosing and kClosed. |
452 EXPECT_EQ(2U, observer_->on_state_change_count()); | 452 EXPECT_EQ(2U, observer_->on_state_change_count()); |
453 EXPECT_EQ(webrtc::DataChannelInterface::kClosed, | 453 EXPECT_EQ(webrtc::DataChannelInterface::kClosed, |
454 webrtc_data_channel_->state()); | 454 webrtc_data_channel_->state()); |
455 } | 455 } |
456 | 456 |
457 // Tests that the DataChannel is closed if the received buffer is full. | 457 // Tests that the DataChannel is closed if the received buffer is full. |
458 TEST_F(SctpDataChannelTest, ClosedWhenReceivedBufferFull) { | 458 TEST_F(SctpDataChannelTest, ClosedWhenReceivedBufferFull) { |
459 SetChannelReady(); | 459 SetChannelReady(); |
460 rtc::Buffer buffer(1024); | 460 rtc::CopyOnWriteBuffer buffer(1024); |
461 memset(buffer.data(), 0, buffer.size()); | 461 memset(buffer.data(), 0, buffer.size()); |
462 | 462 |
463 cricket::ReceiveDataParams params; | 463 cricket::ReceiveDataParams params; |
464 params.ssrc = 0; | 464 params.ssrc = 0; |
465 | 465 |
466 // Receiving data without having an observer will overflow the buffer. | 466 // Receiving data without having an observer will overflow the buffer. |
467 for (size_t i = 0; i < 16 * 1024 + 1; ++i) { | 467 for (size_t i = 0; i < 16 * 1024 + 1; ++i) { |
468 webrtc_data_channel_->OnDataReceived(NULL, params, buffer); | 468 webrtc_data_channel_->OnDataReceived(NULL, params, buffer); |
469 } | 469 } |
470 EXPECT_EQ(webrtc::DataChannelInterface::kClosed, | 470 EXPECT_EQ(webrtc::DataChannelInterface::kClosed, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); | 555 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); |
556 EXPECT_EQ(even_id, allocated_id); | 556 EXPECT_EQ(even_id, allocated_id); |
557 | 557 |
558 // Verifies that used higher ids are not reused. | 558 // Verifies that used higher ids are not reused. |
559 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_SERVER, &allocated_id)); | 559 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_SERVER, &allocated_id)); |
560 EXPECT_EQ(odd_id + 6, allocated_id); | 560 EXPECT_EQ(odd_id + 6, allocated_id); |
561 | 561 |
562 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); | 562 EXPECT_TRUE(allocator_.AllocateSid(rtc::SSL_CLIENT, &allocated_id)); |
563 EXPECT_EQ(even_id + 6, allocated_id); | 563 EXPECT_EQ(even_id + 6, allocated_id); |
564 } | 564 } |
OLD | NEW |