OLD | NEW |
1 #include "net/quic/quic_multipath_sent_packet_manager.h" | 1 #include "net/quic/quic_multipath_sent_packet_manager.h" |
2 | 2 |
3 #include "net/quic/test_tools/quic_multipath_sent_packet_manager_peer.h" | 3 #include "net/quic/test_tools/quic_multipath_sent_packet_manager_peer.h" |
4 #include "net/quic/test_tools/quic_test_utils.h" | 4 #include "net/quic/test_tools/quic_test_utils.h" |
5 #include "net/test/gtest_util.h" | 5 #include "net/test/gtest_util.h" |
6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 using testing::Return; | 9 using testing::Return; |
10 using testing::StrictMock; | 10 using testing::StrictMock; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 frame3.path_id = kTestPathId3; | 85 frame3.path_id = kTestPathId3; |
86 EXPECT_CALL(*manager_0_, OnIncomingAck(_, QuicTime::Zero())); | 86 EXPECT_CALL(*manager_0_, OnIncomingAck(_, QuicTime::Zero())); |
87 EXPECT_CALL(*manager_1_, OnIncomingAck(_, QuicTime::Zero())); | 87 EXPECT_CALL(*manager_1_, OnIncomingAck(_, QuicTime::Zero())); |
88 EXPECT_CALL(*manager_2_, OnIncomingAck(_, QuicTime::Zero())).Times(0); | 88 EXPECT_CALL(*manager_2_, OnIncomingAck(_, QuicTime::Zero())).Times(0); |
89 multipath_manager_.OnIncomingAck(frame0, QuicTime::Zero()); | 89 multipath_manager_.OnIncomingAck(frame0, QuicTime::Zero()); |
90 multipath_manager_.OnIncomingAck(frame1, QuicTime::Zero()); | 90 multipath_manager_.OnIncomingAck(frame1, QuicTime::Zero()); |
91 multipath_manager_.OnIncomingAck(frame2, QuicTime::Zero()); | 91 multipath_manager_.OnIncomingAck(frame2, QuicTime::Zero()); |
92 multipath_manager_.OnIncomingAck(frame3, QuicTime::Zero()); | 92 multipath_manager_.OnIncomingAck(frame3, QuicTime::Zero()); |
93 } | 93 } |
94 | 94 |
95 TEST_F(QuicMultipathSentPacketManagerTest, IsUnacked) { | |
96 EXPECT_CALL(*manager_0_, IsUnacked(kDefaultPathId, 1)).WillOnce(Return(true)); | |
97 EXPECT_CALL(*manager_1_, IsUnacked(kTestPathId1, 2)).WillOnce(Return(false)); | |
98 EXPECT_CALL(*manager_2_, IsUnacked(kTestPathId2, 3)).WillOnce(Return(true)); | |
99 EXPECT_TRUE(multipath_manager_.IsUnacked(kDefaultPathId, 1)); | |
100 EXPECT_FALSE(multipath_manager_.IsUnacked(kTestPathId1, 2)); | |
101 EXPECT_TRUE(multipath_manager_.IsUnacked(kTestPathId2, 3)); | |
102 /* | |
103 EXPECT_DFATAL(multipath_manager_.IsUnacked(kTestPathId3, 4), ""); | |
104 */ | |
105 } | |
106 | |
107 TEST_F(QuicMultipathSentPacketManagerTest, HasRetransmittableFrames) { | |
108 EXPECT_CALL(*manager_0_, HasRetransmittableFrames(kDefaultPathId, 1)) | |
109 .WillOnce(Return(true)); | |
110 EXPECT_CALL(*manager_1_, HasRetransmittableFrames(kTestPathId1, 2)) | |
111 .WillOnce(Return(false)); | |
112 EXPECT_CALL(*manager_2_, HasRetransmittableFrames(kTestPathId2, 3)) | |
113 .WillOnce(Return(true)); | |
114 EXPECT_TRUE(multipath_manager_.HasRetransmittableFrames(kDefaultPathId, 1)); | |
115 EXPECT_FALSE(multipath_manager_.HasRetransmittableFrames(kTestPathId1, 2)); | |
116 EXPECT_TRUE(multipath_manager_.HasRetransmittableFrames(kTestPathId2, 3)); | |
117 /* | |
118 EXPECT_DFATAL(multipath_manager_.HasRetransmittableFrames(kTestPathId3, 4), | |
119 ""); | |
120 */ | |
121 } | |
122 | |
123 TEST_F(QuicMultipathSentPacketManagerTest, RetransmitUnackedPackets) { | 95 TEST_F(QuicMultipathSentPacketManagerTest, RetransmitUnackedPackets) { |
124 EXPECT_CALL(*manager_0_, RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION)); | 96 EXPECT_CALL(*manager_0_, RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION)); |
125 multipath_manager_.RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION); | 97 multipath_manager_.RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION); |
126 } | 98 } |
127 | 99 |
128 TEST_F(QuicMultipathSentPacketManagerTest, MaybeRetransmitTailLossProbe) { | 100 TEST_F(QuicMultipathSentPacketManagerTest, MaybeRetransmitTailLossProbe) { |
129 EXPECT_CALL(*manager_0_, MaybeRetransmitTailLossProbe()) | 101 EXPECT_CALL(*manager_0_, MaybeRetransmitTailLossProbe()) |
130 .WillOnce(Return(false)); | 102 .WillOnce(Return(false)); |
131 EXPECT_CALL(*manager_1_, MaybeRetransmitTailLossProbe()) | 103 EXPECT_CALL(*manager_1_, MaybeRetransmitTailLossProbe()) |
132 .WillOnce(Return(false)); | 104 .WillOnce(Return(false)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 EXPECT_TRUE(multipath_manager_.HasUnackedPackets()); | 143 EXPECT_TRUE(multipath_manager_.HasUnackedPackets()); |
172 } | 144 } |
173 | 145 |
174 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastUnacked) { | 146 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastUnacked) { |
175 EXPECT_CALL(*manager_0_, GetLeastUnacked(kDefaultPathId)).WillOnce(Return(2)); | 147 EXPECT_CALL(*manager_0_, GetLeastUnacked(kDefaultPathId)).WillOnce(Return(2)); |
176 EXPECT_CALL(*manager_1_, GetLeastUnacked(kTestPathId1)).WillOnce(Return(3)); | 148 EXPECT_CALL(*manager_1_, GetLeastUnacked(kTestPathId1)).WillOnce(Return(3)); |
177 EXPECT_CALL(*manager_2_, GetLeastUnacked(kTestPathId2)).WillOnce(Return(4)); | 149 EXPECT_CALL(*manager_2_, GetLeastUnacked(kTestPathId2)).WillOnce(Return(4)); |
178 EXPECT_EQ(2u, multipath_manager_.GetLeastUnacked(kDefaultPathId)); | 150 EXPECT_EQ(2u, multipath_manager_.GetLeastUnacked(kDefaultPathId)); |
179 EXPECT_EQ(3u, multipath_manager_.GetLeastUnacked(kTestPathId1)); | 151 EXPECT_EQ(3u, multipath_manager_.GetLeastUnacked(kTestPathId1)); |
180 EXPECT_EQ(4u, multipath_manager_.GetLeastUnacked(kTestPathId2)); | 152 EXPECT_EQ(4u, multipath_manager_.GetLeastUnacked(kTestPathId2)); |
181 EXPECT_EQ(0u, multipath_manager_.GetLeastUnacked(kTestPathId3)); | 153 EXPECT_DFATAL(multipath_manager_.GetLeastUnacked(kTestPathId3), ""); |
182 } | 154 } |
183 | 155 |
184 TEST_F(QuicMultipathSentPacketManagerTest, OnPacketSent) { | 156 TEST_F(QuicMultipathSentPacketManagerTest, OnPacketSent) { |
185 SerializedPacket packet0(kDefaultPathId, 1, PACKET_6BYTE_PACKET_NUMBER, | 157 SerializedPacket packet0(kDefaultPathId, 1, PACKET_6BYTE_PACKET_NUMBER, |
186 nullptr, 1250, 0u, false, false); | 158 nullptr, 1250, 0u, false, false); |
187 SerializedPacket packet1(kTestPathId1, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, | 159 SerializedPacket packet1(kTestPathId1, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, |
188 1250, 0u, false, false); | 160 1250, 0u, false, false); |
189 SerializedPacket packet2(kTestPathId2, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, | 161 SerializedPacket packet2(kTestPathId2, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, |
190 1250, 0u, false, false); | 162 1250, 0u, false, false); |
191 SerializedPacket packet3(kTestPathId3, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, | 163 SerializedPacket packet3(kTestPathId3, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 EXPECT_CALL(*manager_2_, OnConnectionMigration(_, _)).Times(0); | 268 EXPECT_CALL(*manager_2_, OnConnectionMigration(_, _)).Times(0); |
297 multipath_manager_.OnConnectionMigration(kDefaultPathId, PORT_CHANGE); | 269 multipath_manager_.OnConnectionMigration(kDefaultPathId, PORT_CHANGE); |
298 EXPECT_CALL(delegate_, | 270 EXPECT_CALL(delegate_, |
299 OnUnrecoverableError(QUIC_MULTIPATH_PATH_NOT_ACTIVE, _, _)); | 271 OnUnrecoverableError(QUIC_MULTIPATH_PATH_NOT_ACTIVE, _, _)); |
300 /* | 272 /* |
301 EXPECT_DFATAL( | 273 EXPECT_DFATAL( |
302 multipath_manager_.OnConnectionMigration(kTestPathId2, PORT_CHANGE), ""); | 274 multipath_manager_.OnConnectionMigration(kTestPathId2, PORT_CHANGE), ""); |
303 */ | 275 */ |
304 EXPECT_CALL(delegate_, | 276 EXPECT_CALL(delegate_, |
305 OnUnrecoverableError(QUIC_MULTIPATH_PATH_DOES_NOT_EXIST, _, _)); | 277 OnUnrecoverableError(QUIC_MULTIPATH_PATH_DOES_NOT_EXIST, _, _)); |
306 multipath_manager_.OnConnectionMigration(kTestPathId3, PORT_CHANGE); | 278 EXPECT_DFATAL( |
| 279 multipath_manager_.OnConnectionMigration(kTestPathId3, PORT_CHANGE), ""); |
307 } | 280 } |
308 | 281 |
309 TEST_F(QuicMultipathSentPacketManagerTest, IsHandshakeConfirmed) { | 282 TEST_F(QuicMultipathSentPacketManagerTest, IsHandshakeConfirmed) { |
310 EXPECT_CALL(*manager_0_, IsHandshakeConfirmed()).WillOnce(Return(true)); | 283 EXPECT_CALL(*manager_0_, IsHandshakeConfirmed()).WillOnce(Return(true)); |
311 EXPECT_TRUE(multipath_manager_.IsHandshakeConfirmed()); | 284 EXPECT_TRUE(multipath_manager_.IsHandshakeConfirmed()); |
312 } | 285 } |
313 | 286 |
314 TEST_F(QuicMultipathSentPacketManagerTest, SetDebugDelegate) { | 287 TEST_F(QuicMultipathSentPacketManagerTest, SetDebugDelegate) { |
315 EXPECT_CALL(*manager_0_, SetDebugDelegate(nullptr)); | 288 EXPECT_CALL(*manager_0_, SetDebugDelegate(nullptr)); |
316 EXPECT_CALL(*manager_1_, SetDebugDelegate(nullptr)); | 289 EXPECT_CALL(*manager_1_, SetDebugDelegate(nullptr)); |
317 EXPECT_CALL(*manager_2_, SetDebugDelegate(nullptr)); | 290 EXPECT_CALL(*manager_2_, SetDebugDelegate(nullptr)); |
318 multipath_manager_.SetDebugDelegate(nullptr); | 291 multipath_manager_.SetDebugDelegate(nullptr); |
319 } | 292 } |
320 | 293 |
321 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestObserved) { | 294 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestObserved) { |
322 EXPECT_CALL(*manager_0_, GetLargestObserved(kDefaultPathId)) | 295 EXPECT_CALL(*manager_0_, GetLargestObserved(kDefaultPathId)) |
323 .WillOnce(Return(10)); | 296 .WillOnce(Return(10)); |
324 EXPECT_CALL(*manager_1_, GetLargestObserved(kTestPathId1)) | 297 EXPECT_CALL(*manager_1_, GetLargestObserved(kTestPathId1)) |
325 .WillOnce(Return(11)); | 298 .WillOnce(Return(11)); |
326 EXPECT_CALL(*manager_2_, GetLargestObserved(kTestPathId2)) | 299 EXPECT_CALL(*manager_2_, GetLargestObserved(kTestPathId2)) |
327 .WillOnce(Return(12)); | 300 .WillOnce(Return(12)); |
328 EXPECT_EQ(10u, multipath_manager_.GetLargestObserved(kDefaultPathId)); | 301 EXPECT_EQ(10u, multipath_manager_.GetLargestObserved(kDefaultPathId)); |
329 EXPECT_EQ(11u, multipath_manager_.GetLargestObserved(kTestPathId1)); | 302 EXPECT_EQ(11u, multipath_manager_.GetLargestObserved(kTestPathId1)); |
330 EXPECT_EQ(12u, multipath_manager_.GetLargestObserved(kTestPathId2)); | 303 EXPECT_EQ(12u, multipath_manager_.GetLargestObserved(kTestPathId2)); |
331 EXPECT_DFATAL(multipath_manager_.GetLargestObserved(kTestPathId3), ""); | 304 EXPECT_EQ(0u, multipath_manager_.GetLargestObserved(kTestPathId3)); |
332 } | 305 } |
333 | 306 |
334 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestSentPacket) { | 307 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestSentPacket) { |
335 EXPECT_CALL(*manager_0_, GetLargestSentPacket(kDefaultPathId)) | 308 EXPECT_CALL(*manager_0_, GetLargestSentPacket(kDefaultPathId)) |
336 .WillOnce(Return(10)); | 309 .WillOnce(Return(10)); |
337 EXPECT_CALL(*manager_1_, GetLargestSentPacket(kTestPathId1)) | 310 EXPECT_CALL(*manager_1_, GetLargestSentPacket(kTestPathId1)) |
338 .WillOnce(Return(11)); | 311 .WillOnce(Return(11)); |
339 EXPECT_CALL(*manager_2_, GetLargestSentPacket(kTestPathId2)) | 312 EXPECT_CALL(*manager_2_, GetLargestSentPacket(kTestPathId2)) |
340 .WillOnce(Return(12)); | 313 .WillOnce(Return(12)); |
341 EXPECT_EQ(10u, multipath_manager_.GetLargestSentPacket(kDefaultPathId)); | 314 EXPECT_EQ(10u, multipath_manager_.GetLargestSentPacket(kDefaultPathId)); |
342 EXPECT_EQ(11u, multipath_manager_.GetLargestSentPacket(kTestPathId1)); | 315 EXPECT_EQ(11u, multipath_manager_.GetLargestSentPacket(kTestPathId1)); |
343 EXPECT_EQ(12u, multipath_manager_.GetLargestSentPacket(kTestPathId2)); | 316 EXPECT_EQ(12u, multipath_manager_.GetLargestSentPacket(kTestPathId2)); |
344 EXPECT_EQ(0u, multipath_manager_.GetLargestSentPacket(kTestPathId3)); | 317 EXPECT_EQ(0u, multipath_manager_.GetLargestSentPacket(kTestPathId3)); |
345 } | 318 } |
346 | 319 |
347 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastPacketAwaitedByPeer) { | 320 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastPacketAwaitedByPeer) { |
348 EXPECT_CALL(*manager_0_, GetLeastPacketAwaitedByPeer(kDefaultPathId)) | 321 EXPECT_CALL(*manager_0_, GetLeastPacketAwaitedByPeer(kDefaultPathId)) |
349 .WillOnce(Return(10)); | 322 .WillOnce(Return(10)); |
350 EXPECT_CALL(*manager_1_, GetLeastPacketAwaitedByPeer(kTestPathId1)) | 323 EXPECT_CALL(*manager_1_, GetLeastPacketAwaitedByPeer(kTestPathId1)) |
351 .WillOnce(Return(11)); | 324 .WillOnce(Return(11)); |
352 EXPECT_CALL(*manager_2_, GetLeastPacketAwaitedByPeer(kTestPathId2)) | 325 EXPECT_CALL(*manager_2_, GetLeastPacketAwaitedByPeer(kTestPathId2)) |
353 .WillOnce(Return(12)); | 326 .WillOnce(Return(12)); |
354 EXPECT_EQ(10u, | 327 EXPECT_EQ(10u, |
355 multipath_manager_.GetLeastPacketAwaitedByPeer(kDefaultPathId)); | 328 multipath_manager_.GetLeastPacketAwaitedByPeer(kDefaultPathId)); |
356 EXPECT_EQ(11u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId1)); | 329 EXPECT_EQ(11u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId1)); |
357 EXPECT_EQ(12u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId2)); | 330 EXPECT_EQ(12u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId2)); |
358 EXPECT_EQ(0u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId3)); | 331 EXPECT_DFATAL(multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId3), |
| 332 ""); |
359 } | 333 } |
360 | 334 |
361 TEST_F(QuicMultipathSentPacketManagerTest, SetNetworkChangeVisitor) { | 335 TEST_F(QuicMultipathSentPacketManagerTest, SetNetworkChangeVisitor) { |
362 EXPECT_CALL(*manager_0_, SetNetworkChangeVisitor(nullptr)); | 336 EXPECT_CALL(*manager_0_, SetNetworkChangeVisitor(nullptr)); |
363 EXPECT_CALL(*manager_1_, SetNetworkChangeVisitor(nullptr)); | 337 EXPECT_CALL(*manager_1_, SetNetworkChangeVisitor(nullptr)); |
364 multipath_manager_.SetNetworkChangeVisitor(nullptr); | 338 multipath_manager_.SetNetworkChangeVisitor(nullptr); |
365 } | 339 } |
366 | 340 |
367 TEST_F(QuicMultipathSentPacketManagerTest, InSlowStart) { | 341 TEST_F(QuicMultipathSentPacketManagerTest, InSlowStart) { |
368 EXPECT_CALL(*manager_0_, InSlowStart()).WillOnce(Return(true)); | 342 EXPECT_CALL(*manager_0_, InSlowStart()).WillOnce(Return(true)); |
369 EXPECT_TRUE(multipath_manager_.InSlowStart()); | 343 EXPECT_TRUE(multipath_manager_.InSlowStart()); |
370 } | 344 } |
371 | 345 |
372 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveRtoCount) { | 346 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveRtoCount) { |
373 EXPECT_CALL(*manager_0_, GetConsecutiveRtoCount()).WillOnce(Return(4)); | 347 EXPECT_CALL(*manager_0_, GetConsecutiveRtoCount()).WillOnce(Return(4)); |
374 EXPECT_EQ(4u, multipath_manager_.GetConsecutiveRtoCount()); | 348 EXPECT_EQ(4u, multipath_manager_.GetConsecutiveRtoCount()); |
375 } | 349 } |
376 | 350 |
377 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveTlpCount) { | 351 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveTlpCount) { |
378 EXPECT_CALL(*manager_0_, GetConsecutiveTlpCount()).WillOnce(Return(3)); | 352 EXPECT_CALL(*manager_0_, GetConsecutiveTlpCount()).WillOnce(Return(3)); |
379 EXPECT_EQ(3u, multipath_manager_.GetConsecutiveTlpCount()); | 353 EXPECT_EQ(3u, multipath_manager_.GetConsecutiveTlpCount()); |
380 } | 354 } |
381 | 355 |
382 } // namespace | 356 } // namespace |
383 } // namespace test | 357 } // namespace test |
384 } // namespace net | 358 } // namespace net |
OLD | NEW |