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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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_connection_stats.h ('k') | net/quic/quic_crypto_client_stream.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.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/basictypes.h"
10 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/quic/congestion_control/loss_detection_interface.h" 14 #include "net/quic/congestion_control/loss_detection_interface.h"
15 #include "net/quic/congestion_control/send_algorithm_interface.h" 15 #include "net/quic/congestion_control/send_algorithm_interface.h"
16 #include "net/quic/crypto/null_encrypter.h" 16 #include "net/quic/crypto/null_encrypter.h"
17 #include "net/quic/crypto/quic_decrypter.h" 17 #include "net/quic/crypto/quic_decrypter.h"
18 #include "net/quic/crypto/quic_encrypter.h" 18 #include "net/quic/crypto/quic_encrypter.h"
19 #include "net/quic/quic_flags.h" 19 #include "net/quic/quic_flags.h"
20 #include "net/quic/quic_protocol.h" 20 #include "net/quic/quic_protocol.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 const QuicPacketEntropyHash kTestEntropyHash = 76; 65 const QuicPacketEntropyHash kTestEntropyHash = 76;
66 66
67 const int kDefaultRetransmissionTimeMs = 500; 67 const int kDefaultRetransmissionTimeMs = 500;
68 68
69 const IPEndPoint kPeerAddress = IPEndPoint(Loopback6(), /*port=*/12345); 69 const IPEndPoint kPeerAddress = IPEndPoint(Loopback6(), /*port=*/12345);
70 const IPEndPoint kSelfAddress = IPEndPoint(Loopback6(), /*port=*/443); 70 const IPEndPoint kSelfAddress = IPEndPoint(Loopback6(), /*port=*/443);
71 71
72 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message. 72 // TaggingEncrypter appends kTagSize bytes of |tag| to the end of each message.
73 class TaggingEncrypter : public QuicEncrypter { 73 class TaggingEncrypter : public QuicEncrypter {
74 public: 74 public:
75 explicit TaggingEncrypter(uint8 tag) : tag_(tag) {} 75 explicit TaggingEncrypter(uint8_t tag) : tag_(tag) {}
76 76
77 ~TaggingEncrypter() override {} 77 ~TaggingEncrypter() override {}
78 78
79 // QuicEncrypter interface. 79 // QuicEncrypter interface.
80 bool SetKey(StringPiece key) override { return true; } 80 bool SetKey(StringPiece key) override { return true; }
81 81
82 bool SetNoncePrefix(StringPiece nonce_prefix) override { return true; } 82 bool SetNoncePrefix(StringPiece nonce_prefix) override { return true; }
83 83
84 bool EncryptPacket(QuicPacketNumber packet_number, 84 bool EncryptPacket(QuicPacketNumber packet_number,
85 StringPiece associated_data, 85 StringPiece associated_data,
(...skipping 25 matching lines...) Expand all
111 111
112 StringPiece GetKey() const override { return StringPiece(); } 112 StringPiece GetKey() const override { return StringPiece(); }
113 113
114 StringPiece GetNoncePrefix() const override { return StringPiece(); } 114 StringPiece GetNoncePrefix() const override { return StringPiece(); }
115 115
116 private: 116 private:
117 enum { 117 enum {
118 kTagSize = 12, 118 kTagSize = 12,
119 }; 119 };
120 120
121 const uint8 tag_; 121 const uint8_t tag_;
122 122
123 DISALLOW_COPY_AND_ASSIGN(TaggingEncrypter); 123 DISALLOW_COPY_AND_ASSIGN(TaggingEncrypter);
124 }; 124 };
125 125
126 // TaggingDecrypter ensures that the final kTagSize bytes of the message all 126 // TaggingDecrypter ensures that the final kTagSize bytes of the message all
127 // have the same value and then removes them. 127 // have the same value and then removes them.
128 class TaggingDecrypter : public QuicDecrypter { 128 class TaggingDecrypter : public QuicDecrypter {
129 public: 129 public:
130 ~TaggingDecrypter() override {} 130 ~TaggingDecrypter() override {}
131 131
(...skipping 16 matching lines...) Expand all
148 } 148 }
149 *output_length = ciphertext.size() - kTagSize; 149 *output_length = ciphertext.size() - kTagSize;
150 memcpy(output, ciphertext.data(), *output_length); 150 memcpy(output, ciphertext.data(), *output_length);
151 return true; 151 return true;
152 } 152 }
153 153
154 StringPiece GetKey() const override { return StringPiece(); } 154 StringPiece GetKey() const override { return StringPiece(); }
155 StringPiece GetNoncePrefix() const override { return StringPiece(); } 155 StringPiece GetNoncePrefix() const override { return StringPiece(); }
156 const char* cipher_name() const override { return "Tagging"; } 156 const char* cipher_name() const override { return "Tagging"; }
157 // Use a distinct value starting with 0xFFFFFF, which is never used by TLS. 157 // Use a distinct value starting with 0xFFFFFF, which is never used by TLS.
158 uint32 cipher_id() const override { return 0xFFFFFFF0; } 158 uint32_t cipher_id() const override { return 0xFFFFFFF0; }
159 159
160 protected: 160 protected:
161 virtual uint8 GetTag(StringPiece ciphertext) { 161 virtual uint8_t GetTag(StringPiece ciphertext) {
162 return ciphertext.data()[ciphertext.size() - 1]; 162 return ciphertext.data()[ciphertext.size() - 1];
163 } 163 }
164 164
165 private: 165 private:
166 enum { 166 enum {
167 kTagSize = 12, 167 kTagSize = 12,
168 }; 168 };
169 169
170 bool CheckTag(StringPiece ciphertext, uint8 tag) { 170 bool CheckTag(StringPiece ciphertext, uint8_t tag) {
171 for (size_t i = ciphertext.size() - kTagSize; i < ciphertext.size(); i++) { 171 for (size_t i = ciphertext.size() - kTagSize; i < ciphertext.size(); i++) {
172 if (ciphertext.data()[i] != tag) { 172 if (ciphertext.data()[i] != tag) {
173 return false; 173 return false;
174 } 174 }
175 } 175 }
176 176
177 return true; 177 return true;
178 } 178 }
179 }; 179 };
180 180
181 // StringTaggingDecrypter ensures that the final kTagSize bytes of the message 181 // StringTaggingDecrypter ensures that the final kTagSize bytes of the message
182 // match the expected value. 182 // match the expected value.
183 class StrictTaggingDecrypter : public TaggingDecrypter { 183 class StrictTaggingDecrypter : public TaggingDecrypter {
184 public: 184 public:
185 explicit StrictTaggingDecrypter(uint8 tag) : tag_(tag) {} 185 explicit StrictTaggingDecrypter(uint8_t tag) : tag_(tag) {}
186 ~StrictTaggingDecrypter() override {} 186 ~StrictTaggingDecrypter() override {}
187 187
188 // TaggingQuicDecrypter 188 // TaggingQuicDecrypter
189 uint8 GetTag(StringPiece ciphertext) override { return tag_; } 189 uint8_t GetTag(StringPiece ciphertext) override { return tag_; }
190 190
191 const char* cipher_name() const override { return "StrictTagging"; } 191 const char* cipher_name() const override { return "StrictTagging"; }
192 // Use a distinct value starting with 0xFFFFFF, which is never used by TLS. 192 // Use a distinct value starting with 0xFFFFFF, which is never used by TLS.
193 uint32 cipher_id() const override { return 0xFFFFFFF1; } 193 uint32_t cipher_id() const override { return 0xFFFFFFF1; }
194 194
195 private: 195 private:
196 const uint8 tag_; 196 const uint8_t tag_;
197 }; 197 };
198 198
199 class TestConnectionHelper : public QuicConnectionHelperInterface { 199 class TestConnectionHelper : public QuicConnectionHelperInterface {
200 public: 200 public:
201 class TestAlarm : public QuicAlarm { 201 class TestAlarm : public QuicAlarm {
202 public: 202 public:
203 explicit TestAlarm(QuicAlarm::Delegate* delegate) : QuicAlarm(delegate) {} 203 explicit TestAlarm(QuicAlarm::Delegate* delegate) : QuicAlarm(delegate) {}
204 204
205 void SetImpl() override {} 205 void SetImpl() override {}
206 void CancelImpl() override {} 206 void CancelImpl() override {}
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void set_perspective(Perspective perspective) { 349 void set_perspective(Perspective perspective) {
350 // We invert perspective here, because the framer needs to parse packets 350 // We invert perspective here, because the framer needs to parse packets
351 // we send. 351 // we send.
352 perspective = perspective == Perspective::IS_CLIENT 352 perspective = perspective == Perspective::IS_CLIENT
353 ? Perspective::IS_SERVER 353 ? Perspective::IS_SERVER
354 : Perspective::IS_CLIENT; 354 : Perspective::IS_CLIENT;
355 QuicFramerPeer::SetPerspective(framer_.framer(), perspective); 355 QuicFramerPeer::SetPerspective(framer_.framer(), perspective);
356 } 356 }
357 357
358 // final_bytes_of_last_packet_ returns the last four bytes of the previous 358 // final_bytes_of_last_packet_ returns the last four bytes of the previous
359 // packet as a little-endian, uint32. This is intended to be used with a 359 // packet as a little-endian, uint32_t. This is intended to be used with a
360 // TaggingEncrypter so that tests can determine which encrypter was used for 360 // TaggingEncrypter so that tests can determine which encrypter was used for
361 // a given packet. 361 // a given packet.
362 uint32 final_bytes_of_last_packet() { return final_bytes_of_last_packet_; } 362 uint32_t final_bytes_of_last_packet() { return final_bytes_of_last_packet_; }
363 363
364 // Returns the final bytes of the second to last packet. 364 // Returns the final bytes of the second to last packet.
365 uint32 final_bytes_of_previous_packet() { 365 uint32_t final_bytes_of_previous_packet() {
366 return final_bytes_of_previous_packet_; 366 return final_bytes_of_previous_packet_;
367 } 367 }
368 368
369 void use_tagging_decrypter() { use_tagging_decrypter_ = true; } 369 void use_tagging_decrypter() { use_tagging_decrypter_ = true; }
370 370
371 uint32 packets_write_attempts() { return packets_write_attempts_; } 371 uint32_t packets_write_attempts() { return packets_write_attempts_; }
372 372
373 void Reset() { framer_.Reset(); } 373 void Reset() { framer_.Reset(); }
374 374
375 void SetSupportedVersions(const QuicVersionVector& versions) { 375 void SetSupportedVersions(const QuicVersionVector& versions) {
376 framer_.SetSupportedVersions(versions); 376 framer_.SetSupportedVersions(versions);
377 } 377 }
378 378
379 void set_max_packet_size(QuicByteCount max_packet_size) { 379 void set_max_packet_size(QuicByteCount max_packet_size) {
380 max_packet_size_ = max_packet_size; 380 max_packet_size_ = max_packet_size;
381 } 381 }
382 382
383 private: 383 private:
384 QuicVersion version_; 384 QuicVersion version_;
385 SimpleQuicFramer framer_; 385 SimpleQuicFramer framer_;
386 size_t last_packet_size_; 386 size_t last_packet_size_;
387 bool write_blocked_; 387 bool write_blocked_;
388 bool write_should_fail_; 388 bool write_should_fail_;
389 bool block_on_next_write_; 389 bool block_on_next_write_;
390 bool is_write_blocked_data_buffered_; 390 bool is_write_blocked_data_buffered_;
391 uint32 final_bytes_of_last_packet_; 391 uint32_t final_bytes_of_last_packet_;
392 uint32 final_bytes_of_previous_packet_; 392 uint32_t final_bytes_of_previous_packet_;
393 bool use_tagging_decrypter_; 393 bool use_tagging_decrypter_;
394 uint32 packets_write_attempts_; 394 uint32_t packets_write_attempts_;
395 MockClock* clock_; 395 MockClock* clock_;
396 // If non-zero, the clock will pause during WritePacket for this amount of 396 // If non-zero, the clock will pause during WritePacket for this amount of
397 // time. 397 // time.
398 QuicTime::Delta write_pause_time_delta_; 398 QuicTime::Delta write_pause_time_delta_;
399 QuicByteCount max_packet_size_; 399 QuicByteCount max_packet_size_;
400 400
401 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter); 401 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter);
402 }; 402 };
403 403
404 class TestConnection : public QuicConnection { 404 class TestConnection : public QuicConnection {
(...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after
3285 3285
3286 // Set a forward-secure encrypter but do not make it the default, and 3286 // Set a forward-secure encrypter but do not make it the default, and
3287 // verify that it is not yet used. 3287 // verify that it is not yet used.
3288 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE, 3288 connection_.SetEncrypter(ENCRYPTION_FORWARD_SECURE,
3289 new TaggingEncrypter(0x03)); 3289 new TaggingEncrypter(0x03));
3290 SendAckPacketToPeer(); 3290 SendAckPacketToPeer();
3291 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 3291 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
3292 3292
3293 // Now send a packet "Far enough" after the encrypter was set and verify that 3293 // Now send a packet "Far enough" after the encrypter was set and verify that
3294 // the forward-secure encrypter is now used. 3294 // the forward-secure encrypter is now used.
3295 for (uint64 i = 0; i < 3 * congestion_window - 1; ++i) { 3295 for (uint64_t i = 0; i < 3 * congestion_window - 1; ++i) {
3296 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 3296 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
3297 SendAckPacketToPeer(); 3297 SendAckPacketToPeer();
3298 } 3298 }
3299 EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); 3299 EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
3300 } 3300 }
3301 3301
3302 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) { 3302 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
3303 // SetFromConfig is always called after construction from InitializeSession. 3303 // SetFromConfig is always called after construction from InitializeSession.
3304 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3304 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3305 QuicConfig config; 3305 QuicConfig config;
3306 connection_.SetFromConfig(config); 3306 connection_.SetFromConfig(config);
3307 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3307 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3308 use_tagging_decrypter(); 3308 use_tagging_decrypter();
3309 3309
3310 const uint8 tag = 0x07; 3310 const uint8_t tag = 0x07;
3311 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 3311 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
3312 3312
3313 // Process an encrypted packet which can not yet be decrypted which should 3313 // Process an encrypted packet which can not yet be decrypted which should
3314 // result in the packet being buffered. 3314 // result in the packet being buffered.
3315 ProcessDataPacketAtLevel(1, 0, kEntropyFlag, ENCRYPTION_INITIAL); 3315 ProcessDataPacketAtLevel(1, 0, kEntropyFlag, ENCRYPTION_INITIAL);
3316 3316
3317 // Transition to the new encryption state and process another encrypted packet 3317 // Transition to the new encryption state and process another encrypted packet
3318 // which should result in the original packet being processed. 3318 // which should result in the original packet being processed.
3319 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); 3319 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
3320 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); 3320 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
3321 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 3321 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
3322 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(2); 3322 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(2);
3323 ProcessDataPacketAtLevel(2, 0, kEntropyFlag, ENCRYPTION_INITIAL); 3323 ProcessDataPacketAtLevel(2, 0, kEntropyFlag, ENCRYPTION_INITIAL);
3324 3324
3325 // Finally, process a third packet and note that we do not reprocess the 3325 // Finally, process a third packet and note that we do not reprocess the
3326 // buffered packet. 3326 // buffered packet.
3327 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 3327 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
3328 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL); 3328 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL);
3329 } 3329 }
3330 3330
3331 TEST_P(QuicConnectionTest, ProcessBufferedFECGroup) { 3331 TEST_P(QuicConnectionTest, ProcessBufferedFECGroup) {
3332 // SetFromConfig is always called after construction from InitializeSession. 3332 // SetFromConfig is always called after construction from InitializeSession.
3333 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3333 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3334 QuicConfig config; 3334 QuicConfig config;
3335 config.set_max_undecryptable_packets(100); 3335 config.set_max_undecryptable_packets(100);
3336 connection_.SetFromConfig(config); 3336 connection_.SetFromConfig(config);
3337 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3337 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3338 use_tagging_decrypter(); 3338 use_tagging_decrypter();
3339 3339
3340 const uint8 tag = 0x07; 3340 const uint8_t tag = 0x07;
3341 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 3341 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
3342 3342
3343 // Don't send packet 1 and buffer initially encrypted packets. 3343 // Don't send packet 1 and buffer initially encrypted packets.
3344 ProcessFecProtectedPacketAtLevel(2, 1, false, !kEntropyFlag, 3344 ProcessFecProtectedPacketAtLevel(2, 1, false, !kEntropyFlag,
3345 ENCRYPTION_INITIAL); 3345 ENCRYPTION_INITIAL);
3346 ProcessFecPacketAtLevel(3, 1, false, kEntropyFlag, nullptr, 3346 ProcessFecPacketAtLevel(3, 1, false, kEntropyFlag, nullptr,
3347 ENCRYPTION_INITIAL); 3347 ENCRYPTION_INITIAL);
3348 // Since the packets were buffered, no FEC group should be open. 3348 // Since the packets were buffered, no FEC group should be open.
3349 ASSERT_EQ(0u, connection_.NumFecGroups()); 3349 ASSERT_EQ(0u, connection_.NumFecGroups());
3350 3350
(...skipping 16 matching lines...) Expand all
3367 3367
3368 TEST_P(QuicConnectionTest, Buffer100NonDecryptablePackets) { 3368 TEST_P(QuicConnectionTest, Buffer100NonDecryptablePackets) {
3369 // SetFromConfig is always called after construction from InitializeSession. 3369 // SetFromConfig is always called after construction from InitializeSession.
3370 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 3370 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3371 QuicConfig config; 3371 QuicConfig config;
3372 config.set_max_undecryptable_packets(100); 3372 config.set_max_undecryptable_packets(100);
3373 connection_.SetFromConfig(config); 3373 connection_.SetFromConfig(config);
3374 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3374 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3375 use_tagging_decrypter(); 3375 use_tagging_decrypter();
3376 3376
3377 const uint8 tag = 0x07; 3377 const uint8_t tag = 0x07;
3378 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 3378 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
3379 3379
3380 // Process an encrypted packet which can not yet be decrypted which should 3380 // Process an encrypted packet which can not yet be decrypted which should
3381 // result in the packet being buffered. 3381 // result in the packet being buffered.
3382 for (QuicPacketNumber i = 1; i <= 100; ++i) { 3382 for (QuicPacketNumber i = 1; i <= 100; ++i) {
3383 ProcessDataPacketAtLevel(i, 0, kEntropyFlag, ENCRYPTION_INITIAL); 3383 ProcessDataPacketAtLevel(i, 0, kEntropyFlag, ENCRYPTION_INITIAL);
3384 } 3384 }
3385 3385
3386 // Transition to the new encryption state and process another encrypted packet 3386 // Transition to the new encryption state and process another encrypted packet
3387 // which should result in the original packets being processed. 3387 // which should result in the original packets being processed.
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
4281 connection_.SendStreamDataWithString(3, payload, 0, !kFin, nullptr) 4281 connection_.SendStreamDataWithString(3, payload, 0, !kFin, nullptr)
4282 .bytes_consumed); 4282 .bytes_consumed);
4283 // Just like above, we save 8 bytes on payload, and 8 on truncation. 4283 // Just like above, we save 8 bytes on payload, and 8 on truncation.
4284 EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() + 8 * 2); 4284 EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() + 8 * 2);
4285 } 4285 }
4286 4286
4287 TEST_P(QuicConnectionTest, SendDelayedAck) { 4287 TEST_P(QuicConnectionTest, SendDelayedAck) {
4288 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime()); 4288 QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime());
4289 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4289 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4290 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 4290 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4291 const uint8 tag = 0x07; 4291 const uint8_t tag = 0x07;
4292 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); 4292 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
4293 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 4293 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
4294 // Process a packet from the non-crypto stream. 4294 // Process a packet from the non-crypto stream.
4295 frame1_.stream_id = 3; 4295 frame1_.stream_id = 3;
4296 4296
4297 // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used 4297 // The same as ProcessPacket(1) except that ENCRYPTION_INITIAL is used
4298 // instead of ENCRYPTION_NONE. 4298 // instead of ENCRYPTION_NONE.
4299 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 4299 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4300 ProcessDataPacketAtLevel(1, 0, !kEntropyFlag, ENCRYPTION_INITIAL); 4300 ProcessDataPacketAtLevel(1, 0, !kEntropyFlag, ENCRYPTION_INITIAL);
4301 4301
(...skipping 15 matching lines...) Expand all
4317 const size_t kMinRttMs = 40; 4317 const size_t kMinRttMs = 40;
4318 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_); 4318 RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(manager_);
4319 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs), 4319 rtt_stats->UpdateRtt(QuicTime::Delta::FromMilliseconds(kMinRttMs),
4320 QuicTime::Delta::Zero(), QuicTime::Zero()); 4320 QuicTime::Delta::Zero(), QuicTime::Zero());
4321 // The ack time should be based on min_rtt/4, since it's less than the 4321 // The ack time should be based on min_rtt/4, since it's less than the
4322 // default delayed ack time. 4322 // default delayed ack time.
4323 QuicTime ack_time = clock_.ApproximateNow().Add( 4323 QuicTime ack_time = clock_.ApproximateNow().Add(
4324 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4)); 4324 QuicTime::Delta::FromMilliseconds(kMinRttMs / 4));
4325 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4325 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4326 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 4326 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
4327 const uint8 tag = 0x07; 4327 const uint8_t tag = 0x07;
4328 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag)); 4328 connection_.SetDecrypter(ENCRYPTION_INITIAL, new StrictTaggingDecrypter(tag));
4329 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 4329 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
4330 // Process a packet from the non-crypto stream. 4330 // Process a packet from the non-crypto stream.
4331 frame1_.stream_id = 3; 4331 frame1_.stream_id = 3;
4332 4332
4333 // Process all the initial packets in order so there aren't missing packets. 4333 // Process all the initial packets in order so there aren't missing packets.
4334 QuicPacketNumber kFirstDecimatedPacket = 101; 4334 QuicPacketNumber kFirstDecimatedPacket = 101;
4335 for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) { 4335 for (unsigned int i = 0; i < kFirstDecimatedPacket - 1; ++i) {
4336 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1); 4336 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(1);
4337 ProcessDataPacketAtLevel(1 + i, 0, !kEntropyFlag, ENCRYPTION_INITIAL); 4337 ProcessDataPacketAtLevel(1 + i, 0, !kEntropyFlag, ENCRYPTION_INITIAL);
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
5490 EXPECT_CALL(visitor_, 5490 EXPECT_CALL(visitor_,
5491 OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, false)); 5491 OnConnectionClosed(QUIC_UNENCRYPTED_STREAM_DATA, false));
5492 EXPECT_DFATAL(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), 5492 EXPECT_DFATAL(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr),
5493 "Cannot send stream data without encryption."); 5493 "Cannot send stream data without encryption.");
5494 EXPECT_FALSE(connection_.connected()); 5494 EXPECT_FALSE(connection_.connected());
5495 } 5495 }
5496 5496
5497 } // namespace 5497 } // namespace
5498 } // namespace test 5498 } // namespace test
5499 } // namespace net 5499 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_stats.h ('k') | net/quic/quic_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698