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

Unified Diff: content/renderer/media/webrtc/rtc_stats_unittest.cc

Issue 2490183002: Filter webrtc::RTCStats by whitelist in surfacing them to Blink. (Closed)
Patch Set: git cl format: {\n} -> {} Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/webrtc/rtc_stats.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc/rtc_stats_unittest.cc
diff --git a/content/renderer/media/webrtc/rtc_stats_unittest.cc b/content/renderer/media/webrtc/rtc_stats_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..38ff6bd9a8df5e1b5809d335db40ab6736775f77
--- /dev/null
+++ b/content/renderer/media/webrtc/rtc_stats_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/webrtc/rtc_stats.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/webrtc/api/stats/rtcstats_objects.h"
+#include "third_party/webrtc/api/stats/rtcstatsreport.h"
+#include "third_party/webrtc/stats/test/rtcteststats.h"
+
+namespace content {
+
+TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_GetStats) {
+ const char* not_whitelisted_id = "NotWhitelistedId";
+ const char* whitelisted_id = "WhitelistedId";
+
+ rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report =
+ webrtc::RTCStatsReport::Create(42);
+ webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>(
+ new webrtc::RTCTestStats(not_whitelisted_id, 42)));
+ webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>(
+ new webrtc::RTCPeerConnectionStats(whitelisted_id, 42)));
+
+ RTCStatsReport report(webrtc_report.get());
+ EXPECT_FALSE(report.getStats(blink::WebString::fromUTF8(not_whitelisted_id)));
+ EXPECT_TRUE(report.getStats(blink::WebString::fromUTF8(whitelisted_id)));
+}
+
+TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_Iteration) {
+ const char* not_whitelisted_id = "NotWhitelistedId";
+ const char* whitelisted_id = "WhitelistedId";
+
+ rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report =
+ webrtc::RTCStatsReport::Create(42);
+ webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>(
+ new webrtc::RTCTestStats(not_whitelisted_id, 42)));
+ webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>(
+ new webrtc::RTCPeerConnectionStats(whitelisted_id, 42)));
+
+ RTCStatsReport report(webrtc_report.get());
+ std::unique_ptr<blink::WebRTCStats> stats = report.next();
+ EXPECT_TRUE(stats);
+ EXPECT_EQ(stats->id(), whitelisted_id);
+ EXPECT_FALSE(report.next());
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/media/webrtc/rtc_stats.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698