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

Side by Side Diff: talk/media/sctp/sctpdataengine_unittest.cc

Issue 1315923003: Revert of Added send-thresholding and fixed text packet dumping. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « talk/media/sctp/sctpdataengine.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 virtual void SetUp() { 234 virtual void SetUp() {
235 engine_.reset(new cricket::SctpDataEngine()); 235 engine_.reset(new cricket::SctpDataEngine());
236 } 236 }
237 237
238 void SetupConnectedChannels() { 238 void SetupConnectedChannels() {
239 net1_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); 239 net1_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current()));
240 net2_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); 240 net2_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current()));
241 recv1_.reset(new SctpFakeDataReceiver()); 241 recv1_.reset(new SctpFakeDataReceiver());
242 recv2_.reset(new SctpFakeDataReceiver()); 242 recv2_.reset(new SctpFakeDataReceiver());
243 chan1_ready_to_send_count_ = 0;
244 chan2_ready_to_send_count_ = 0;
245 chan1_.reset(CreateChannel(net1_.get(), recv1_.get())); 243 chan1_.reset(CreateChannel(net1_.get(), recv1_.get()));
246 chan1_->set_debug_name("chan1/connector"); 244 chan1_->set_debug_name("chan1/connector");
247 chan1_->SignalReadyToSend.connect(
248 this, &SctpDataMediaChannelTest::OnChan1ReadyToSend);
249 chan2_.reset(CreateChannel(net2_.get(), recv2_.get())); 245 chan2_.reset(CreateChannel(net2_.get(), recv2_.get()));
250 chan2_->set_debug_name("chan2/listener"); 246 chan2_->set_debug_name("chan2/listener");
251 chan2_->SignalReadyToSend.connect(
252 this, &SctpDataMediaChannelTest::OnChan2ReadyToSend);
253 // Setup two connected channels ready to send and receive. 247 // Setup two connected channels ready to send and receive.
254 net1_->SetDestination(chan2_.get()); 248 net1_->SetDestination(chan2_.get());
255 net2_->SetDestination(chan1_.get()); 249 net2_->SetDestination(chan1_.get());
256 250
257 LOG(LS_VERBOSE) << "Channel setup ----------------------------- "; 251 LOG(LS_VERBOSE) << "Channel setup ----------------------------- ";
258 AddStream(1); 252 AddStream(1);
259 AddStream(2); 253 AddStream(2);
260 254
261 LOG(LS_VERBOSE) << "Connect the channels -----------------------------"; 255 LOG(LS_VERBOSE) << "Connect the channels -----------------------------";
262 // chan1 wants to setup a data connection. 256 // chan1 wants to setup a data connection.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 323 }
330 } 324 }
331 return !thread->IsQuitting(); 325 return !thread->IsQuitting();
332 } 326 }
333 327
334 cricket::SctpDataMediaChannel* channel1() { return chan1_.get(); } 328 cricket::SctpDataMediaChannel* channel1() { return chan1_.get(); }
335 cricket::SctpDataMediaChannel* channel2() { return chan2_.get(); } 329 cricket::SctpDataMediaChannel* channel2() { return chan2_.get(); }
336 SctpFakeDataReceiver* receiver1() { return recv1_.get(); } 330 SctpFakeDataReceiver* receiver1() { return recv1_.get(); }
337 SctpFakeDataReceiver* receiver2() { return recv2_.get(); } 331 SctpFakeDataReceiver* receiver2() { return recv2_.get(); }
338 332
339 int channel1_ready_to_send_count() { return chan1_ready_to_send_count_; }
340 int channel2_ready_to_send_count() { return chan2_ready_to_send_count_; }
341 private: 333 private:
342 rtc::scoped_ptr<cricket::SctpDataEngine> engine_; 334 rtc::scoped_ptr<cricket::SctpDataEngine> engine_;
343 rtc::scoped_ptr<SctpFakeNetworkInterface> net1_; 335 rtc::scoped_ptr<SctpFakeNetworkInterface> net1_;
344 rtc::scoped_ptr<SctpFakeNetworkInterface> net2_; 336 rtc::scoped_ptr<SctpFakeNetworkInterface> net2_;
345 rtc::scoped_ptr<SctpFakeDataReceiver> recv1_; 337 rtc::scoped_ptr<SctpFakeDataReceiver> recv1_;
346 rtc::scoped_ptr<SctpFakeDataReceiver> recv2_; 338 rtc::scoped_ptr<SctpFakeDataReceiver> recv2_;
347 rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan1_; 339 rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan1_;
348 rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan2_; 340 rtc::scoped_ptr<cricket::SctpDataMediaChannel> chan2_;
349
350 int chan1_ready_to_send_count_;
351 int chan2_ready_to_send_count_;
352
353 void OnChan1ReadyToSend(bool send) { if (send) chan1_ready_to_send_count_++; }
354 void OnChan2ReadyToSend(bool send) { if (send) chan2_ready_to_send_count_++; }
355 }; 341 };
356 342
357 // Verifies that SignalReadyToSend is fired. 343 // Verifies that SignalReadyToSend is fired.
358 TEST_F(SctpDataMediaChannelTest, SignalReadyToSend) { 344 TEST_F(SctpDataMediaChannelTest, SignalReadyToSend) {
359 SetupConnectedChannels(); 345 SetupConnectedChannels();
360 346
361 SignalReadyToSendObserver signal_observer_1; 347 SignalReadyToSendObserver signal_observer_1;
362 SignalReadyToSendObserver signal_observer_2; 348 SignalReadyToSendObserver signal_observer_2;
363 349
364 channel1()->SignalReadyToSend.connect(&signal_observer_1, 350 channel1()->SignalReadyToSend.connect(&signal_observer_1,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 479
494 channel2()->RemoveSendStream(2); 480 channel2()->RemoveSendStream(2);
495 channel2()->RemoveSendStream(3); 481 channel2()->RemoveSendStream(3);
496 channel2()->RemoveSendStream(4); 482 channel2()->RemoveSendStream(4);
497 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000); 483 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000);
498 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(2), 1000); 484 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(2), 1000);
499 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(3), 1000); 485 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(3), 1000);
500 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(4), 1000); 486 EXPECT_TRUE_WAIT(chan_1_sig_receiver.WasStreamClosed(4), 1000);
501 } 487 }
502 488
503 TEST_F(SctpDataMediaChannelTest, EngineSignalsRightChannel) {
504 SetupConnectedChannels();
505 EXPECT_TRUE_WAIT(channel1()->socket() != NULL, 1000);
506 struct socket *sock = const_cast<struct socket*>(channel1()->socket());
507 int prior_count = channel1_ready_to_send_count();
508 cricket::SctpDataEngine::SendThresholdCallback(sock, 0);
509 EXPECT_GT(channel1_ready_to_send_count(), prior_count);
510 }
511
512 // Flaky on Linux and Windows. See webrtc:4453. 489 // Flaky on Linux and Windows. See webrtc:4453.
513 #if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX) 490 #if defined(WEBRTC_WIN) || defined(WEBRTC_LINUX)
514 #define MAYBE_ReusesAStream DISABLED_ReusesAStream 491 #define MAYBE_ReusesAStream DISABLED_ReusesAStream
515 #else 492 #else
516 #define MAYBE_ReusesAStream ReusesAStream 493 #define MAYBE_ReusesAStream ReusesAStream
517 #endif 494 #endif
518 TEST_F(SctpDataMediaChannelTest, MAYBE_ReusesAStream) { 495 TEST_F(SctpDataMediaChannelTest, MAYBE_ReusesAStream) {
519 // Shut down channel 1, then open it up again for reuse. 496 // Shut down channel 1, then open it up again for reuse.
520 SetupConnectedChannels(); 497 SetupConnectedChannels();
521 cricket::SendDataResult result; 498 cricket::SendDataResult result;
522 SignalChannelClosedObserver chan_2_sig_receiver; 499 SignalChannelClosedObserver chan_2_sig_receiver;
523 chan_2_sig_receiver.BindSelf(channel2()); 500 chan_2_sig_receiver.BindSelf(channel2());
524 501
525 ASSERT_TRUE(SendData(channel1(), 1, "hello?", &result)); 502 ASSERT_TRUE(SendData(channel1(), 1, "hello?", &result));
526 EXPECT_EQ(cricket::SDR_SUCCESS, result); 503 EXPECT_EQ(cricket::SDR_SUCCESS, result);
527 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hello?"), 1000); 504 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hello?"), 1000);
528 505
529 channel1()->RemoveSendStream(1); 506 channel1()->RemoveSendStream(1);
530 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000); 507 EXPECT_TRUE_WAIT(chan_2_sig_receiver.WasStreamClosed(1), 1000);
531 // Channel 1 is gone now. 508 // Channel 1 is gone now.
532 509
533 // Create a new channel 1. 510 // Create a new channel 1.
534 AddStream(1); 511 AddStream(1);
535 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); 512 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result));
536 EXPECT_EQ(cricket::SDR_SUCCESS, result); 513 EXPECT_EQ(cricket::SDR_SUCCESS, result);
537 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); 514 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000);
538 channel1()->RemoveSendStream(1); 515 channel1()->RemoveSendStream(1);
539 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); 516 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000);
540 } 517 }
OLDNEW
« 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