|
|
Created:
4 years ago by hbos Modified:
4 years ago Reviewers:
Taylor Brandstetter CC:
webrtc-reviews_webrtc.org, the sun, tterriberry_mozilla.com Target Ref:
refs/heads/master Project:
webrtc Visibility:
Public. |
DescriptionRTCStatsCollectorTest: Remove ExpectReportContainsCandidate.
Remove ExpectReportContainsCandidate in favor of EXPECT_EQ checks of
RTC[Local/Remote]IceCandidateStats objects.
BUG=chromium:627816
Review-Url: https://codereview.webrtc.org/2594753002
Cr-Commit-Position: refs/heads/master@{#15737}
Committed: https://chromium.googlesource.com/external/webrtc/+/c42ba32877d3b520f96dff5720f83f5230580fe2
Patch Set 1 #
Total comments: 2
Patch Set 2 : Moved expected stats for clarity #Patch Set 3 : Rebase with master #Messages
Total messages: 20 (12 generated)
The CQ bit was checked by hbos@webrtc.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
hbos@webrtc.org changed reviewers: + deadbeef@webrtc.org
Please take a look, deadbeef.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.webrtc.org/2594753002/diff/1/webrtc/api/rtcstatscollector_... File webrtc/api/rtcstatscollector_unittest.cc (right): https://codereview.webrtc.org/2594753002/diff/1/webrtc/api/rtcstatscollector_... webrtc/api/rtcstatscollector_unittest.cc:979: RTCLocalIceCandidateStats>()); nit: It may make sense to create the "expected stats" objects in the same place as the fake candidates (at the top of the test), so that when reading the test code it's easier to see how the fake candidate is expected to map to the candidate stats. Same goes for the other CLs (like data channel stats).
lgtm with above nit
https://codereview.webrtc.org/2594753002/diff/1/webrtc/api/rtcstatscollector_... File webrtc/api/rtcstatscollector_unittest.cc (right): https://codereview.webrtc.org/2594753002/diff/1/webrtc/api/rtcstatscollector_... webrtc/api/rtcstatscollector_unittest.cc:979: RTCLocalIceCandidateStats>()); On 2016/12/20 19:56:43, Taylor Brandstetter wrote: > nit: It may make sense to create the "expected stats" objects in the same place > as the fake candidates (at the top of the test), so that when reading the test > code it's easier to see how the fake candidate is expected to map to the > candidate stats. Same goes for the other CLs (like data channel stats). Done.
The CQ bit was checked by hbos@webrtc.org
The patchset sent to the CQ was uploaded after l-g-t-m from deadbeef@webrtc.org Link to the patchset: https://codereview.webrtc.org/2594753002/#ps20001 (title: "Moved expected stats for clarity")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for webrtc/api/rtcstatscollector_unittest.cc: While running git apply --index -p1; error: patch failed: webrtc/api/rtcstatscollector_unittest.cc:1058 error: webrtc/api/rtcstatscollector_unittest.cc: patch does not apply Patch: webrtc/api/rtcstatscollector_unittest.cc Index: webrtc/api/rtcstatscollector_unittest.cc diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc index 4be7491724010ec0ae85d396f57698f2fed42039..5aac9a0789e097a221dd07052897911678cceead 100644 --- a/webrtc/api/rtcstatscollector_unittest.cc +++ b/webrtc/api/rtcstatscollector_unittest.cc @@ -494,30 +494,6 @@ class RTCStatsCollectorTest : public testing::Test { return callback->report(); } - const RTCIceCandidateStats* ExpectReportContainsCandidate( - const rtc::scoped_refptr<const RTCStatsReport>& report, - const cricket::Candidate& candidate, - bool is_local) { - const RTCStats* stats = report->Get("RTCIceCandidate_" + candidate.id()); - EXPECT_TRUE(stats); - const RTCIceCandidateStats* candidate_stats; - if (is_local) - candidate_stats = &stats->cast_to<RTCLocalIceCandidateStats>(); - else - candidate_stats = &stats->cast_to<RTCRemoteIceCandidateStats>(); - EXPECT_EQ(*candidate_stats->ip, candidate.address().ipaddr().ToString()); - EXPECT_EQ(*candidate_stats->port, - static_cast<int32_t>(candidate.address().port())); - EXPECT_EQ(*candidate_stats->protocol, candidate.protocol()); - EXPECT_EQ(*candidate_stats->candidate_type, - CandidateTypeToRTCIceCandidateTypeForTesting(candidate.type())); - EXPECT_EQ(*candidate_stats->priority, - static_cast<int32_t>(candidate.priority())); - // TODO(hbos): Define candidate_stats->url. crbug.com/632723 - EXPECT_FALSE(candidate_stats->url.is_defined()); - return candidate_stats; - } - void ExpectReportContainsCertificateInfo( const rtc::scoped_refptr<const RTCStatsReport>& report, const CertificateInfo& cert_info) { @@ -927,32 +903,79 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { "a_local_host's protocol", cricket::LOCAL_PORT_TYPE, 0); + RTCLocalIceCandidateStats expected_a_local_host( + "RTCIceCandidate_" + a_local_host->id(), 0); + expected_a_local_host.ip = "1.2.3.4"; + expected_a_local_host.port = 5; + expected_a_local_host.protocol = "a_local_host's protocol"; + expected_a_local_host.candidate_type = "host"; + expected_a_local_host.priority = 0; + std::unique_ptr<cricket::Candidate> a_remote_srflx = CreateFakeCandidate( "6.7.8.9", 10, "remote_srflx's protocol", cricket::STUN_PORT_TYPE, 1); + RTCRemoteIceCandidateStats expected_a_remote_srflx( + "RTCIceCandidate_" + a_remote_srflx->id(), 0); + expected_a_remote_srflx.ip = "6.7.8.9"; + expected_a_remote_srflx.port = 10; + expected_a_remote_srflx.protocol = "remote_srflx's protocol"; + expected_a_remote_srflx.candidate_type = "srflx"; + expected_a_remote_srflx.priority = 1; + std::unique_ptr<cricket::Candidate> a_local_prflx = CreateFakeCandidate( "11.12.13.14", 15, "a_local_prflx's protocol", cricket::PRFLX_PORT_TYPE, 2); + RTCLocalIceCandidateStats expected_a_local_prflx( + "RTCIceCandidate_" + a_local_prflx->id(), 0); + expected_a_local_prflx.ip = "11.12.13.14"; + expected_a_local_prflx.port = 15; + expected_a_local_prflx.protocol = "a_local_prflx's protocol"; + expected_a_local_prflx.candidate_type = "prflx"; + expected_a_local_prflx.priority = 2; + std::unique_ptr<cricket::Candidate> a_remote_relay = CreateFakeCandidate( "16.17.18.19", 20, "a_remote_relay's protocol", cricket::RELAY_PORT_TYPE, 3); + RTCRemoteIceCandidateStats expected_a_remote_relay( + "RTCIceCandidate_" + a_remote_relay->id(), 0); + expected_a_remote_relay.ip = "16.17.18.19"; + expected_a_remote_relay.port = 20; + expected_a_remote_relay.protocol = "a_remote_relay's protocol"; + expected_a_remote_relay.candidate_type = "relay"; + expected_a_remote_relay.priority = 3; + // Candidates in the second transport stats. std::unique_ptr<cricket::Candidate> b_local = CreateFakeCandidate( "42.42.42.42", 42, "b_local's protocol", cricket::LOCAL_PORT_TYPE, 42); + RTCLocalIceCandidateStats expected_b_local( + "RTCIceCandidate_" + b_local->id(), 0); + expected_b_local.ip = "42.42.42.42"; + expected_b_local.port = 42; + expected_b_local.protocol = "b_local's protocol"; + expected_b_local.candidate_type = "host"; + expected_b_local.priority = 42; + std::unique_ptr<cricket::Candidate> b_remote = CreateFakeCandidate( "42.42.42.42", 42, "b_remote's protocol", cricket::LOCAL_PORT_TYPE, 42); + RTCRemoteIceCandidateStats expected_b_remote( + "RTCIceCandidate_" + b_remote->id(), 0); + expected_b_remote.ip = "42.42.42.42"; + expected_b_remote.port = 42; + expected_b_remote.protocol = "b_remote's protocol"; + expected_b_remote.candidate_type = "host"; + expected_b_remote.priority = 42; SessionStats session_stats; @@ -989,12 +1012,31 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { })); rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); - ExpectReportContainsCandidate(report, *a_local_host.get(), true); - ExpectReportContainsCandidate(report, *a_remote_srflx.get(), false); - ExpectReportContainsCandidate(report, *a_local_prflx.get(), true); - ExpectReportContainsCandidate(report, *a_remote_relay.get(), false); - ExpectReportContainsCandidate(report, *b_local.get(), true); - ExpectReportContainsCandidate(report, *b_remote.get(), false); + + EXPECT_TRUE(report->Get(expected_a_local_host.id())); + EXPECT_EQ(expected_a_local_host, + report->Get(expected_a_local_host.id())->cast_to< + RTCLocalIceCandidateStats>()); + EXPECT_TRUE(report->Get(expected_a_remote_srflx.id())); + EXPECT_EQ(expected_a_remote_srflx, + report->Get(expected_a_remote_srflx.id())->cast_to< + RTCRemoteIceCandidateStats>()); + EXPECT_TRUE(report->Get(expected_a_local_prflx.id())); + EXPECT_EQ(expected_a_local_prflx, + report->Get(expected_a_local_prflx.id())->cast_to< + RTCLocalIceCandidateStats>()); + EXPECT_TRUE(report->Get(expected_a_remote_relay.id())); + EXPECT_EQ(expected_a_remote_relay, + report->Get(expected_a_remote_relay.id())->cast_to< + RTCRemoteIceCandidateStats>()); + EXPECT_TRUE(report->Get(expected_b_local.id())); + EXPECT_EQ(expected_b_local, + report->Get(expected_b_local.id())->cast_to< + RTCLocalIceCandidateStats>()); + EXPECT_TRUE(report->Get(expected_b_remote.id())); + EXPECT_EQ(expected_b_remote, + report->Get(expected_b_remote.id())->cast_to< + RTCRemoteIceCandidateStats>()); } TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { @@ -1058,11 +1100,29 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { expected_pair, report->Get(expected_pair.id())->cast_to<RTCIceCandidatePairStats>()); - EXPECT_TRUE(report->Get(*expected_pair.local_candidate_id)); - ExpectReportContainsCandidate(report, connection_info.local_candidate, true); - EXPECT_TRUE(report->Get(*expected_pair.remote_candidate_id)); - ExpectReportContainsCandidate(report, connection_info.remote_candidate, - false); + RTCLocalIceCandidateStats expected_local_candidate( + *expected_pair.local_candidate_id, report->timestamp_us()); + expected_local_candidate.ip = "42.42.42.42"; + expected_local_candidate.port = 42; + expected_local_candidate.protocol = "protocol"; + expected_local_candidate.candidate_type = "host"; + expected_local_candidate.priority = 42; + ASSERT_TRUE(report->Get(expected_local_candidate.id())); + EXPECT_EQ(expected_local_candidate, + report->Get(expected_local_candidate.id())->cast_to< + RTCLocalIceCandidateStats>()); + + RTCRemoteIceCandidateStats expected_remote_candidate( + *expected_pair.remote_candidate_id, report->timestamp_us()); + expected_remote_candidate.ip = "42.42.42.42"; + expected_remote_candidate.port = 42; + expected_remote_candidate.protocol = "protocol"; + expected_remote_candidate.candidate_type = "host"; + expected_remote_candidate.priority = 42; + ASSERT_TRUE(report->Get(expected_remote_candidate.id())); + EXPECT_EQ(expected_remote_candidate, + report->Get(expected_remote_candidate.id())->cast_to< + RTCRemoteIceCandidateStats>()); } TEST_F(RTCStatsCollectorTest, CollectRTCPeerConnectionStats) {
The CQ bit was checked by hbos@webrtc.org
The patchset sent to the CQ was uploaded after l-g-t-m from deadbeef@webrtc.org Link to the patchset: https://codereview.webrtc.org/2594753002/#ps40001 (title: "Rebase with master")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
CQ is committing da patch. Bot data: {"patchset_id": 40001, "attempt_start_ts": 1482317244877110, "parent_rev": "e55b16c66423717e1136f4d90504c6ba57e81769", "commit_rev": "c42ba32877d3b520f96dff5720f83f5230580fe2"}
Message was sent while issue was closed.
Description was changed from ========== RTCStatsCollectorTest: Remove ExpectReportContainsCandidate. Remove ExpectReportContainsCandidate in favor of EXPECT_EQ checks of RTC[Local/Remote]IceCandidateStats objects. BUG=chromium:627816 ========== to ========== RTCStatsCollectorTest: Remove ExpectReportContainsCandidate. Remove ExpectReportContainsCandidate in favor of EXPECT_EQ checks of RTC[Local/Remote]IceCandidateStats objects. BUG=chromium:627816 Review-Url: https://codereview.webrtc.org/2594753002 Cr-Commit-Position: refs/heads/master@{#15737} Committed: https://chromium.googlesource.com/external/webrtc/+/c42ba32877d3b520f96dff572... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/external/webrtc/+/c42ba32877d3b520f96dff572... |