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

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

Issue 1204493002: Set / verify stats report timestamps. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/test/mockpeerconnectionobservers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 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,
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 .WillOnce(DoAll(SetArgPointee<0>(*stats_read), Return(true))); 590 .WillOnce(DoAll(SetArgPointee<0>(*stats_read), Return(true)));
591 591
592 stats->UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 592 stats->UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
593 stats->ClearUpdateStatsCacheForTest(); 593 stats->ClearUpdateStatsCacheForTest();
594 stats->GetStats(NULL, reports); 594 stats->GetStats(NULL, reports);
595 595
596 // Verify the existence of the track report. 596 // Verify the existence of the track report.
597 const StatsReport* report = FindNthReportByType( 597 const StatsReport* report = FindNthReportByType(
598 *reports, StatsReport::kStatsReportTypeSsrc, 1); 598 *reports, StatsReport::kStatsReportTypeSsrc, 1);
599 EXPECT_FALSE(report == NULL); 599 EXPECT_FALSE(report == NULL);
600 EXPECT_EQ(stats->GetTimeNow(), report->timestamp());
600 std::string track_id = ExtractSsrcStatsValue( 601 std::string track_id = ExtractSsrcStatsValue(
601 *reports, StatsReport::kStatsValueNameTrackId); 602 *reports, StatsReport::kStatsValueNameTrackId);
602 EXPECT_EQ(audio_track->id(), track_id); 603 EXPECT_EQ(audio_track->id(), track_id);
603 std::string ssrc_id = ExtractSsrcStatsValue( 604 std::string ssrc_id = ExtractSsrcStatsValue(
604 *reports, StatsReport::kStatsValueNameSsrc); 605 *reports, StatsReport::kStatsValueNameSsrc);
605 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 606 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
606 607
607 // Verifies the values in the track report. 608 // Verifies the values in the track report.
608 if (voice_sender_info) { 609 if (voice_sender_info) {
609 UpdateVoiceSenderInfoFromAudioTrack(audio_track, voice_sender_info); 610 UpdateVoiceSenderInfoFromAudioTrack(audio_track, voice_sender_info);
610 VerifyVoiceSenderInfoReport(report, *voice_sender_info); 611 VerifyVoiceSenderInfoReport(report, *voice_sender_info);
611 } 612 }
612 if (voice_receiver_info) { 613 if (voice_receiver_info) {
613 VerifyVoiceReceiverInfoReport(report, *voice_receiver_info); 614 VerifyVoiceReceiverInfoReport(report, *voice_receiver_info);
614 } 615 }
615 616
616 // Verify we get the same result by passing a track to GetStats(). 617 // Verify we get the same result by passing a track to GetStats().
617 StatsReports track_reports; // returned values. 618 StatsReports track_reports; // returned values.
618 stats->GetStats(audio_track, &track_reports); 619 stats->GetStats(audio_track, &track_reports);
619 const StatsReport* track_report = FindNthReportByType( 620 const StatsReport* track_report = FindNthReportByType(
620 track_reports, StatsReport::kStatsReportTypeSsrc, 1); 621 track_reports, StatsReport::kStatsReportTypeSsrc, 1);
621 EXPECT_TRUE(track_report); 622 EXPECT_TRUE(track_report);
623 EXPECT_EQ(stats->GetTimeNow(), track_report->timestamp());
622 track_id = ExtractSsrcStatsValue(track_reports, 624 track_id = ExtractSsrcStatsValue(track_reports,
623 StatsReport::kStatsValueNameTrackId); 625 StatsReport::kStatsValueNameTrackId);
624 EXPECT_EQ(audio_track->id(), track_id); 626 EXPECT_EQ(audio_track->id(), track_id);
625 ssrc_id = ExtractSsrcStatsValue(track_reports, 627 ssrc_id = ExtractSsrcStatsValue(track_reports,
626 StatsReport::kStatsValueNameSsrc); 628 StatsReport::kStatsValueNameSsrc);
627 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 629 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
628 if (voice_sender_info) 630 if (voice_sender_info)
629 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info); 631 VerifyVoiceSenderInfoReport(track_report, *voice_sender_info);
630 if (voice_receiver_info) 632 if (voice_receiver_info)
631 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info); 633 VerifyVoiceReceiverInfoReport(track_report, *voice_receiver_info);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 cricket::VideoChannel video_channel(rtc::Thread::Current(), 924 cricket::VideoChannel video_channel(rtc::Thread::Current(),
923 media_engine_, media_channel, NULL, "video", false); 925 media_engine_, media_channel, NULL, "video", false);
924 AddOutgoingVideoTrackStats(); 926 AddOutgoingVideoTrackStats();
925 stats.AddStream(stream_); 927 stats.AddStream(stream_);
926 928
927 // Verfies the existence of the track report. 929 // Verfies the existence of the track report.
928 StatsReports reports; 930 StatsReports reports;
929 stats.GetStats(NULL, &reports); 931 stats.GetStats(NULL, &reports);
930 EXPECT_EQ((size_t)1, reports.size()); 932 EXPECT_EQ((size_t)1, reports.size());
931 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type()); 933 EXPECT_EQ(StatsReport::kStatsReportTypeTrack, reports[0]->type());
934 EXPECT_EQ(0, reports[0]->timestamp());
932 935
933 std::string trackValue = 936 std::string trackValue =
934 ExtractStatsValue(StatsReport::kStatsReportTypeTrack, 937 ExtractStatsValue(StatsReport::kStatsReportTypeTrack,
935 reports, 938 reports,
936 StatsReport::kStatsValueNameTrackId); 939 StatsReport::kStatsValueNameTrackId);
937 EXPECT_EQ(kLocalTrackId, trackValue); 940 EXPECT_EQ(kLocalTrackId, trackValue);
938 } 941 }
939 942
940 // This test verifies that the empty track report exists in the returned stats 943 // This test verifies that the empty track report exists in the returned stats
941 // when StatsCollector::UpdateStats is called with ssrc stats. 944 // when StatsCollector::UpdateStats is called with ssrc stats.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 987
985 // Get report for the specific |track|. 988 // Get report for the specific |track|.
986 reports.clear(); 989 reports.clear();
987 stats.GetStats(track_, &reports); 990 stats.GetStats(track_, &reports);
988 // |reports| should contain at least one session report, one track report, 991 // |reports| should contain at least one session report, one track report,
989 // and one ssrc report. 992 // and one ssrc report.
990 EXPECT_LE((size_t)3, reports.size()); 993 EXPECT_LE((size_t)3, reports.size());
991 track_report = FindNthReportByType( 994 track_report = FindNthReportByType(
992 reports, StatsReport::kStatsReportTypeTrack, 1); 995 reports, StatsReport::kStatsReportTypeTrack, 1);
993 EXPECT_TRUE(track_report); 996 EXPECT_TRUE(track_report);
997 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
994 998
995 std::string ssrc_id = ExtractSsrcStatsValue( 999 std::string ssrc_id = ExtractSsrcStatsValue(
996 reports, StatsReport::kStatsValueNameSsrc); 1000 reports, StatsReport::kStatsValueNameSsrc);
997 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1001 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
998 1002
999 std::string track_id = ExtractSsrcStatsValue( 1003 std::string track_id = ExtractSsrcStatsValue(
1000 reports, StatsReport::kStatsValueNameTrackId); 1004 reports, StatsReport::kStatsValueNameTrackId);
1001 EXPECT_EQ(kLocalTrackId, track_id); 1005 EXPECT_EQ(kLocalTrackId, track_id);
1002 } 1006 }
1003 1007
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1176
1173 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 1177 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
1174 StatsReports reports; 1178 StatsReports reports;
1175 stats.GetStats(NULL, &reports); 1179 stats.GetStats(NULL, &reports);
1176 // |reports| should contain at least one session report, one track report, 1180 // |reports| should contain at least one session report, one track report,
1177 // and one ssrc report. 1181 // and one ssrc report.
1178 EXPECT_LE(static_cast<size_t>(3), reports.size()); 1182 EXPECT_LE(static_cast<size_t>(3), reports.size());
1179 const StatsReport* track_report = FindNthReportByType( 1183 const StatsReport* track_report = FindNthReportByType(
1180 reports, StatsReport::kStatsReportTypeTrack, 1); 1184 reports, StatsReport::kStatsReportTypeTrack, 1);
1181 EXPECT_TRUE(track_report); 1185 EXPECT_TRUE(track_report);
1186 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
1182 1187
1183 std::string ssrc_id = ExtractSsrcStatsValue( 1188 std::string ssrc_id = ExtractSsrcStatsValue(
1184 reports, StatsReport::kStatsValueNameSsrc); 1189 reports, StatsReport::kStatsValueNameSsrc);
1185 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1190 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
1186 1191
1187 std::string track_id = ExtractSsrcStatsValue( 1192 std::string track_id = ExtractSsrcStatsValue(
1188 reports, StatsReport::kStatsValueNameTrackId); 1193 reports, StatsReport::kStatsValueNameTrackId);
1189 EXPECT_EQ(kRemoteTrackId, track_id); 1194 EXPECT_EQ(kRemoteTrackId, track_id);
1190 } 1195 }
1191 1196
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 Return(true))); 1551 Return(true)));
1547 1552
1548 StatsReports reports; // returned values. 1553 StatsReports reports; // returned values.
1549 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 1554 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
1550 stats.GetStats(NULL, &reports); 1555 stats.GetStats(NULL, &reports);
1551 1556
1552 // The report will exist since we don't remove them in RemoveStream(). 1557 // The report will exist since we don't remove them in RemoveStream().
1553 const StatsReport* report = FindNthReportByType( 1558 const StatsReport* report = FindNthReportByType(
1554 reports, StatsReport::kStatsReportTypeSsrc, 1); 1559 reports, StatsReport::kStatsReportTypeSsrc, 1);
1555 EXPECT_FALSE(report == NULL); 1560 EXPECT_FALSE(report == NULL);
1561 EXPECT_EQ(stats.GetTimeNow(), report->timestamp());
1556 std::string track_id = ExtractSsrcStatsValue( 1562 std::string track_id = ExtractSsrcStatsValue(
1557 reports, StatsReport::kStatsValueNameTrackId); 1563 reports, StatsReport::kStatsValueNameTrackId);
1558 EXPECT_EQ(kLocalTrackId, track_id); 1564 EXPECT_EQ(kLocalTrackId, track_id);
1559 std::string ssrc_id = ExtractSsrcStatsValue( 1565 std::string ssrc_id = ExtractSsrcStatsValue(
1560 reports, StatsReport::kStatsValueNameSsrc); 1566 reports, StatsReport::kStatsValueNameSsrc);
1561 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id); 1567 EXPECT_EQ(rtc::ToString<uint32>(kSsrcOfTrack), ssrc_id);
1562 1568
1563 // Verifies the values in the track report, no value will be changed by the 1569 // Verifies the values in the track report, no value will be changed by the
1564 // AudioTrackInterface::GetSignalValue() and 1570 // AudioTrackInterface::GetSignalValue() and
1565 // AudioProcessorInterface::AudioProcessorStats::GetStats(); 1571 // AudioProcessorInterface::AudioProcessorStats::GetStats();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 Return(true))); 1629 Return(true)));
1624 1630
1625 StatsReports reports; // returned values. 1631 StatsReports reports; // returned values.
1626 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 1632 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
1627 1633
1628 // Get stats for the local track. 1634 // Get stats for the local track.
1629 stats.GetStats(audio_track_.get(), &reports); 1635 stats.GetStats(audio_track_.get(), &reports);
1630 const StatsReport* track_report = FindNthReportByType( 1636 const StatsReport* track_report = FindNthReportByType(
1631 reports, StatsReport::kStatsReportTypeSsrc, 1); 1637 reports, StatsReport::kStatsReportTypeSsrc, 1);
1632 EXPECT_TRUE(track_report); 1638 EXPECT_TRUE(track_report);
1639 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
1633 std::string track_id = ExtractSsrcStatsValue( 1640 std::string track_id = ExtractSsrcStatsValue(
1634 reports, StatsReport::kStatsValueNameTrackId); 1641 reports, StatsReport::kStatsValueNameTrackId);
1635 EXPECT_EQ(kLocalTrackId, track_id); 1642 EXPECT_EQ(kLocalTrackId, track_id);
1636 VerifyVoiceSenderInfoReport(track_report, voice_sender_info); 1643 VerifyVoiceSenderInfoReport(track_report, voice_sender_info);
1637 1644
1638 // Get stats for the remote track. 1645 // Get stats for the remote track.
1639 reports.clear(); 1646 reports.clear();
1640 stats.GetStats(remote_track.get(), &reports); 1647 stats.GetStats(remote_track.get(), &reports);
1641 track_report = FindNthReportByType(reports, 1648 track_report = FindNthReportByType(reports,
1642 StatsReport::kStatsReportTypeSsrc, 1); 1649 StatsReport::kStatsReportTypeSsrc, 1);
1643 EXPECT_TRUE(track_report); 1650 EXPECT_TRUE(track_report);
1651 EXPECT_EQ(stats.GetTimeNow(), track_report->timestamp());
1644 track_id = ExtractSsrcStatsValue(reports, 1652 track_id = ExtractSsrcStatsValue(reports,
1645 StatsReport::kStatsValueNameTrackId); 1653 StatsReport::kStatsValueNameTrackId);
1646 EXPECT_EQ(kRemoteTrackId, track_id); 1654 EXPECT_EQ(kRemoteTrackId, track_id);
1647 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info); 1655 VerifyVoiceReceiverInfoReport(track_report, voice_receiver_info);
1648 } 1656 }
1649 1657
1650 // This test verifies that when two outgoing audio tracks are using the same 1658 // This test verifies that when two outgoing audio tracks are using the same
1651 // ssrc at different times, they populate stats reports correctly. 1659 // ssrc at different times, they populate stats reports correctly.
1652 // TODO(xians): Figure out if it is possible to encapsulate the setup and 1660 // TODO(xians): Figure out if it is possible to encapsulate the setup and
1653 // avoid duplication of code in test cases. 1661 // avoid duplication of code in test cases.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 cricket::VoiceSenderInfo new_voice_sender_info; 1702 cricket::VoiceSenderInfo new_voice_sender_info;
1695 InitVoiceSenderInfo(&new_voice_sender_info); 1703 InitVoiceSenderInfo(&new_voice_sender_info);
1696 cricket::VoiceMediaInfo new_stats_read; 1704 cricket::VoiceMediaInfo new_stats_read;
1697 reports.clear(); 1705 reports.clear();
1698 SetupAndVerifyAudioTrackStats( 1706 SetupAndVerifyAudioTrackStats(
1699 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName, 1707 new_audio_track.get(), stream_.get(), &stats, &voice_channel, kVcName,
1700 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports); 1708 media_channel, &new_voice_sender_info, NULL, &new_stats_read, &reports);
1701 } 1709 }
1702 1710
1703 } // namespace webrtc 1711 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/app/webrtc/statscollector.cc ('k') | talk/app/webrtc/test/mockpeerconnectionobservers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698