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

Side by Side Diff: net/quic/quic_connection_helper_test.cc

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_connection_logger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_connection_helper.h" 5 #include "net/quic/quic_connection_helper.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/quic/crypto/quic_decrypter.h" 10 #include "net/quic/crypto/quic_decrypter.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 MessageLoop::current()->RunUntilIdle(); 365 MessageLoop::current()->RunUntilIdle();
366 EXPECT_TRUE(AtEof()); 366 EXPECT_TRUE(AtEof());
367 } 367 }
368 368
369 TEST_F(QuicConnectionHelperTest, TimeoutAfterSend) { 369 TEST_F(QuicConnectionHelperTest, TimeoutAfterSend) {
370 AddWrite(SYNCHRONOUS, ConstructAckPacket(1)); 370 AddWrite(SYNCHRONOUS, ConstructAckPacket(1));
371 AddWrite(SYNCHRONOUS, ConstructClosePacket(2, 1)); 371 AddWrite(SYNCHRONOUS, ConstructClosePacket(2, 1));
372 Initialize(); 372 Initialize();
373 373
374 EXPECT_TRUE(connection_->connected()); 374 EXPECT_TRUE(connection_->connected());
375 EXPECT_EQ(0u, clock_.NowAsDeltaSinceUnixEpoch().ToMicroseconds()); 375 QuicTime start = clock_.ApproximateNow();
376 376
377 // When we send a packet, the timeout will change to 5000 + kDefaultTimeout. 377 // When we send a packet, the timeout will change to 5000 + kDefaultTimeout.
378 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(5000)); 378 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(5000));
379 EXPECT_EQ(5000u, clock_.NowAsDeltaSinceUnixEpoch().ToMicroseconds()); 379 EXPECT_EQ(5000u, clock_.ApproximateNow().Subtract(start).ToMicroseconds());
380 EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, NOT_RETRANSMISSION)); 380 EXPECT_CALL(*send_algorithm_, SentPacket(_, 1, _, NOT_RETRANSMISSION));
381 381
382 // Send an ack so we don't set the retransmission alarm. 382 // Send an ack so we don't set the retransmission alarm.
383 connection_->SendAck(); 383 connection_->SendAck();
384 384
385 // The original alarm will fire. We should not time out because we had a 385 // The original alarm will fire. We should not time out because we had a
386 // network event at t=5000. The alarm will reregister. 386 // network event at t=5000. The alarm will reregister.
387 runner_->RunNextTask(); 387 runner_->RunNextTask();
388 388
389 EXPECT_EQ(QuicTime::Zero().Add( 389 EXPECT_EQ(QuicTime::Zero().Add(
390 QuicTime::Delta::FromMicroseconds(kDefaultTimeoutUs)), 390 QuicTime::Delta::FromMicroseconds(kDefaultTimeoutUs)),
391 clock_.ApproximateNow()); 391 clock_.ApproximateNow());
392 EXPECT_TRUE(connection_->connected()); 392 EXPECT_TRUE(connection_->connected());
393 393
394 // This time, we should time out. 394 // This time, we should time out.
395 EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false)); 395 EXPECT_CALL(visitor_, ConnectionClose(QUIC_CONNECTION_TIMED_OUT, false));
396 EXPECT_CALL(*send_algorithm_, SentPacket(_, 2, _, NOT_RETRANSMISSION)); 396 EXPECT_CALL(*send_algorithm_, SentPacket(_, 2, _, NOT_RETRANSMISSION));
397 runner_->RunNextTask(); 397 runner_->RunNextTask();
398 EXPECT_EQ(kDefaultTimeoutUs + 5000, 398 EXPECT_EQ(kDefaultTimeoutUs + 5000, clock_.ApproximateNow().Subtract(
399 clock_.NowAsDeltaSinceUnixEpoch().ToMicroseconds()); 399 QuicTime::Zero()).ToMicroseconds());
400 EXPECT_FALSE(connection_->connected()); 400 EXPECT_FALSE(connection_->connected());
401 EXPECT_TRUE(AtEof()); 401 EXPECT_TRUE(AtEof());
402 } 402 }
403 403
404 TEST_F(QuicConnectionHelperTest, SendSchedulerDelayThenSend) { 404 TEST_F(QuicConnectionHelperTest, SendSchedulerDelayThenSend) {
405 AddWrite(SYNCHRONOUS, ConstructDataPacket(1)); 405 AddWrite(SYNCHRONOUS, ConstructDataPacket(1));
406 Initialize(); 406 Initialize();
407 407
408 // Test that if we send a packet with a delay, it ends up queued. 408 // Test that if we send a packet with a delay, it ends up queued.
409 EXPECT_CALL( 409 EXPECT_CALL(
(...skipping 12 matching lines...) Expand all
422 *send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly( 422 *send_algorithm_, TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillRepeatedly(
423 testing::Return(QuicTime::Delta::Zero())); 423 testing::Return(QuicTime::Delta::Zero()));
424 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true)); 424 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(testing::Return(true));
425 runner_->RunNextTask(); 425 runner_->RunNextTask();
426 EXPECT_EQ(0u, connection_->NumQueuedPackets()); 426 EXPECT_EQ(0u, connection_->NumQueuedPackets());
427 EXPECT_TRUE(AtEof()); 427 EXPECT_TRUE(AtEof());
428 } 428 }
429 429
430 } // namespace test 430 } // namespace test
431 } // namespace net 431 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_connection_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698