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