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 |
11 #include "webrtc/api/test/peerconnectiontestwrapper.h" | 11 #include "webrtc/api/test/peerconnectiontestwrapper.h" |
12 // Notice that mockpeerconnectionobservers.h must be included after the above! | 12 // Notice that mockpeerconnectionobservers.h must be included after the above! |
13 #include "webrtc/api/test/mockpeerconnectionobservers.h" | 13 #include "webrtc/api/test/mockpeerconnectionobservers.h" |
14 #ifdef WEBRTC_ANDROID | 14 #ifdef WEBRTC_ANDROID |
15 #include "webrtc/api/test/androidtestinitializer.h" | 15 #include "webrtc/api/test/androidtestinitializer.h" |
16 #endif | 16 #endif |
17 #include "webrtc/base/gunit.h" | 17 #include "webrtc/base/gunit.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/base/ssladapter.h" | 19 #include "webrtc/base/ssladapter.h" |
| 20 #include "webrtc/base/thread.h" |
20 #include "webrtc/base/sslstreamadapter.h" | 21 #include "webrtc/base/sslstreamadapter.h" |
21 #include "webrtc/base/stringencode.h" | 22 #include "webrtc/base/stringencode.h" |
22 #include "webrtc/base/stringutils.h" | 23 #include "webrtc/base/stringutils.h" |
23 | 24 |
24 #define MAYBE_SKIP_TEST(feature) \ | 25 #define MAYBE_SKIP_TEST(feature) \ |
25 if (!(feature())) { \ | 26 if (!(feature())) { \ |
26 LOG(LS_INFO) << "Feature disabled... skipping"; \ | 27 LOG(LS_INFO) << "Feature disabled... skipping"; \ |
27 return; \ | 28 return; \ |
28 } | 29 } |
29 | 30 |
30 using webrtc::DataChannelInterface; | 31 using webrtc::DataChannelInterface; |
31 using webrtc::FakeConstraints; | 32 using webrtc::FakeConstraints; |
32 using webrtc::MediaConstraintsInterface; | 33 using webrtc::MediaConstraintsInterface; |
33 using webrtc::MediaStreamInterface; | 34 using webrtc::MediaStreamInterface; |
34 using webrtc::PeerConnectionInterface; | 35 using webrtc::PeerConnectionInterface; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 const size_t kMaxWait = 10000; | 39 const size_t kMaxWait = 10000; |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 class PeerConnectionEndToEndTest | 43 class PeerConnectionEndToEndTest |
43 : public sigslot::has_slots<>, | 44 : public sigslot::has_slots<>, |
44 public testing::Test { | 45 public testing::Test { |
45 public: | 46 public: |
46 typedef std::vector<rtc::scoped_refptr<DataChannelInterface> > | 47 typedef std::vector<rtc::scoped_refptr<DataChannelInterface> > |
47 DataChannelList; | 48 DataChannelList; |
48 | 49 |
49 PeerConnectionEndToEndTest() | 50 PeerConnectionEndToEndTest() { |
50 : caller_(new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 51 RTC_CHECK(worker_thread_.Start()); |
51 "caller")), | 52 caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
52 callee_(new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 53 "caller", &worker_thread_); |
53 "callee")) { | 54 callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
| 55 "callee", &worker_thread_); |
54 #ifdef WEBRTC_ANDROID | 56 #ifdef WEBRTC_ANDROID |
55 webrtc::InitializeAndroidObjects(); | 57 webrtc::InitializeAndroidObjects(); |
56 #endif | 58 #endif |
57 } | 59 } |
58 | 60 |
59 void CreatePcs() { | 61 void CreatePcs() { |
60 CreatePcs(NULL); | 62 CreatePcs(NULL); |
61 } | 63 } |
62 | 64 |
63 void CreatePcs(const MediaConstraintsInterface* pc_constraints) { | 65 void CreatePcs(const MediaConstraintsInterface* pc_constraints) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const DataChannelList& remote_dc_list, | 146 const DataChannelList& remote_dc_list, |
145 size_t remote_dc_index) { | 147 size_t remote_dc_index) { |
146 local_dc->Close(); | 148 local_dc->Close(); |
147 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, local_dc->state(), kMaxWait); | 149 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, local_dc->state(), kMaxWait); |
148 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, | 150 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, |
149 remote_dc_list[remote_dc_index]->state(), | 151 remote_dc_list[remote_dc_index]->state(), |
150 kMaxWait); | 152 kMaxWait); |
151 } | 153 } |
152 | 154 |
153 protected: | 155 protected: |
| 156 rtc::Thread worker_thread_; |
154 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; | 157 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; |
155 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; | 158 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; |
156 DataChannelList caller_signaled_data_channels_; | 159 DataChannelList caller_signaled_data_channels_; |
157 DataChannelList callee_signaled_data_channels_; | 160 DataChannelList callee_signaled_data_channels_; |
158 }; | 161 }; |
159 | 162 |
160 // Disabled for TSan v2, see | 163 // Disabled for TSan v2, see |
161 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. | 164 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4719 for details. |
162 // Disabled for Mac, see | 165 // Disabled for Mac, see |
163 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. | 166 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5231 for details. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); | 364 WaitForDataChannelsToOpen(caller_dc, callee_signaled_data_channels_, 0); |
362 // This removes the reference to the remote data channel that we hold. | 365 // This removes the reference to the remote data channel that we hold. |
363 callee_signaled_data_channels_.clear(); | 366 callee_signaled_data_channels_.clear(); |
364 caller_dc->Close(); | 367 caller_dc->Close(); |
365 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); | 368 EXPECT_EQ_WAIT(DataChannelInterface::kClosed, caller_dc->state(), kMaxWait); |
366 | 369 |
367 // Wait for a bit longer so the remote data channel will receive the | 370 // Wait for a bit longer so the remote data channel will receive the |
368 // close message and be destroyed. | 371 // close message and be destroyed. |
369 rtc::Thread::Current()->ProcessMessages(100); | 372 rtc::Thread::Current()->ProcessMessages(100); |
370 } | 373 } |
OLD | NEW |