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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 virtual void TearDown() { | 264 virtual void TearDown() { |
265 channel1()->SetSend(false); | 265 channel1()->SetSend(false); |
266 channel2()->SetSend(false); | 266 channel2()->SetSend(false); |
267 | 267 |
268 // Process messages until idle to prevent a sent packet from being dropped | 268 // Process messages until idle to prevent a sent packet from being dropped |
269 // and causing memory leaks (not being deleted by the receiver). | 269 // and causing memory leaks (not being deleted by the receiver). |
270 ProcessMessagesUntilIdle(); | 270 ProcessMessagesUntilIdle(); |
271 } | 271 } |
272 | 272 |
273 void AddStream(int ssrc) { | 273 bool AddStream(int ssrc) { |
| 274 bool ret = true; |
274 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(ssrc)); | 275 cricket::StreamParams p(cricket::StreamParams::CreateLegacy(ssrc)); |
275 chan1_->AddSendStream(p); | 276 ret = ret && chan1_->AddSendStream(p); |
276 chan1_->AddRecvStream(p); | 277 ret = ret && chan1_->AddRecvStream(p); |
277 chan2_->AddSendStream(p); | 278 ret = ret && chan2_->AddSendStream(p); |
278 chan2_->AddRecvStream(p); | 279 ret = ret && chan2_->AddRecvStream(p); |
| 280 return ret; |
279 } | 281 } |
280 | 282 |
281 cricket::SctpDataMediaChannel* CreateChannel( | 283 cricket::SctpDataMediaChannel* CreateChannel( |
282 SctpFakeNetworkInterface* net, SctpFakeDataReceiver* recv) { | 284 SctpFakeNetworkInterface* net, SctpFakeDataReceiver* recv) { |
283 cricket::SctpDataMediaChannel* channel = | 285 cricket::SctpDataMediaChannel* channel = |
284 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel( | 286 static_cast<cricket::SctpDataMediaChannel*>(engine_->CreateChannel( |
285 cricket::DCT_SCTP)); | 287 cricket::DCT_SCTP)); |
286 channel->SetInterface(net); | 288 channel->SetInterface(net); |
287 // When data is received, pass it to the SctpFakeDataReceiver. | 289 // When data is received, pass it to the SctpFakeDataReceiver. |
288 channel->SignalDataReceived.connect( | 290 channel->SignalDataReceived.connect( |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 499 |
498 TEST_F(SctpDataMediaChannelTest, EngineSignalsRightChannel) { | 500 TEST_F(SctpDataMediaChannelTest, EngineSignalsRightChannel) { |
499 SetupConnectedChannels(); | 501 SetupConnectedChannels(); |
500 EXPECT_TRUE_WAIT(channel1()->socket() != NULL, 1000); | 502 EXPECT_TRUE_WAIT(channel1()->socket() != NULL, 1000); |
501 struct socket *sock = const_cast<struct socket*>(channel1()->socket()); | 503 struct socket *sock = const_cast<struct socket*>(channel1()->socket()); |
502 int prior_count = channel1_ready_to_send_count(); | 504 int prior_count = channel1_ready_to_send_count(); |
503 cricket::SctpDataEngine::SendThresholdCallback(sock, 0); | 505 cricket::SctpDataEngine::SendThresholdCallback(sock, 0); |
504 EXPECT_GT(channel1_ready_to_send_count(), prior_count); | 506 EXPECT_GT(channel1_ready_to_send_count(), prior_count); |
505 } | 507 } |
506 | 508 |
| 509 TEST_F(SctpDataMediaChannelTest, RefusesHighNumberedChannels) { |
| 510 SetupConnectedChannels(); |
| 511 EXPECT_TRUE(AddStream(1022)); |
| 512 EXPECT_FALSE(AddStream(1023)); |
| 513 } |
| 514 |
507 // Flaky on Linux and Windows. See webrtc:4453. | 515 // Flaky on Linux and Windows. See webrtc:4453. |
508 #if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX) | 516 #if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX) |
509 #define MAYBE_ReusesAStream DISABLED_ReusesAStream | 517 #define MAYBE_ReusesAStream DISABLED_ReusesAStream |
510 #else | 518 #else |
511 #define MAYBE_ReusesAStream ReusesAStream | 519 #define MAYBE_ReusesAStream ReusesAStream |
512 #endif | 520 #endif |
513 TEST_F(SctpDataMediaChannelTest, MAYBE_ReusesAStream) { | 521 TEST_F(SctpDataMediaChannelTest, MAYBE_ReusesAStream) { |
514 // Shut down channel 1, then open it up again for reuse. | 522 // Shut down channel 1, then open it up again for reuse. |
515 SetupConnectedChannels(); | 523 SetupConnectedChannels(); |
516 cricket::SendDataResult result; | 524 cricket::SendDataResult result; |
517 SignalChannelClosedObserver chan_2_sig_receiver; | 525 SignalChannelClosedObserver chan_2_sig_receiver; |
518 chan_2_sig_receiver.BindSelf(channel2()); | 526 chan_2_sig_receiver.BindSelf(channel2()); |
519 | 527 |
520 ASSERT_TRUE(SendData(channel1(), 1, "hello?", &result)); | 528 ASSERT_TRUE(SendData(channel1(), 1, "hello?", &result)); |
521 EXPECT_EQ(cricket::SDR_SUCCESS, result); | 529 EXPECT_EQ(cricket::SDR_SUCCESS, result); |
522 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hello?"), 1000); | 530 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hello?"), 1000); |
523 | 531 |
524 channel1()->RemoveSendStream(1); | 532 channel1()->RemoveSendStream(1); |
525 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000); | 533 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000); |
526 // Channel 1 is gone now. | 534 // Channel 1 is gone now. |
527 | 535 |
528 // Create a new channel 1. | 536 // Create a new channel 1. |
529 AddStream(1); | 537 AddStream(1); |
530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); | 538 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); |
531 EXPECT_EQ(cricket::SDR_SUCCESS, result); | 539 EXPECT_EQ(cricket::SDR_SUCCESS, result); |
532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); | 540 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); |
533 channel1()->RemoveSendStream(1); | 541 channel1()->RemoveSendStream(1); |
534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); | 542 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); |
535 } | 543 } |
OLD | NEW |