| 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 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 EXPECT_TRUE_WAIT(callback->report(), kGetStatsReportTimeoutMs); | 489 EXPECT_TRUE_WAIT(callback->report(), kGetStatsReportTimeoutMs); |
| 490 int64_t after = rtc::TimeUTCMicros(); | 490 int64_t after = rtc::TimeUTCMicros(); |
| 491 for (const RTCStats& stats : *callback->report()) { | 491 for (const RTCStats& stats : *callback->report()) { |
| 492 EXPECT_LE(stats.timestamp_us(), after); | 492 EXPECT_LE(stats.timestamp_us(), after); |
| 493 } | 493 } |
| 494 return callback->report(); | 494 return callback->report(); |
| 495 } | 495 } |
| 496 | 496 |
| 497 void ExpectReportContainsCertificateInfo( | 497 void ExpectReportContainsCertificateInfo( |
| 498 const rtc::scoped_refptr<const RTCStatsReport>& report, | 498 const rtc::scoped_refptr<const RTCStatsReport>& report, |
| 499 const CertificateInfo& cert_info) { | 499 const CertificateInfo& certinfo) { |
| 500 for (size_t i = 0; i < cert_info.fingerprints.size(); ++i) { | 500 for (size_t i = 0; i < certinfo.fingerprints.size(); ++i) { |
| 501 const RTCStats* stats = report->Get( | 501 RTCCertificateStats expected_certificate_stats( |
| 502 "RTCCertificate_" + cert_info.fingerprints[i]); | 502 "RTCCertificate_" + certinfo.fingerprints[i], |
| 503 ASSERT_TRUE(stats); | 503 report->timestamp_us()); |
| 504 const RTCCertificateStats& cert_stats = | 504 expected_certificate_stats.fingerprint = certinfo.fingerprints[i]; |
| 505 stats->cast_to<const RTCCertificateStats>(); | 505 expected_certificate_stats.fingerprint_algorithm = "sha-1"; |
| 506 EXPECT_EQ(*cert_stats.fingerprint, cert_info.fingerprints[i]); | 506 expected_certificate_stats.base64_certificate = certinfo.pems[i]; |
| 507 EXPECT_EQ(*cert_stats.fingerprint_algorithm, "sha-1"); | 507 if (i + 1 < certinfo.fingerprints.size()) { |
| 508 EXPECT_EQ(*cert_stats.base64_certificate, cert_info.pems[i]); | 508 expected_certificate_stats.issuer_certificate_id = |
| 509 if (i + 1 < cert_info.fingerprints.size()) { | 509 "RTCCertificate_" + certinfo.fingerprints[i + 1]; |
| 510 EXPECT_EQ(*cert_stats.issuer_certificate_id, | |
| 511 "RTCCertificate_" + cert_info.fingerprints[i + 1]); | |
| 512 } else { | |
| 513 EXPECT_FALSE(cert_stats.issuer_certificate_id.is_defined()); | |
| 514 } | 510 } |
| 511 ASSERT_TRUE(report->Get(expected_certificate_stats.id())); |
| 512 EXPECT_EQ(expected_certificate_stats, |
| 513 report->Get(expected_certificate_stats.id())->cast_to< |
| 514 RTCCertificateStats>()); |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 protected: | 518 protected: |
| 519 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; | 519 rtc::scoped_refptr<RTCStatsCollectorTestHelper> test_; |
| 520 rtc::scoped_refptr<RTCStatsCollector> collector_; | 520 rtc::scoped_refptr<RTCStatsCollector> collector_; |
| 521 }; | 521 }; |
| 522 | 522 |
| 523 TEST_F(RTCStatsCollectorTest, SingleCallback) { | 523 TEST_F(RTCStatsCollectorTest, SingleCallback) { |
| 524 rtc::scoped_refptr<const RTCStatsReport> result; | 524 rtc::scoped_refptr<const RTCStatsReport> result; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 })); | 600 })); |
| 601 EXPECT_CALL(test_->session(), | 601 EXPECT_CALL(test_->session(), |
| 602 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( | 602 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( |
| 603 [this, &remote_certinfo](const std::string& transport_name) { | 603 [this, &remote_certinfo](const std::string& transport_name) { |
| 604 if (transport_name == "transport") | 604 if (transport_name == "transport") |
| 605 return remote_certinfo->certificate->ssl_certificate().GetReference(); | 605 return remote_certinfo->certificate->ssl_certificate().GetReference(); |
| 606 return static_cast<rtc::SSLCertificate*>(nullptr); | 606 return static_cast<rtc::SSLCertificate*>(nullptr); |
| 607 })); | 607 })); |
| 608 | 608 |
| 609 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 609 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 610 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); | 610 ExpectReportContainsCertificateInfo(report, *local_certinfo); |
| 611 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); | 611 ExpectReportContainsCertificateInfo(report, *remote_certinfo); |
| 612 } | 612 } |
| 613 | 613 |
| 614 TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) { | 614 TEST_F(RTCStatsCollectorTest, CollectRTCCodecStats) { |
| 615 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 615 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 616 cricket::VoiceChannel voice_channel( | 616 cricket::VoiceChannel voice_channel( |
| 617 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 617 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 618 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, | 618 voice_media_channel, nullptr, "VoiceContentName", kDefaultRtcpEnabled, |
| 619 kDefaultSrtpRequired); | 619 kDefaultSrtpRequired); |
| 620 | 620 |
| 621 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); | 621 MockVideoMediaChannel* video_media_channel = new MockVideoMediaChannel(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 .GetReference(); | 779 .GetReference(); |
| 780 } | 780 } |
| 781 if (transport_name == "video") { | 781 if (transport_name == "video") { |
| 782 return video_remote_certinfo->certificate->ssl_certificate() | 782 return video_remote_certinfo->certificate->ssl_certificate() |
| 783 .GetReference(); | 783 .GetReference(); |
| 784 } | 784 } |
| 785 return static_cast<rtc::SSLCertificate*>(nullptr); | 785 return static_cast<rtc::SSLCertificate*>(nullptr); |
| 786 })); | 786 })); |
| 787 | 787 |
| 788 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 788 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 789 ExpectReportContainsCertificateInfo(report, *audio_local_certinfo.get()); | 789 ExpectReportContainsCertificateInfo(report, *audio_local_certinfo); |
| 790 ExpectReportContainsCertificateInfo(report, *audio_remote_certinfo.get()); | 790 ExpectReportContainsCertificateInfo(report, *audio_remote_certinfo); |
| 791 ExpectReportContainsCertificateInfo(report, *video_local_certinfo.get()); | 791 ExpectReportContainsCertificateInfo(report, *video_local_certinfo); |
| 792 ExpectReportContainsCertificateInfo(report, *video_remote_certinfo.get()); | 792 ExpectReportContainsCertificateInfo(report, *video_remote_certinfo); |
| 793 } | 793 } |
| 794 | 794 |
| 795 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) { | 795 TEST_F(RTCStatsCollectorTest, CollectRTCCertificateStatsChain) { |
| 796 std::vector<std::string> local_ders; | 796 std::vector<std::string> local_ders; |
| 797 local_ders.push_back("(local) this"); | 797 local_ders.push_back("(local) this"); |
| 798 local_ders.push_back("(local) is"); | 798 local_ders.push_back("(local) is"); |
| 799 local_ders.push_back("(local) a"); | 799 local_ders.push_back("(local) a"); |
| 800 local_ders.push_back("(local) chain"); | 800 local_ders.push_back("(local) chain"); |
| 801 std::unique_ptr<CertificateInfo> local_certinfo = | 801 std::unique_ptr<CertificateInfo> local_certinfo = |
| 802 CreateFakeCertificateAndInfoFromDers(local_ders); | 802 CreateFakeCertificateAndInfoFromDers(local_ders); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 826 })); | 826 })); |
| 827 EXPECT_CALL(test_->session(), | 827 EXPECT_CALL(test_->session(), |
| 828 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( | 828 GetRemoteSSLCertificate_ReturnsRawPointer(_)).WillRepeatedly(Invoke( |
| 829 [this, &remote_certinfo](const std::string& transport_name) { | 829 [this, &remote_certinfo](const std::string& transport_name) { |
| 830 if (transport_name == "transport") | 830 if (transport_name == "transport") |
| 831 return remote_certinfo->certificate->ssl_certificate().GetReference(); | 831 return remote_certinfo->certificate->ssl_certificate().GetReference(); |
| 832 return static_cast<rtc::SSLCertificate*>(nullptr); | 832 return static_cast<rtc::SSLCertificate*>(nullptr); |
| 833 })); | 833 })); |
| 834 | 834 |
| 835 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 835 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
| 836 ExpectReportContainsCertificateInfo(report, *local_certinfo.get()); | 836 ExpectReportContainsCertificateInfo(report, *local_certinfo); |
| 837 ExpectReportContainsCertificateInfo(report, *remote_certinfo.get()); | 837 ExpectReportContainsCertificateInfo(report, *remote_certinfo); |
| 838 } | 838 } |
| 839 | 839 |
| 840 TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { | 840 TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { |
| 841 test_->data_channels().push_back( | 841 test_->data_channels().push_back( |
| 842 new MockDataChannel( | 842 new MockDataChannel( |
| 843 0, "MockDataChannel0", DataChannelInterface::kConnecting, "udp", | 843 0, "MockDataChannel0", DataChannelInterface::kConnecting, "udp", |
| 844 1, 2, 3, 4)); | 844 1, 2, 3, 4)); |
| 845 RTCDataChannelStats expected_data_channel0("RTCDataChannel_0", 0); | 845 RTCDataChannelStats expected_data_channel0("RTCDataChannel_0", 0); |
| 846 expected_data_channel0.label = "MockDataChannel0"; | 846 expected_data_channel0.label = "MockDataChannel0"; |
| 847 expected_data_channel0.protocol = "udp"; | 847 expected_data_channel0.protocol = "udp"; |
| (...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1986 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1987 }; | 1987 }; |
| 1988 | 1988 |
| 1989 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1989 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1990 collector_->VerifyThreadUsageAndResultsMerging(); | 1990 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1991 } | 1991 } |
| 1992 | 1992 |
| 1993 } // namespace | 1993 } // namespace |
| 1994 | 1994 |
| 1995 } // namespace webrtc | 1995 } // namespace webrtc |
| OLD | NEW |