OLD | NEW |
(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 |
OLD | NEW |