OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 <set> | 11 #include <set> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | 14 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" |
15 #include "webrtc/api/datachannelinterface.h" | 15 #include "webrtc/api/datachannelinterface.h" |
16 #include "webrtc/api/peerconnectioninterface.h" | 16 #include "webrtc/api/peerconnectioninterface.h" |
17 #include "webrtc/api/stats/rtcstats_objects.h" | 17 #include "webrtc/api/stats/rtcstats_objects.h" |
18 #include "webrtc/api/stats/rtcstatsreport.h" | 18 #include "webrtc/api/stats/rtcstatsreport.h" |
19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
20 #include "webrtc/base/gunit.h" | 20 #include "webrtc/base/gunit.h" |
21 #include "webrtc/base/physicalsocketserver.h" | |
22 #include "webrtc/base/refcountedobject.h" | 21 #include "webrtc/base/refcountedobject.h" |
23 #include "webrtc/base/scoped_ref_ptr.h" | 22 #include "webrtc/base/scoped_ref_ptr.h" |
24 #include "webrtc/base/virtualsocketserver.h" | 23 #include "webrtc/base/virtualsocketserver.h" |
25 #include "webrtc/pc/test/peerconnectiontestwrapper.h" | 24 #include "webrtc/pc/test/peerconnectiontestwrapper.h" |
26 #include "webrtc/pc/test/rtcstatsobtainer.h" | 25 #include "webrtc/pc/test/rtcstatsobtainer.h" |
27 | 26 |
28 namespace webrtc { | 27 namespace webrtc { |
29 | 28 |
30 namespace { | 29 namespace { |
31 | 30 |
32 const int64_t kGetStatsTimeoutMs = 10000; | 31 const int64_t kGetStatsTimeoutMs = 10000; |
33 | 32 |
34 class RTCStatsIntegrationTest : public testing::Test { | 33 class RTCStatsIntegrationTest : public testing::Test { |
35 public: | 34 public: |
36 RTCStatsIntegrationTest() | 35 RTCStatsIntegrationTest() |
37 : physical_socket_server_(), | 36 : network_thread_(&virtual_socket_server_), worker_thread_() { |
38 virtual_socket_server_(&physical_socket_server_), | |
39 network_thread_(&virtual_socket_server_), | |
40 worker_thread_() { | |
41 RTC_CHECK(network_thread_.Start()); | 37 RTC_CHECK(network_thread_.Start()); |
42 RTC_CHECK(worker_thread_.Start()); | 38 RTC_CHECK(worker_thread_.Start()); |
43 | 39 |
44 caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 40 caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
45 "caller", &network_thread_, &worker_thread_); | 41 "caller", &network_thread_, &worker_thread_); |
46 callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( | 42 callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>( |
47 "callee", &network_thread_, &worker_thread_); | 43 "callee", &network_thread_, &worker_thread_); |
48 } | 44 } |
49 | 45 |
50 void StartCall() { | 46 void StartCall() { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 protected: | 85 protected: |
90 static rtc::scoped_refptr<const RTCStatsReport> GetStats( | 86 static rtc::scoped_refptr<const RTCStatsReport> GetStats( |
91 PeerConnectionInterface* pc) { | 87 PeerConnectionInterface* pc) { |
92 rtc::scoped_refptr<RTCStatsObtainer> stats_obtainer = | 88 rtc::scoped_refptr<RTCStatsObtainer> stats_obtainer = |
93 RTCStatsObtainer::Create(); | 89 RTCStatsObtainer::Create(); |
94 pc->GetStats(stats_obtainer); | 90 pc->GetStats(stats_obtainer); |
95 EXPECT_TRUE_WAIT(stats_obtainer->report(), kGetStatsTimeoutMs); | 91 EXPECT_TRUE_WAIT(stats_obtainer->report(), kGetStatsTimeoutMs); |
96 return stats_obtainer->report(); | 92 return stats_obtainer->report(); |
97 } | 93 } |
98 | 94 |
99 // These objects use each other and must be constructed/destroyed in this | 95 // |network_thread_| uses |virtual_socket_server_| so they must be |
100 // order. Relationship: | 96 // constructed/destructed in the correct order. |
101 // |physical_socket_server_| <- |virtual_socket_server_| <- |network_thread_| | |
102 rtc::PhysicalSocketServer physical_socket_server_; | |
103 rtc::VirtualSocketServer virtual_socket_server_; | 97 rtc::VirtualSocketServer virtual_socket_server_; |
104 rtc::Thread network_thread_; | 98 rtc::Thread network_thread_; |
105 rtc::Thread worker_thread_; | 99 rtc::Thread worker_thread_; |
106 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; | 100 rtc::scoped_refptr<PeerConnectionTestWrapper> caller_; |
107 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; | 101 rtc::scoped_refptr<PeerConnectionTestWrapper> callee_; |
108 }; | 102 }; |
109 | 103 |
110 class RTCStatsVerifier { | 104 class RTCStatsVerifier { |
111 public: | 105 public: |
112 RTCStatsVerifier(const RTCStatsReport* report, const RTCStats* stats) | 106 RTCStatsVerifier(const RTCStatsReport* report, const RTCStats* stats) |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 caller_ = nullptr; | 640 caller_ = nullptr; |
647 // Any pending stats requests should have completed in the act of destroying | 641 // Any pending stats requests should have completed in the act of destroying |
648 // the peer connection. | 642 // the peer connection. |
649 EXPECT_TRUE(stats_obtainer->report()); | 643 EXPECT_TRUE(stats_obtainer->report()); |
650 } | 644 } |
651 #endif // HAVE_SCTP | 645 #endif // HAVE_SCTP |
652 | 646 |
653 } // namespace | 647 } // namespace |
654 | 648 |
655 } // namespace webrtc | 649 } // namespace webrtc |
OLD | NEW |