In preparation for track deletion, fix some more tests.

The tests should say something about RTPs too, because what they say
about track will soon be irrelevant. A drive-by fix is to GetStatsOfType
as RTCOutboundRTPStreamStats instead of RTPStreamStats, this is because
of a limitation with using T::kType for runtime type information...
GetStatsOfType<T> does not work for Ts higher up in the stats hierarchy,
so it would always have returned an empty list even if
RTCOutboundRTPStreamStats were present. (Room for improvement here, but
that's a different issue.)

Bug: webrtc:14175
Change-Id: I0235bc0b66c52081859ee621c58249a6b6e98738
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288583
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38984}
This commit is contained in:
Henrik Boström 2022-12-24 11:20:12 +01:00 committed by WebRTC LUCI CQ
parent 323e9df6d1
commit 5ed4da7222

View File

@ -3890,10 +3890,9 @@ TEST_F(RTCStatsCollectorTest, GetStatsWithNullReceiverSelector) {
EXPECT_EQ(empty_report->size(), 0u);
}
// When the PC has not had SetLocalDescription done, tracks all have
// SSRC 0, meaning "unconnected".
// In this state, we report on track stats, but not RTP stats.
TEST_F(RTCStatsCollectorTest, StatsReportedOnZeroSsrc) {
// Before SetLocalDescription() senders don't have an SSRC.
// To simulate this case we create a mock sender with SSRC=0.
TEST_F(RTCStatsCollectorTest, RtpIsMissingWhileSsrcIsZero) {
rtc::scoped_refptr<MediaStreamTrackInterface> track =
CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "audioTrack",
MediaStreamTrackInterface::kLive);
@ -3904,16 +3903,15 @@ TEST_F(RTCStatsCollectorTest, StatsReportedOnZeroSsrc) {
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
std::vector<const DEPRECATED_RTCMediaStreamTrackStats*> track_stats =
report->GetStatsOfType<DEPRECATED_RTCMediaStreamTrackStats>();
EXPECT_EQ(1U, track_stats.size());
std::vector<const RTCRTPStreamStats*> rtp_stream_stats =
report->GetStatsOfType<RTCRTPStreamStats>();
EXPECT_EQ(0U, rtp_stream_stats.size());
auto tracks = report->GetStatsOfType<DEPRECATED_RTCMediaStreamTrackStats>();
EXPECT_EQ(1U, tracks.size());
auto outbound_rtps = report->GetStatsOfType<RTCOutboundRTPStreamStats>();
EXPECT_TRUE(outbound_rtps.empty());
}
TEST_F(RTCStatsCollectorTest, DoNotCrashOnSsrcChange) {
// We may also be in a case where the SSRC has been assigned but no
// `voice_sender_info` stats exist yet.
TEST_F(RTCStatsCollectorTest, DoNotCrashIfSsrcIsKnownButInfosAreStillMissing) {
rtc::scoped_refptr<MediaStreamTrackInterface> track =
CreateFakeTrack(cricket::MEDIA_TYPE_AUDIO, "audioTrack",
MediaStreamTrackInterface::kLive);
@ -3928,6 +3926,8 @@ TEST_F(RTCStatsCollectorTest, DoNotCrashOnSsrcChange) {
std::vector<const DEPRECATED_RTCMediaStreamTrackStats*> track_stats =
report->GetStatsOfType<DEPRECATED_RTCMediaStreamTrackStats>();
EXPECT_EQ(1U, track_stats.size());
auto outbound_rtps = report->GetStatsOfType<RTCOutboundRTPStreamStats>();
EXPECT_TRUE(outbound_rtps.empty());
}
// Used for test below, to test calling GetStatsReport during a callback.