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

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

Issue 839143002: Roll Chrome into Mojo. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebase Created 5 years, 11 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
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.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_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "net/quic/crypto/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/null_encrypter.h" 10 #include "net/quic/crypto/null_encrypter.h"
11 #include "net/quic/crypto/quic_decrypter.h" 11 #include "net/quic/crypto/quic_decrypter.h"
12 #include "net/quic/crypto/quic_encrypter.h" 12 #include "net/quic/crypto/quic_encrypter.h"
13 #include "net/quic/quic_flags.h" 13 #include "net/quic/quic_flags.h"
14 #include "net/quic/quic_utils.h" 14 #include "net/quic/quic_utils.h"
15 #include "net/quic/test_tools/quic_packet_creator_peer.h" 15 #include "net/quic/test_tools/quic_packet_creator_peer.h"
16 #include "net/quic/test_tools/quic_packet_generator_peer.h" 16 #include "net/quic/test_tools/quic_packet_generator_peer.h"
17 #include "net/quic/test_tools/quic_test_utils.h" 17 #include "net/quic/test_tools/quic_test_utils.h"
18 #include "net/quic/test_tools/simple_quic_framer.h" 18 #include "net/quic/test_tools/simple_quic_framer.h"
19 #include "net/test/gtest_util.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 22
22 using base::StringPiece; 23 using base::StringPiece;
23 using std::string; 24 using std::string;
24 using testing::InSequence; 25 using testing::InSequence;
25 using testing::Return; 26 using testing::Return;
26 using testing::SaveArg; 27 using testing::SaveArg;
27 using testing::StrictMock; 28 using testing::StrictMock;
28 using testing::_; 29 using testing::_;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 kHeadersStreamId, MakeIOVector("foo"), 2, true, MAY_FEC_PROTECT, nullptr); 423 kHeadersStreamId, MakeIOVector("foo"), 2, true, MAY_FEC_PROTECT, nullptr);
423 EXPECT_EQ(3u, consumed.bytes_consumed); 424 EXPECT_EQ(3u, consumed.bytes_consumed);
424 EXPECT_TRUE(consumed.fin_consumed); 425 EXPECT_TRUE(consumed.fin_consumed);
425 EXPECT_FALSE(generator_.HasQueuedFrames()); 426 EXPECT_FALSE(generator_.HasQueuedFrames());
426 427
427 PacketContents contents; 428 PacketContents contents;
428 contents.num_stream_frames = 1; 429 contents.num_stream_frames = 1;
429 CheckPacketContains(contents, packet_); 430 CheckPacketContains(contents, packet_);
430 } 431 }
431 432
433 TEST_F(QuicPacketGeneratorTest, ConsumeData_EmptyData) {
434 ValueRestore<bool> old_flag(&FLAGS_quic_empty_data_no_fin_early_return, true);
435 EXPECT_DFATAL(generator_.ConsumeData(kHeadersStreamId, MakeIOVector(""), 0,
436 false, MAY_FEC_PROTECT, nullptr),
437 "Attempt to consume empty data without FIN.");
438 }
439
432 TEST_F(QuicPacketGeneratorTest, 440 TEST_F(QuicPacketGeneratorTest,
433 ConsumeDataMultipleTimes_WritableAndShouldNotFlush) { 441 ConsumeDataMultipleTimes_WritableAndShouldNotFlush) {
434 delegate_.SetCanWriteAnything(); 442 delegate_.SetCanWriteAnything();
435 generator_.StartBatchOperations(); 443 generator_.StartBatchOperations();
436 444
437 generator_.ConsumeData(kHeadersStreamId, MakeIOVector("foo"), 2, true, 445 generator_.ConsumeData(kHeadersStreamId, MakeIOVector("foo"), 2, true,
438 MAY_FEC_PROTECT, nullptr); 446 MAY_FEC_PROTECT, nullptr);
439 QuicConsumedData consumed = generator_.ConsumeData( 447 QuicConsumedData consumed = generator_.ConsumeData(
440 3, MakeIOVector("quux"), 7, false, MAY_FEC_PROTECT, nullptr); 448 3, MakeIOVector("quux"), 7, false, MAY_FEC_PROTECT, nullptr);
441 EXPECT_EQ(4u, consumed.bytes_consumed); 449 EXPECT_EQ(4u, consumed.bytes_consumed);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 EXPECT_EQ(3u, consumed.bytes_consumed); 579 EXPECT_EQ(3u, consumed.bytes_consumed);
572 EXPECT_TRUE(consumed.fin_consumed); 580 EXPECT_TRUE(consumed.fin_consumed);
573 EXPECT_FALSE(generator_.HasQueuedFrames()); 581 EXPECT_FALSE(generator_.HasQueuedFrames());
574 582
575 PacketContents contents; 583 PacketContents contents;
576 contents.num_stream_frames = 1; 584 contents.num_stream_frames = 1;
577 CheckPacketContains(contents, packet_); 585 CheckPacketContains(contents, packet_);
578 CheckPacketContains(contents, packet2_); 586 CheckPacketContains(contents, packet2_);
579 } 587 }
580 588
589 TEST_F(QuicPacketGeneratorTest, FecTimeoutOnRttChange) {
590 EXPECT_EQ(QuicTime::Delta::Zero(), generator_.fec_timeout());
591 generator_.OnRttChange(QuicTime::Delta::FromMilliseconds(300));
592 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(150), generator_.fec_timeout());
593 }
594
581 TEST_F(QuicPacketGeneratorTest, FecGroupSizeOnCongestionWindowChange) { 595 TEST_F(QuicPacketGeneratorTest, FecGroupSizeOnCongestionWindowChange) {
582 delegate_.SetCanWriteAnything(); 596 delegate_.SetCanWriteAnything();
583 creator_->set_max_packets_per_fec_group(50); 597 creator_->set_max_packets_per_fec_group(50);
584 EXPECT_EQ(50u, creator_->max_packets_per_fec_group()); 598 EXPECT_EQ(50u, creator_->max_packets_per_fec_group());
585 EXPECT_FALSE(creator_->IsFecGroupOpen()); 599 EXPECT_FALSE(creator_->IsFecGroupOpen());
586 600
587 // On reduced cwnd. 601 // On reduced cwnd.
588 generator_.OnCongestionWindowChange(7); 602 generator_.OnCongestionWindowChange(7);
589 EXPECT_EQ(3u, creator_->max_packets_per_fec_group()); 603 EXPECT_EQ(3u, creator_->max_packets_per_fec_group());
590 604
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 generator_.SetConnectionIdLength(7); 1010 generator_.SetConnectionIdLength(7);
997 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length()); 1011 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
998 generator_.SetConnectionIdLength(8); 1012 generator_.SetConnectionIdLength(8);
999 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length()); 1013 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
1000 generator_.SetConnectionIdLength(9); 1014 generator_.SetConnectionIdLength(9);
1001 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length()); 1015 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
1002 } 1016 }
1003 1017
1004 } // namespace test 1018 } // namespace test
1005 } // namespace net 1019 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698