Use metrics::Samples in a couple pc/ tests

Bug: None
Change-Id: Ic898d3bdc374ceefc40d7f6be6d2abac3ff584b9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125781
Reviewed-by: Amit Hilbuch <amithi@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26980}
This commit is contained in:
Steve Anton 2019-03-05 14:09:49 -08:00 committed by Commit Bot
parent e2a284d299
commit b443dfe7ba
2 changed files with 21 additions and 25 deletions

View File

@ -32,6 +32,7 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/virtual_socket_server.h"
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
namespace webrtc {
@ -39,6 +40,8 @@ using RTCConfiguration = PeerConnectionInterface::RTCConfiguration;
using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
using rtc::SocketAddress;
using ::testing::Combine;
using ::testing::ElementsAre;
using ::testing::Pair;
using ::testing::Values;
constexpr int kIceCandidatesTimeout = 10000;
@ -435,11 +438,8 @@ TEST_P(PeerConnectionIceTest, CannotAddCandidateWhenRemoteDescriptionNotSet) {
caller->CreateOfferAndSetAsLocal();
EXPECT_FALSE(caller->pc()->AddIceCandidate(jsep_candidate.get()));
EXPECT_EQ(
2, webrtc::metrics::NumSamples("WebRTC.PeerConnection.AddIceCandidate"));
EXPECT_EQ(
2, webrtc::metrics::NumEvents("WebRTC.PeerConnection.AddIceCandidate",
kAddIceCandidateFailNoRemoteDescription));
EXPECT_THAT(webrtc::metrics::Samples("WebRTC.PeerConnection.AddIceCandidate"),
ElementsAre(Pair(kAddIceCandidateFailNoRemoteDescription, 2)));
}
TEST_P(PeerConnectionIceTest, CannotAddCandidateWhenPeerConnectionClosed) {

View File

@ -18,9 +18,13 @@
#include "rtc_base/byte_order.h"
#include "rtc_base/ssl_stream_adapter.h" // For rtc::SRTP_*
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "third_party/libsrtp/include/srtp.h"
using ::testing::ElementsAre;
using ::testing::Pair;
namespace rtc {
std::vector<int> kEncryptedHeaderExtensionIds;
@ -148,17 +152,13 @@ TEST_F(SrtpSessionTest, TestTamperReject) {
rtp_packet_[0] = 0x12;
rtcp_packet_[1] = 0x34;
EXPECT_FALSE(s2_.UnprotectRtp(rtp_packet_, rtp_len_, &out_len));
EXPECT_EQ(1, webrtc::metrics::NumSamples(
"WebRTC.PeerConnection.SrtpUnprotectError"));
EXPECT_EQ(
1, webrtc::metrics::NumEvents("WebRTC.PeerConnection.SrtpUnprotectError",
srtp_err_status_bad_param));
EXPECT_THAT(
webrtc::metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"),
ElementsAre(Pair(srtp_err_status_bad_param, 1)));
EXPECT_FALSE(s2_.UnprotectRtcp(rtcp_packet_, rtcp_len_, &out_len));
EXPECT_EQ(1, webrtc::metrics::NumSamples(
"WebRTC.PeerConnection.SrtcpUnprotectError"));
EXPECT_EQ(
1, webrtc::metrics::NumEvents("WebRTC.PeerConnection.SrtcpUnprotectError",
srtp_err_status_auth_fail));
EXPECT_THAT(
webrtc::metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"),
ElementsAre(Pair(srtp_err_status_auth_fail, 1)));
}
// Test that we fail to unprotect if the payloads are not authenticated.
@ -169,17 +169,13 @@ TEST_F(SrtpSessionTest, TestUnencryptReject) {
EXPECT_TRUE(s2_.SetRecv(SRTP_AES128_CM_SHA1_80, kTestKey1, kTestKeyLen,
kEncryptedHeaderExtensionIds));
EXPECT_FALSE(s2_.UnprotectRtp(rtp_packet_, rtp_len_, &out_len));
EXPECT_EQ(1, webrtc::metrics::NumSamples(
"WebRTC.PeerConnection.SrtpUnprotectError"));
EXPECT_EQ(
1, webrtc::metrics::NumEvents("WebRTC.PeerConnection.SrtpUnprotectError",
srtp_err_status_auth_fail));
EXPECT_THAT(
webrtc::metrics::Samples("WebRTC.PeerConnection.SrtpUnprotectError"),
ElementsAre(Pair(srtp_err_status_auth_fail, 1)));
EXPECT_FALSE(s2_.UnprotectRtcp(rtcp_packet_, rtcp_len_, &out_len));
EXPECT_EQ(1, webrtc::metrics::NumSamples(
"WebRTC.PeerConnection.SrtcpUnprotectError"));
EXPECT_EQ(
1, webrtc::metrics::NumEvents("WebRTC.PeerConnection.SrtcpUnprotectError",
srtp_err_status_cant_check));
EXPECT_THAT(
webrtc::metrics::Samples("WebRTC.PeerConnection.SrtcpUnprotectError"),
ElementsAre(Pair(srtp_err_status_cant_check, 1)));
}
// Test that we fail when using buffers that are too small.