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

Side by Side Diff: talk/app/webrtc/webrtcsession_unittest.cc

Issue 1156143005: Report metrics about negotiated ciphers. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed properties and provide accessors. Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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,
11 * this list of conditions and the following disclaimer in the documentation 11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution. 12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products 13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/app/webrtc/audiotrack.h" 28 #include "talk/app/webrtc/audiotrack.h"
29 #include "talk/app/webrtc/fakemetricsobserver.h"
29 #include "talk/app/webrtc/jsepicecandidate.h" 30 #include "talk/app/webrtc/jsepicecandidate.h"
30 #include "talk/app/webrtc/jsepsessiondescription.h" 31 #include "talk/app/webrtc/jsepsessiondescription.h"
31 #include "talk/app/webrtc/mediastreamsignaling.h" 32 #include "talk/app/webrtc/mediastreamsignaling.h"
32 #include "talk/app/webrtc/streamcollection.h" 33 #include "talk/app/webrtc/streamcollection.h"
33 #include "talk/app/webrtc/test/fakeconstraints.h" 34 #include "talk/app/webrtc/test/fakeconstraints.h"
34 #include "talk/app/webrtc/test/fakedtlsidentityservice.h" 35 #include "talk/app/webrtc/test/fakedtlsidentityservice.h"
35 #include "talk/app/webrtc/test/fakemediastreamsignaling.h" 36 #include "talk/app/webrtc/test/fakemediastreamsignaling.h"
36 #include "talk/app/webrtc/videotrack.h" 37 #include "talk/app/webrtc/videotrack.h"
37 #include "talk/app/webrtc/webrtcsession.h" 38 #include "talk/app/webrtc/webrtcsession.h"
38 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h" 39 #include "talk/app/webrtc/webrtcsessiondescriptionfactory.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 using cricket::TransportInfo; 75 using cricket::TransportInfo;
75 using rtc::SocketAddress; 76 using rtc::SocketAddress;
76 using rtc::scoped_ptr; 77 using rtc::scoped_ptr;
77 using rtc::Thread; 78 using rtc::Thread;
78 using webrtc::CreateSessionDescription; 79 using webrtc::CreateSessionDescription;
79 using webrtc::CreateSessionDescriptionObserver; 80 using webrtc::CreateSessionDescriptionObserver;
80 using webrtc::CreateSessionDescriptionRequest; 81 using webrtc::CreateSessionDescriptionRequest;
81 using webrtc::DTLSIdentityRequestObserver; 82 using webrtc::DTLSIdentityRequestObserver;
82 using webrtc::DTLSIdentityServiceInterface; 83 using webrtc::DTLSIdentityServiceInterface;
83 using webrtc::FakeConstraints; 84 using webrtc::FakeConstraints;
85 using webrtc::FakeMetricsObserver;
84 using webrtc::IceCandidateCollection; 86 using webrtc::IceCandidateCollection;
85 using webrtc::JsepIceCandidate; 87 using webrtc::JsepIceCandidate;
86 using webrtc::JsepSessionDescription; 88 using webrtc::JsepSessionDescription;
87 using webrtc::PeerConnectionFactoryInterface; 89 using webrtc::PeerConnectionFactoryInterface;
88 using webrtc::PeerConnectionInterface; 90 using webrtc::PeerConnectionInterface;
89 using webrtc::SessionDescriptionInterface; 91 using webrtc::SessionDescriptionInterface;
90 using webrtc::StreamCollection; 92 using webrtc::StreamCollection;
91 using webrtc::WebRtcSession; 93 using webrtc::WebRtcSession;
92 using webrtc::kBundleWithoutRtcpMux; 94 using webrtc::kBundleWithoutRtcpMux;
93 using webrtc::kCreateChannelFailed; 95 using webrtc::kCreateChannelFailed;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 160
159 // Add some extra |newlines| to the |message| after |line|. 161 // Add some extra |newlines| to the |message| after |line|.
160 static void InjectAfter(const std::string& line, 162 static void InjectAfter(const std::string& line,
161 const std::string& newlines, 163 const std::string& newlines,
162 std::string* message) { 164 std::string* message) {
163 const std::string tmp = line + newlines; 165 const std::string tmp = line + newlines;
164 rtc::replace_substrs(line.c_str(), line.length(), 166 rtc::replace_substrs(line.c_str(), line.length(),
165 tmp.c_str(), tmp.length(), message); 167 tmp.c_str(), tmp.length(), message);
166 } 168 }
167 169
168 class FakeMetricsObserver : public webrtc::MetricsObserverInterface {
169 public:
170 FakeMetricsObserver() { Reset(); }
171 void Reset() {
172 memset(peer_connection_metrics_counters_, 0,
173 sizeof(peer_connection_metrics_counters_));
174 memset(peer_connection_metrics_name_, 0,
175 sizeof(peer_connection_metrics_name_));
176 }
177
178 void IncrementCounter(webrtc::PeerConnectionMetricsCounter type) override {
179 peer_connection_metrics_counters_[type]++;
180 }
181 void AddHistogramSample(webrtc::PeerConnectionMetricsName type,
182 int value) override {
183 ASSERT(peer_connection_metrics_name_[type] == 0);
184 peer_connection_metrics_name_[type] = value;
185 }
186
187 int peer_connection_metrics_counters_
188 [webrtc::kPeerConnectionMetricsCounter_Max];
189 int peer_connection_metrics_name_[webrtc::kPeerConnectionMetricsCounter_Max];
190
191 int AddRef() override { return 1; }
192 int Release() override { return 1; }
193 };
194
195 class MockIceObserver : public webrtc::IceObserver { 170 class MockIceObserver : public webrtc::IceObserver {
196 public: 171 public:
197 MockIceObserver() 172 MockIceObserver()
198 : oncandidatesready_(false), 173 : oncandidatesready_(false),
199 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), 174 ice_connection_state_(PeerConnectionInterface::kIceConnectionNew),
200 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) { 175 ice_gathering_state_(PeerConnectionInterface::kIceGatheringNew) {
201 } 176 }
202 177
203 virtual void OnIceConnectionChange( 178 virtual void OnIceConnectionChange(
204 PeerConnectionInterface::IceConnectionState new_state) { 179 PeerConnectionInterface::IceConnectionState new_state) {
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 998
1024 void VerifyBestConnectionAfterIceConverge( 999 void VerifyBestConnectionAfterIceConverge(
1025 const FakeMetricsObserver& metrics_observer) const { 1000 const FakeMetricsObserver& metrics_observer) const {
1026 Verify(metrics_observer, best_connection_after_initial_ice_converged_); 1001 Verify(metrics_observer, best_connection_after_initial_ice_converged_);
1027 } 1002 }
1028 1003
1029 private: 1004 private:
1030 void Verify(const FakeMetricsObserver& metrics_observer, 1005 void Verify(const FakeMetricsObserver& metrics_observer,
1031 const ExpectedBestConnection& expected) const { 1006 const ExpectedBestConnection& expected) const {
1032 EXPECT_EQ( 1007 EXPECT_EQ(
1033 metrics_observer 1008 metrics_observer.GetCounter(webrtc::kBestConnections_IPv4),
1034 .peer_connection_metrics_counters_[webrtc::kBestConnections_IPv4],
1035 expected.ipv4_count_); 1009 expected.ipv4_count_);
1036 EXPECT_EQ( 1010 EXPECT_EQ(
1037 metrics_observer 1011 metrics_observer.GetCounter(webrtc::kBestConnections_IPv6),
1038 .peer_connection_metrics_counters_[webrtc::kBestConnections_IPv6],
1039 expected.ipv6_count_); 1012 expected.ipv6_count_);
1040 } 1013 }
1041 }; 1014 };
1042 1015
1043 class LoopbackNetworkManager { 1016 class LoopbackNetworkManager {
1044 public: 1017 public:
1045 LoopbackNetworkManager(WebRtcSessionTest* session, 1018 LoopbackNetworkManager(WebRtcSessionTest* session,
1046 const LoopbackNetworkConfiguration& config) 1019 const LoopbackNetworkConfiguration& config)
1047 : config_(config) { 1020 : config_(config) {
1048 session->AddInterface( 1021 session->AddInterface(
(...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 EXPECT_EQ(4000, option_val); 3847 EXPECT_EQ(4000, option_val);
3875 3848
3876 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption( 3849 EXPECT_TRUE(session_->voice_channel()->transport_channel()->GetOption(
3877 rtc::Socket::Option::OPT_RCVBUF, &option_val)); 3850 rtc::Socket::Option::OPT_RCVBUF, &option_val));
3878 EXPECT_EQ(8000, option_val); 3851 EXPECT_EQ(8000, option_val);
3879 } 3852 }
3880 3853
3881 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 3854 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
3882 // currently fails because upon disconnection and reconnection OnIceComplete is 3855 // currently fails because upon disconnection and reconnection OnIceComplete is
3883 // called more than once without returning to IceGatheringGathering. 3856 // called more than once without returning to IceGatheringGathering.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698