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

Side by Side 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 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 | « content/renderer/media/webrtc/rtc_stats.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/webrtc/rtc_stats.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/webrtc/api/stats/rtcstats_objects.h"
9 #include "third_party/webrtc/api/stats/rtcstatsreport.h"
10 #include "third_party/webrtc/stats/test/rtcteststats.h"
11
12 namespace content {
13
14 TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_GetStats) {
15 const char* not_whitelisted_id = "NotWhitelistedId";
16 const char* whitelisted_id = "WhitelistedId";
17
18 rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report =
19 webrtc::RTCStatsReport::Create(42);
20 webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>(
21 new webrtc::RTCTestStats(not_whitelisted_id, 42)));
22 webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>(
23 new webrtc::RTCPeerConnectionStats(whitelisted_id, 42)));
24
25 RTCStatsReport report(webrtc_report.get());
26 EXPECT_FALSE(report.getStats(blink::WebString::fromUTF8(not_whitelisted_id)));
27 EXPECT_TRUE(report.getStats(blink::WebString::fromUTF8(whitelisted_id)));
28 }
29
30 TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_Iteration) {
31 const char* not_whitelisted_id = "NotWhitelistedId";
32 const char* whitelisted_id = "WhitelistedId";
33
34 rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report =
35 webrtc::RTCStatsReport::Create(42);
36 webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>(
37 new webrtc::RTCTestStats(not_whitelisted_id, 42)));
38 webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>(
39 new webrtc::RTCPeerConnectionStats(whitelisted_id, 42)));
40
41 RTCStatsReport report(webrtc_report.get());
42 std::unique_ptr<blink::WebRTCStats> stats = report.next();
43 EXPECT_TRUE(stats);
44 EXPECT_EQ(stats->id(), whitelisted_id);
45 EXPECT_FALSE(report.next());
46 }
47
48 } // namespace content
OLDNEW
« 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