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

Side by Side Diff: webrtc/pc/rtcstatscollector_unittest.cc

Issue 3005433002: Fix places that trigger no-unused-lambda-capture (Closed)
Patch Set: Rebased Created 3 years, 4 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 * 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
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) { 714 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsSingle) {
715 std::unique_ptr<CertificateInfo> local_certinfo = 715 std::unique_ptr<CertificateInfo> local_certinfo =
716 CreateFakeCertificateAndInfoFromDers( 716 CreateFakeCertificateAndInfoFromDers(
717 std::vector<std::string>({ "(local) single certificate" })); 717 std::vector<std::string>({ "(local) single certificate" }));
718 std::unique_ptr<CertificateInfo> remote_certinfo = 718 std::unique_ptr<CertificateInfo> remote_certinfo =
719 CreateFakeCertificateAndInfoFromDers( 719 CreateFakeCertificateAndInfoFromDers(
720 std::vector<std::string>({ "(remote) single certificate" })); 720 std::vector<std::string>({ "(remote) single certificate" }));
721 721
722 // Mock the session to return the local and remote certificates. 722 // Mock the session to return the local and remote certificates.
723 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( 723 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
724 [this](const ChannelNamePairs&) { 724 [](const ChannelNamePairs&) {
725 std::unique_ptr<SessionStats> stats(new SessionStats()); 725 std::unique_ptr<SessionStats> stats(new SessionStats());
726 stats->transport_stats["transport"].transport_name = "transport"; 726 stats->transport_stats["transport"].transport_name = "transport";
727 return stats; 727 return stats;
728 })); 728 }));
729 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 729 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
730 Invoke([this, &local_certinfo](const std::string& transport_name, 730 Invoke([&local_certinfo](const std::string& transport_name,
731 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 731 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
732 if (transport_name == "transport") { 732 if (transport_name == "transport") {
733 *certificate = local_certinfo->certificate; 733 *certificate = local_certinfo->certificate;
734 return true; 734 return true;
735 } 735 }
736 return false; 736 return false;
737 })); 737 }));
738 EXPECT_CALL(test_->session(), 738 EXPECT_CALL(test_->session(),
739 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 739 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
740 [this, &remote_certinfo](const std::string& transport_name) { 740 [&remote_certinfo](const std::string& transport_name) {
741 if (transport_name == "transport") 741 if (transport_name == "transport")
742 return remote_certinfo->certificate->ssl_certificate().GetReference(); 742 return remote_certinfo->certificate->ssl_certificate().GetReference();
743 return static_cast<rtc::SSLCertificate*>(nullptr); 743 return static_cast<rtc::SSLCertificate*>(nullptr);
744 })); 744 }));
745 745
746 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 746 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
747 ExpectReportContainsCertificateInfo(report, *local_certinfo); 747 ExpectReportContainsCertificateInfo(report, *local_certinfo);
748 ExpectReportContainsCertificateInfo(report, *remote_certinfo); 748 ExpectReportContainsCertificateInfo(report, *remote_certinfo);
749 } 749 }
750 750
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 video_local_certinfo = CreateFakeCertificateAndInfoFromDers( 885 video_local_certinfo = CreateFakeCertificateAndInfoFromDers(
886 video_local_certinfo->ders); 886 video_local_certinfo->ders);
887 std::unique_ptr<CertificateInfo> video_remote_certinfo = 887 std::unique_ptr<CertificateInfo> video_remote_certinfo =
888 CreateFakeCertificateAndInfoFromDers( 888 CreateFakeCertificateAndInfoFromDers(
889 std::vector<std::string>({ "(remote) video" })); 889 std::vector<std::string>({ "(remote) video" }));
890 video_remote_certinfo = CreateFakeCertificateAndInfoFromDers( 890 video_remote_certinfo = CreateFakeCertificateAndInfoFromDers(
891 video_remote_certinfo->ders); 891 video_remote_certinfo->ders);
892 892
893 // Mock the session to return the local and remote certificates. 893 // Mock the session to return the local and remote certificates.
894 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( 894 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
895 [this](const ChannelNamePairs&) { 895 [](const ChannelNamePairs&) {
896 std::unique_ptr<SessionStats> stats(new SessionStats()); 896 std::unique_ptr<SessionStats> stats(new SessionStats());
897 stats->transport_stats["audio"].transport_name = "audio"; 897 stats->transport_stats["audio"].transport_name = "audio";
898 stats->transport_stats["video"].transport_name = "video"; 898 stats->transport_stats["video"].transport_name = "video";
899 return stats; 899 return stats;
900 })); 900 }));
901 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 901 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
902 Invoke([this, &audio_local_certinfo, &video_local_certinfo]( 902 Invoke([&audio_local_certinfo, &video_local_certinfo](
903 const std::string& transport_name, 903 const std::string& transport_name,
904 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 904 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
905 if (transport_name == "audio") { 905 if (transport_name == "audio") {
906 *certificate = audio_local_certinfo->certificate; 906 *certificate = audio_local_certinfo->certificate;
907 return true; 907 return true;
908 } 908 }
909 if (transport_name == "video") { 909 if (transport_name == "video") {
910 *certificate = video_local_certinfo->certificate; 910 *certificate = video_local_certinfo->certificate;
911 return true; 911 return true;
912 } 912 }
913 return false; 913 return false;
914 })); 914 }));
915 EXPECT_CALL(test_->session(), 915 EXPECT_CALL(test_->session(),
916 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 916 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
917 [this, &audio_remote_certinfo, &video_remote_certinfo]( 917 [&audio_remote_certinfo, &video_remote_certinfo](
918 const std::string& transport_name) { 918 const std::string& transport_name) {
919 if (transport_name == "audio") { 919 if (transport_name == "audio") {
920 return audio_remote_certinfo->certificate->ssl_certificate() 920 return audio_remote_certinfo->certificate->ssl_certificate()
921 .GetReference(); 921 .GetReference();
922 } 922 }
923 if (transport_name == "video") { 923 if (transport_name == "video") {
924 return video_remote_certinfo->certificate->ssl_certificate() 924 return video_remote_certinfo->certificate->ssl_certificate()
925 .GetReference(); 925 .GetReference();
926 } 926 }
927 return static_cast<rtc::SSLCertificate*>(nullptr); 927 return static_cast<rtc::SSLCertificate*>(nullptr);
(...skipping 17 matching lines...) Expand all
945 std::vector<std::string> remote_ders; 945 std::vector<std::string> remote_ders;
946 remote_ders.push_back("(remote) this"); 946 remote_ders.push_back("(remote) this");
947 remote_ders.push_back("(remote) is"); 947 remote_ders.push_back("(remote) is");
948 remote_ders.push_back("(remote) another"); 948 remote_ders.push_back("(remote) another");
949 remote_ders.push_back("(remote) chain"); 949 remote_ders.push_back("(remote) chain");
950 std::unique_ptr<CertificateInfo> remote_certinfo = 950 std::unique_ptr<CertificateInfo> remote_certinfo =
951 CreateFakeCertificateAndInfoFromDers(remote_ders); 951 CreateFakeCertificateAndInfoFromDers(remote_ders);
952 952
953 // Mock the session to return the local and remote certificates. 953 // Mock the session to return the local and remote certificates.
954 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( 954 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke(
955 [this](const ChannelNamePairs&) { 955 [](const ChannelNamePairs&) {
956 std::unique_ptr<SessionStats> stats(new SessionStats()); 956 std::unique_ptr<SessionStats> stats(new SessionStats());
957 stats->transport_stats["transport"].transport_name = "transport"; 957 stats->transport_stats["transport"].transport_name = "transport";
958 return stats; 958 return stats;
959 })); 959 }));
960 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 960 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
961 Invoke([this, &local_certinfo](const std::string& transport_name, 961 Invoke([&local_certinfo](const std::string& transport_name,
962 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 962 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
963 if (transport_name == "transport") { 963 if (transport_name == "transport") {
964 *certificate = local_certinfo->certificate; 964 *certificate = local_certinfo->certificate;
965 return true; 965 return true;
966 } 966 }
967 return false; 967 return false;
968 })); 968 }));
969 EXPECT_CALL(test_->session(), 969 EXPECT_CALL(test_->session(),
970 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 970 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
971 [this, &remote_certinfo](const std::string& transport_name) { 971 [&remote_certinfo](const std::string& transport_name) {
972 if (transport_name == "transport") 972 if (transport_name == "transport")
973 return remote_certinfo->certificate->ssl_certificate().GetReference(); 973 return remote_certinfo->certificate->ssl_certificate().GetReference();
974 return static_cast<rtc::SSLCertificate*>(nullptr); 974 return static_cast<rtc::SSLCertificate*>(nullptr);
975 })); 975 }));
976 976
977 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); 977 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport();
978 ExpectReportContainsCertificateInfo(report, *local_certinfo); 978 ExpectReportContainsCertificateInfo(report, *local_certinfo);
979 ExpectReportContainsCertificateInfo(report, *remote_certinfo); 979 ExpectReportContainsCertificateInfo(report, *remote_certinfo);
980 } 980 }
981 981
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); 2271 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>());
2272 2272
2273 // Get stats with certificates. 2273 // Get stats with certificates.
2274 std::unique_ptr<CertificateInfo> local_certinfo = 2274 std::unique_ptr<CertificateInfo> local_certinfo =
2275 CreateFakeCertificateAndInfoFromDers( 2275 CreateFakeCertificateAndInfoFromDers(
2276 std::vector<std::string>({ "(local) local", "(local) chain" })); 2276 std::vector<std::string>({ "(local) local", "(local) chain" }));
2277 std::unique_ptr<CertificateInfo> remote_certinfo = 2277 std::unique_ptr<CertificateInfo> remote_certinfo =
2278 CreateFakeCertificateAndInfoFromDers( 2278 CreateFakeCertificateAndInfoFromDers(
2279 std::vector<std::string>({ "(remote) local", "(remote) chain" })); 2279 std::vector<std::string>({ "(remote) local", "(remote) chain" }));
2280 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly( 2280 EXPECT_CALL(test_->session(), GetLocalCertificate(_, _)).WillRepeatedly(
2281 Invoke([this, &local_certinfo](const std::string& transport_name, 2281 Invoke([&local_certinfo](const std::string& transport_name,
2282 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 2282 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
2283 if (transport_name == "transport") { 2283 if (transport_name == "transport") {
2284 *certificate = local_certinfo->certificate; 2284 *certificate = local_certinfo->certificate;
2285 return true; 2285 return true;
2286 } 2286 }
2287 return false; 2287 return false;
2288 })); 2288 }));
2289 EXPECT_CALL(test_->session(), 2289 EXPECT_CALL(test_->session(),
2290 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( 2290 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke(
2291 [this, &remote_certinfo](const std::string& transport_name) { 2291 [&remote_certinfo](const std::string& transport_name) {
2292 if (transport_name == "transport") 2292 if (transport_name == "transport")
2293 return remote_certinfo->certificate->ssl_certificate().GetReference(); 2293 return remote_certinfo->certificate->ssl_certificate().GetReference();
2294 return static_cast<rtc::SSLCertificate*>(nullptr); 2294 return static_cast<rtc::SSLCertificate*>(nullptr);
2295 })); 2295 }));
2296 2296
2297 collector_->ClearCachedStatsReport(); 2297 collector_->ClearCachedStatsReport();
2298 report = GetStatsReport(); 2298 report = GetStatsReport();
2299 2299
2300 expected_rtp_transport.local_certificate_id = 2300 expected_rtp_transport.local_certificate_id =
2301 "RTCCertificate_" + local_certinfo->fingerprints[0]; 2301 "RTCCertificate_" + local_certinfo->fingerprints[0];
(...skipping 28 matching lines...) Expand all
2330 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; 2330 rtc::scoped_refptr<FakeRTCStatsCollector> collector_;
2331 }; 2331 };
2332 2332
2333 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { 2333 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) {
2334 collector_->VerifyThreadUsageAndResultsMerging(); 2334 collector_->VerifyThreadUsageAndResultsMerging();
2335 } 2335 }
2336 2336
2337 } // namespace 2337 } // namespace
2338 2338
2339 } // namespace webrtc 2339 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698