OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 | 1859 |
1860 cricket::ConnectionInfo rtp_connection_info; | 1860 cricket::ConnectionInfo rtp_connection_info; |
1861 rtp_connection_info.best_connection = false; | 1861 rtp_connection_info.best_connection = false; |
1862 rtp_connection_info.local_candidate = *rtp_local_candidate.get(); | 1862 rtp_connection_info.local_candidate = *rtp_local_candidate.get(); |
1863 rtp_connection_info.remote_candidate = *rtp_remote_candidate.get(); | 1863 rtp_connection_info.remote_candidate = *rtp_remote_candidate.get(); |
1864 rtp_connection_info.sent_total_bytes = 42; | 1864 rtp_connection_info.sent_total_bytes = 42; |
1865 rtp_connection_info.recv_total_bytes = 1337; | 1865 rtp_connection_info.recv_total_bytes = 1337; |
1866 cricket::TransportChannelStats rtp_transport_channel_stats; | 1866 cricket::TransportChannelStats rtp_transport_channel_stats; |
1867 rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; | 1867 rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; |
1868 rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info); | 1868 rtp_transport_channel_stats.connection_infos.push_back(rtp_connection_info); |
| 1869 rtp_transport_channel_stats.dtls_state = cricket::DTLS_TRANSPORT_NEW; |
1869 session_stats.transport_stats["transport"].channel_stats.push_back( | 1870 session_stats.transport_stats["transport"].channel_stats.push_back( |
1870 rtp_transport_channel_stats); | 1871 rtp_transport_channel_stats); |
1871 | 1872 |
1872 | 1873 |
1873 // Mock the session to return the desired candidates. | 1874 // Mock the session to return the desired candidates. |
1874 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( | 1875 EXPECT_CALL(test_->session(), GetStats(_)).WillRepeatedly(Invoke( |
1875 [&session_stats](const ChannelNamePairs&) { | 1876 [&session_stats](const ChannelNamePairs&) { |
1876 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); | 1877 return std::unique_ptr<SessionStats>(new SessionStats(session_stats)); |
1877 })); | 1878 })); |
1878 | 1879 |
1879 // Get stats without RTCP, an active connection or certificates. | 1880 // Get stats without RTCP, an active connection or certificates. |
1880 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | 1881 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); |
1881 | 1882 |
1882 RTCTransportStats expected_rtp_transport( | 1883 RTCTransportStats expected_rtp_transport( |
1883 "RTCTransport_transport_" + | 1884 "RTCTransport_transport_" + |
1884 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP), | 1885 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTP), |
1885 report->timestamp_us()); | 1886 report->timestamp_us()); |
1886 expected_rtp_transport.bytes_sent = 42; | 1887 expected_rtp_transport.bytes_sent = 42; |
1887 expected_rtp_transport.bytes_received = 1337; | 1888 expected_rtp_transport.bytes_received = 1337; |
1888 expected_rtp_transport.active_connection = false; | 1889 expected_rtp_transport.dtls_state = RTCDtlsTransportState::kNew; |
1889 | 1890 |
1890 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); | 1891 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1891 EXPECT_EQ( | 1892 EXPECT_EQ( |
1892 expected_rtp_transport, | 1893 expected_rtp_transport, |
1893 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1894 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1894 | 1895 |
1895 cricket::ConnectionInfo rtcp_connection_info; | 1896 cricket::ConnectionInfo rtcp_connection_info; |
1896 rtcp_connection_info.best_connection = false; | 1897 rtcp_connection_info.best_connection = false; |
1897 rtcp_connection_info.local_candidate = *rtcp_local_candidate.get(); | 1898 rtcp_connection_info.local_candidate = *rtcp_local_candidate.get(); |
1898 rtcp_connection_info.remote_candidate = *rtcp_remote_candidate.get(); | 1899 rtcp_connection_info.remote_candidate = *rtcp_remote_candidate.get(); |
1899 rtcp_connection_info.sent_total_bytes = 1337; | 1900 rtcp_connection_info.sent_total_bytes = 1337; |
1900 rtcp_connection_info.recv_total_bytes = 42; | 1901 rtcp_connection_info.recv_total_bytes = 42; |
1901 cricket::TransportChannelStats rtcp_transport_channel_stats; | 1902 cricket::TransportChannelStats rtcp_transport_channel_stats; |
1902 rtcp_transport_channel_stats.component = | 1903 rtcp_transport_channel_stats.component = |
1903 cricket::ICE_CANDIDATE_COMPONENT_RTCP; | 1904 cricket::ICE_CANDIDATE_COMPONENT_RTCP; |
1904 rtcp_transport_channel_stats.connection_infos.push_back(rtcp_connection_info); | 1905 rtcp_transport_channel_stats.connection_infos.push_back(rtcp_connection_info); |
| 1906 rtcp_transport_channel_stats.dtls_state = cricket::DTLS_TRANSPORT_CONNECTING; |
1905 session_stats.transport_stats["transport"].channel_stats.push_back( | 1907 session_stats.transport_stats["transport"].channel_stats.push_back( |
1906 rtcp_transport_channel_stats); | 1908 rtcp_transport_channel_stats); |
1907 | 1909 |
1908 collector_->ClearCachedStatsReport(); | 1910 collector_->ClearCachedStatsReport(); |
1909 // Get stats with RTCP and without an active connection or certificates. | 1911 // Get stats with RTCP and without an active connection or certificates. |
1910 report = GetStatsReport(); | 1912 report = GetStatsReport(); |
1911 | 1913 |
1912 RTCTransportStats expected_rtcp_transport( | 1914 RTCTransportStats expected_rtcp_transport( |
1913 "RTCTransport_transport_" + | 1915 "RTCTransport_transport_" + |
1914 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP), | 1916 rtc::ToString<>(cricket::ICE_CANDIDATE_COMPONENT_RTCP), |
1915 report->timestamp_us()); | 1917 report->timestamp_us()); |
1916 expected_rtcp_transport.bytes_sent = 1337; | 1918 expected_rtcp_transport.bytes_sent = 1337; |
1917 expected_rtcp_transport.bytes_received = 42; | 1919 expected_rtcp_transport.bytes_received = 42; |
1918 expected_rtcp_transport.active_connection = false; | 1920 expected_rtcp_transport.dtls_state = RTCDtlsTransportState::kConnecting; |
1919 | 1921 |
1920 expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id(); | 1922 expected_rtp_transport.rtcp_transport_stats_id = expected_rtcp_transport.id(); |
1921 | 1923 |
1922 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); | 1924 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1923 EXPECT_EQ( | 1925 EXPECT_EQ( |
1924 expected_rtp_transport, | 1926 expected_rtp_transport, |
1925 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1927 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1926 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); | 1928 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); |
1927 EXPECT_EQ( | 1929 EXPECT_EQ( |
1928 expected_rtcp_transport, | 1930 expected_rtcp_transport, |
1929 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); | 1931 report->Get(expected_rtcp_transport.id())->cast_to<RTCTransportStats>()); |
1930 | 1932 |
1931 // Get stats with an active connection. | 1933 // Get stats with an active connection (selected candidate pair). |
1932 session_stats.transport_stats["transport"] | 1934 session_stats.transport_stats["transport"] |
1933 .channel_stats[1] | 1935 .channel_stats[1] |
1934 .connection_infos[0] | 1936 .connection_infos[0] |
1935 .best_connection = true; | 1937 .best_connection = true; |
1936 | 1938 |
1937 collector_->ClearCachedStatsReport(); | 1939 collector_->ClearCachedStatsReport(); |
1938 report = GetStatsReport(); | 1940 report = GetStatsReport(); |
1939 | 1941 |
1940 expected_rtcp_transport.active_connection = true; | |
1941 expected_rtcp_transport.selected_candidate_pair_id = | 1942 expected_rtcp_transport.selected_candidate_pair_id = |
1942 "RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" + | 1943 "RTCIceCandidatePair_" + rtcp_local_candidate->id() + "_" + |
1943 rtcp_remote_candidate->id(); | 1944 rtcp_remote_candidate->id(); |
1944 | 1945 |
1945 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); | 1946 ASSERT_TRUE(report->Get(expected_rtp_transport.id())); |
1946 EXPECT_EQ( | 1947 EXPECT_EQ( |
1947 expected_rtp_transport, | 1948 expected_rtp_transport, |
1948 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); | 1949 report->Get(expected_rtp_transport.id())->cast_to<RTCTransportStats>()); |
1949 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); | 1950 ASSERT_TRUE(report->Get(expected_rtcp_transport.id())); |
1950 EXPECT_EQ( | 1951 EXPECT_EQ( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 2012 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
2012 }; | 2013 }; |
2013 | 2014 |
2014 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 2015 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
2015 collector_->VerifyThreadUsageAndResultsMerging(); | 2016 collector_->VerifyThreadUsageAndResultsMerging(); |
2016 } | 2017 } |
2017 | 2018 |
2018 } // namespace | 2019 } // namespace |
2019 | 2020 |
2020 } // namespace webrtc | 2021 } // namespace webrtc |
OLD | NEW |