| 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 27 matching lines...) Expand all Loading... |
| 38 #include "webrtc/base/buffer.h" | 38 #include "webrtc/base/buffer.h" |
| 39 #include "webrtc/base/criticalsection.h" | 39 #include "webrtc/base/criticalsection.h" |
| 40 #include "webrtc/base/gunit.h" | 40 #include "webrtc/base/gunit.h" |
| 41 #include "webrtc/base/helpers.h" | 41 #include "webrtc/base/helpers.h" |
| 42 #include "webrtc/base/messagehandler.h" | 42 #include "webrtc/base/messagehandler.h" |
| 43 #include "webrtc/base/messagequeue.h" | 43 #include "webrtc/base/messagequeue.h" |
| 44 #include "webrtc/base/scoped_ptr.h" | 44 #include "webrtc/base/scoped_ptr.h" |
| 45 #include "webrtc/base/ssladapter.h" | 45 #include "webrtc/base/ssladapter.h" |
| 46 #include "webrtc/base/thread.h" | 46 #include "webrtc/base/thread.h" |
| 47 | 47 |
| 48 #ifdef HAVE_NSS_SSL_H |
| 49 // TODO(thorcarpenter): Remove after webrtc switches over to BoringSSL. |
| 50 #include "webrtc/base/nssstreamadapter.h" |
| 51 #endif // HAVE_NSS_SSL_H |
| 52 |
| 48 enum { | 53 enum { |
| 49 MSG_PACKET = 1, | 54 MSG_PACKET = 1, |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 // Fake NetworkInterface that sends/receives sctp packets. The one in | 57 // Fake NetworkInterface that sends/receives sctp packets. The one in |
| 53 // talk/media/base/fakenetworkinterface.h only works with rtp/rtcp. | 58 // talk/media/base/fakenetworkinterface.h only works with rtp/rtcp. |
| 54 class SctpFakeNetworkInterface : public cricket::MediaChannel::NetworkInterface, | 59 class SctpFakeNetworkInterface : public cricket::MediaChannel::NetworkInterface, |
| 55 public rtc::MessageHandler { | 60 public rtc::MessageHandler { |
| 56 public: | 61 public: |
| 57 explicit SctpFakeNetworkInterface(rtc::Thread* thread) | 62 explicit SctpFakeNetworkInterface(rtc::Thread* thread) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 std::vector<int> streams_; | 216 std::vector<int> streams_; |
| 212 }; | 217 }; |
| 213 | 218 |
| 214 // SCTP Data Engine testing framework. | 219 // SCTP Data Engine testing framework. |
| 215 class SctpDataMediaChannelTest : public testing::Test, | 220 class SctpDataMediaChannelTest : public testing::Test, |
| 216 public sigslot::has_slots<> { | 221 public sigslot::has_slots<> { |
| 217 protected: | 222 protected: |
| 218 // usrsctp uses the NSS random number generator on non-Android platforms, | 223 // usrsctp uses the NSS random number generator on non-Android platforms, |
| 219 // so we need to initialize SSL. | 224 // so we need to initialize SSL. |
| 220 static void SetUpTestCase() { | 225 static void SetUpTestCase() { |
| 226 #ifdef HAVE_NSS_SSL_H |
| 227 // TODO(thorcarpenter): Remove after webrtc switches over to BoringSSL. |
| 228 if (!rtc::NSSContext::InitializeSSL(NULL)) { |
| 229 LOG(LS_WARNING) << "Unabled to initialize NSS."; |
| 230 } |
| 231 #endif // HAVE_NSS_SSL_H |
| 221 } | 232 } |
| 222 | 233 |
| 223 virtual void SetUp() { | 234 virtual void SetUp() { |
| 224 engine_.reset(new cricket::SctpDataEngine()); | 235 engine_.reset(new cricket::SctpDataEngine()); |
| 225 } | 236 } |
| 226 | 237 |
| 227 void SetupConnectedChannels() { | 238 void SetupConnectedChannels() { |
| 228 net1_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); | 239 net1_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); |
| 229 net2_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); | 240 net2_.reset(new SctpFakeNetworkInterface(rtc::Thread::Current())); |
| 230 recv1_.reset(new SctpFakeDataReceiver()); | 241 recv1_.reset(new SctpFakeDataReceiver()); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // Channel 1 is gone now. | 537 // Channel 1 is gone now. |
| 527 | 538 |
| 528 // Create a new channel 1. | 539 // Create a new channel 1. |
| 529 AddStream(1); | 540 AddStream(1); |
| 530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); | 541 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); |
| 531 EXPECT_EQ(cricket::SDR_SUCCESS, result); | 542 EXPECT_EQ(cricket::SDR_SUCCESS, result); |
| 532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); | 543 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); |
| 533 channel1()->RemoveSendStream(1); | 544 channel1()->RemoveSendStream(1); |
| 534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); | 545 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); |
| 535 } | 546 } |
| OLD | NEW |