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

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 2722933002: Measure packet loss so we can use it to select ICE candidate pairs. (Closed)
Patch Set: better comments and test names Created 3 years, 9 months 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
« webrtc/p2p/base/port.cc ('K') | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); 2878 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE);
2879 EXPECT_NE(conn1, conn2); 2879 EXPECT_NE(conn1, conn2);
2880 conn_in_use = port->GetConnection(address); 2880 conn_in_use = port->GetConnection(address);
2881 EXPECT_EQ(conn2, conn_in_use); 2881 EXPECT_EQ(conn2, conn_in_use);
2882 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); 2882 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation());
2883 2883
2884 // Make sure the new connection was not deleted. 2884 // Make sure the new connection was not deleted.
2885 rtc::Thread::Current()->ProcessMessages(300); 2885 rtc::Thread::Current()->ProcessMessages(300);
2886 EXPECT_TRUE(port->GetConnection(address) != nullptr); 2886 EXPECT_TRUE(port->GetConnection(address) != nullptr);
2887 } 2887 }
2888
2889 class PacketLossEstimatorTest : public testing::Test {};
Taylor Brandstetter 2017/03/01 02:26:13 Could have a test for calling RemoveExpiredPackets
Zach Stein 2017/03/02 00:02:23 Done.
2890
2891 class PacketLossEstimatorWithTestInfo : public PacketLossEstimator {
2892 public:
2893 PacketLossEstimatorWithTestInfo(int64_t expire_after)
2894 : PacketLossEstimator(expire_after) {}
2895
2896 // making these public for the tests
2897 using PacketLossEstimator::get_responses_expected;
2898 using PacketLossEstimator::get_responses_received;
2899 };
2900
2901 TEST_F(PacketLossEstimatorTest, ResponseReceived) {
2902 PacketLossEstimatorWithTestInfo ple(5);
2903
2904 ple.ExpectResponse("1", 0);
2905 ple.ReceivedResponse("1", 1);
2906
2907 EXPECT_EQ(1, ple.get_responses_received());
2908 EXPECT_EQ(1, ple.get_responses_expected());
2909 EXPECT_EQ(1.0, ple.get_response_rate());
2910 }
2911
2912 TEST_F(PacketLossEstimatorTest, ResponseLost) {
2913 PacketLossEstimatorWithTestInfo ple(5);
2914
2915 ple.ExpectResponse("1", 0);
2916 ple.RemoveExpiredPackets(10);
2917
2918 EXPECT_EQ(0, ple.get_responses_received());
2919 EXPECT_EQ(1, ple.get_responses_expected());
2920 EXPECT_EQ(0.0, ple.get_response_rate());
2921 }
2922
2923 TEST_F(PacketLossEstimatorTest, ResponseLate) {
2924 PacketLossEstimatorWithTestInfo ple(5);
2925
2926 ple.ExpectResponse("1", 0);
2927 ple.ReceivedResponse("1", 10);
2928
2929 EXPECT_EQ(0, ple.get_responses_received());
2930 EXPECT_EQ(1, ple.get_responses_expected());
2931 EXPECT_EQ(0.0, ple.get_response_rate());
2932 }
2933
2934 TEST_F(PacketLossEstimatorTest, OneLostOneReceived) {
2935 PacketLossEstimatorWithTestInfo ple(5);
2936
2937 ple.ExpectResponse("1", 0);
2938 ple.ExpectResponse("2", 2);
2939 ple.ReceivedResponse("2", 6);
2940
2941 EXPECT_EQ(1, ple.get_responses_received());
2942 EXPECT_EQ(2, ple.get_responses_expected());
2943 EXPECT_EQ(0.5, ple.get_response_rate());
2944 }
2945
2946 TEST_F(PacketLossEstimatorTest, DontDoubleExpire) {
2947 PacketLossEstimatorWithTestInfo ple(5);
2948
2949 ple.ExpectResponse("1", 0);
2950 ple.ExpectResponse("2", 2);
2951 ple.ReceivedResponse("2", 6); // expires "1"
2952 ple.ReceivedResponse("1", 7); // "1" should already be expired
Taylor Brandstetter 2017/03/01 02:26:13 nit: Generally our style is to use full capitaliza
Zach Stein 2017/03/02 00:02:23 Done.
2953
2954 EXPECT_EQ(1, ple.get_responses_received());
2955 EXPECT_EQ(2, ple.get_responses_expected());
2956 EXPECT_EQ(0.5, ple.get_response_rate());
2957 }
OLDNEW
« webrtc/p2p/base/port.cc ('K') | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698