diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index e31843c8eb..64b5f05816 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -1010,7 +1010,8 @@ StatsKey DefaultVideoQualityAnalyzer::ToStatsKey( std::string DefaultVideoQualityAnalyzer::ToMetricName( const InternalStatsKey& key) const { const std::string& stream_label = streams_.name(key.stream); - if (peers_->size() <= 2 && key.sender != key.receiver) { + if (peers_->GetKnownSize() <= 2 && key.sender != key.receiver) { + // TODO(titovartem): remove this special case. return stream_label; } rtc::StringBuilder out; diff --git a/test/pc/e2e/analyzer/video/names_collection.h b/test/pc/e2e/analyzer/video/names_collection.h index e29bad1ad4..f9a13a2a11 100644 --- a/test/pc/e2e/analyzer/video/names_collection.h +++ b/test/pc/e2e/analyzer/video/names_collection.h @@ -44,6 +44,9 @@ class NamesCollection { // Returns amount of currently presented names in the collection. size_t size() const { return size_; } + // Returns amount of all names known to this collection. + size_t GetKnownSize() const { return names_.size(); } + // Returns index of the `name` which was known to the collection. Crashes // if `name` was never registered in the collection. size_t index(absl::string_view name) const { return index_.at(name); } diff --git a/test/pc/e2e/analyzer/video/names_collection_test.cc b/test/pc/e2e/analyzer/video/names_collection_test.cc index 65932ea26e..6c52f96975 100644 --- a/test/pc/e2e/analyzer/video/names_collection_test.cc +++ b/test/pc/e2e/analyzer/video/names_collection_test.cc @@ -137,5 +137,16 @@ TEST(NamesCollectionTest, AddRemoveAddPreserveTheIndex) { EXPECT_THAT(collection.size(), Eq(static_cast(1))); } +TEST(NamesCollectionTest, GetKnownSizeReturnsForRemovedNames) { + NamesCollection collection(std::vector{}); + + size_t alice_index = collection.AddIfAbsent("alice"); + EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast(1))); + + EXPECT_THAT(collection.RemoveIfPresent("alice"), + Eq(absl::optional(alice_index))); + EXPECT_THAT(collection.GetKnownSize(), Eq(static_cast(1))); +} + } // namespace } // namespace webrtc