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

Side by Side Diff: net/quic/test_tools/quic_test_utils.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/test_tools/quic_test_utils.h ('k') | net/tools/quic/end_to_end_test.cc » ('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/test_tools/quic_test_utils.h" 5 #include "net/quic/test_tools/quic_test_utils.h"
6 6
7 #include "base/sha1.h" 7 #include "base/sha1.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "net/quic/crypto/crypto_framer.h" 10 #include "net/quic/crypto/crypto_framer.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 : QuicSession(connection, DefaultQuicConfig()) { 320 : QuicSession(connection, DefaultQuicConfig()) {
321 InitializeSession(); 321 InitializeSession();
322 ON_CALL(*this, WritevData(_, _, _, _, _, _)) 322 ON_CALL(*this, WritevData(_, _, _, _, _, _))
323 .WillByDefault(testing::Return(QuicConsumedData(0, false))); 323 .WillByDefault(testing::Return(QuicConsumedData(0, false)));
324 } 324 }
325 325
326 MockSession::~MockSession() { 326 MockSession::~MockSession() {
327 } 327 }
328 328
329 TestSession::TestSession(QuicConnection* connection, const QuicConfig& config) 329 TestSession::TestSession(QuicConnection* connection, const QuicConfig& config)
330 : QuicSession(connection, config), 330 : QuicSession(connection, config), crypto_stream_(nullptr) {
331 crypto_stream_(NULL) {
332 InitializeSession(); 331 InitializeSession();
333 } 332 }
334 333
335 TestSession::~TestSession() {} 334 TestSession::~TestSession() {}
336 335
337 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { 336 void TestSession::SetCryptoStream(QuicCryptoStream* stream) {
338 crypto_stream_ = stream; 337 crypto_stream_ = stream;
339 } 338 }
340 339
341 QuicCryptoStream* TestSession::GetCryptoStream() { 340 QuicCryptoStream* TestSession::GetCryptoStream() {
342 return crypto_stream_; 341 return crypto_stream_;
343 } 342 }
344 343
345 TestClientSession::TestClientSession(QuicConnection* connection, 344 TestClientSession::TestClientSession(QuicConnection* connection,
346 const QuicConfig& config) 345 const QuicConfig& config)
347 : QuicClientSessionBase(connection, config), 346 : QuicClientSessionBase(connection, config),
348 crypto_stream_(NULL) { 347 crypto_stream_(nullptr) {
349 EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber()); 348 EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber());
350 InitializeSession(); 349 InitializeSession();
351 } 350 }
352 351
353 TestClientSession::~TestClientSession() {} 352 TestClientSession::~TestClientSession() {}
354 353
355 void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) { 354 void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) {
356 crypto_stream_ = stream; 355 crypto_stream_ = stream;
357 } 356 }
358 357
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 header.fec_flag = false; 474 header.fec_flag = false;
476 header.is_in_fec_group = NOT_IN_FEC_GROUP; 475 header.is_in_fec_group = NOT_IN_FEC_GROUP;
477 header.fec_group = 0; 476 header.fec_group = 0;
478 QuicStreamFrame stream_frame(1, false, 0, MakeIOVector(data)); 477 QuicStreamFrame stream_frame(1, false, 0, MakeIOVector(data));
479 QuicFrame frame(&stream_frame); 478 QuicFrame frame(&stream_frame);
480 QuicFrames frames; 479 QuicFrames frames;
481 frames.push_back(frame); 480 frames.push_back(frame);
482 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), false); 481 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), false);
483 scoped_ptr<QuicPacket> packet( 482 scoped_ptr<QuicPacket> packet(
484 BuildUnsizedDataPacket(&framer, header, frames).packet); 483 BuildUnsizedDataPacket(&framer, header, frames).packet);
485 EXPECT_TRUE(packet != NULL); 484 EXPECT_TRUE(packet != nullptr);
486 QuicEncryptedPacket* encrypted = framer.EncryptPacket(ENCRYPTION_NONE, 485 QuicEncryptedPacket* encrypted = framer.EncryptPacket(ENCRYPTION_NONE,
487 sequence_number, 486 sequence_number,
488 *packet); 487 *packet);
489 EXPECT_TRUE(encrypted != NULL); 488 EXPECT_TRUE(encrypted != nullptr);
490 return encrypted; 489 return encrypted;
491 } 490 }
492 491
493 void CompareCharArraysWithHexError( 492 void CompareCharArraysWithHexError(
494 const string& description, 493 const string& description,
495 const char* actual, 494 const char* actual,
496 const int actual_len, 495 const int actual_len,
497 const char* expected, 496 const char* expected,
498 const int expected_len) { 497 const int expected_len) {
499 EXPECT_EQ(actual_len, expected_len); 498 EXPECT_EQ(actual_len, expected_len);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 kInitialSessionFlowControlWindowForTest); 618 kInitialSessionFlowControlWindowForTest);
620 return config; 619 return config;
621 } 620 }
622 621
623 QuicVersionVector SupportedVersions(QuicVersion version) { 622 QuicVersionVector SupportedVersions(QuicVersion version) {
624 QuicVersionVector versions; 623 QuicVersionVector versions;
625 versions.push_back(version); 624 versions.push_back(version);
626 return versions; 625 return versions;
627 } 626 }
628 627
629 TestWriterFactory::TestWriterFactory() : current_writer_(NULL) {} 628 TestWriterFactory::TestWriterFactory() : current_writer_(nullptr) {}
630 TestWriterFactory::~TestWriterFactory() {} 629 TestWriterFactory::~TestWriterFactory() {}
631 630
632 QuicPacketWriter* TestWriterFactory::Create(QuicServerPacketWriter* writer, 631 QuicPacketWriter* TestWriterFactory::Create(QuicServerPacketWriter* writer,
633 QuicConnection* connection) { 632 QuicConnection* connection) {
634 return new PerConnectionPacketWriter(this, writer, connection); 633 return new PerConnectionPacketWriter(this, writer, connection);
635 } 634 }
636 635
637 void TestWriterFactory::OnPacketSent(WriteResult result) { 636 void TestWriterFactory::OnPacketSent(WriteResult result) {
638 if (current_writer_ != NULL && result.status == WRITE_STATUS_ERROR) { 637 if (current_writer_ != nullptr && result.status == WRITE_STATUS_ERROR) {
639 current_writer_->connection()->OnWriteError(result.error_code); 638 current_writer_->connection()->OnWriteError(result.error_code);
640 current_writer_ = NULL; 639 current_writer_ = nullptr;
641 } 640 }
642 } 641 }
643 642
644 void TestWriterFactory::Unregister(PerConnectionPacketWriter* writer) { 643 void TestWriterFactory::Unregister(PerConnectionPacketWriter* writer) {
645 if (current_writer_ == writer) { 644 if (current_writer_ == writer) {
646 current_writer_ = NULL; 645 current_writer_ = nullptr;
647 } 646 }
648 } 647 }
649 648
650 TestWriterFactory::PerConnectionPacketWriter::PerConnectionPacketWriter( 649 TestWriterFactory::PerConnectionPacketWriter::PerConnectionPacketWriter(
651 TestWriterFactory* factory, 650 TestWriterFactory* factory,
652 QuicServerPacketWriter* writer, 651 QuicServerPacketWriter* writer,
653 QuicConnection* connection) 652 QuicConnection* connection)
654 : QuicPerConnectionPacketWriter(writer, connection), 653 : QuicPerConnectionPacketWriter(writer, connection),
655 factory_(factory) { 654 factory_(factory) {
656 } 655 }
657 656
658 TestWriterFactory::PerConnectionPacketWriter::~PerConnectionPacketWriter() { 657 TestWriterFactory::PerConnectionPacketWriter::~PerConnectionPacketWriter() {
659 factory_->Unregister(this); 658 factory_->Unregister(this);
660 } 659 }
661 660
662 WriteResult TestWriterFactory::PerConnectionPacketWriter::WritePacket( 661 WriteResult TestWriterFactory::PerConnectionPacketWriter::WritePacket(
663 const char* buffer, 662 const char* buffer,
664 size_t buf_len, 663 size_t buf_len,
665 const IPAddressNumber& self_address, 664 const IPAddressNumber& self_address,
666 const IPEndPoint& peer_address) { 665 const IPEndPoint& peer_address) {
667 // A DCHECK(factory_current_writer_ == NULL) would be wrong here -- this class 666 // A DCHECK(factory_current_writer_ == nullptr) would be wrong here -- this
668 // may be used in a setting where connection()->OnPacketSent() is called in a 667 // class may be used in a setting where connection()->OnPacketSent() is called
669 // different way, so TestWriterFactory::OnPacketSent might never be called. 668 // in a different way, so TestWriterFactory::OnPacketSent might never be
669 // called.
670 factory_->current_writer_ = this; 670 factory_->current_writer_ = this;
671 return QuicPerConnectionPacketWriter::WritePacket(buffer, 671 return QuicPerConnectionPacketWriter::WritePacket(buffer,
672 buf_len, 672 buf_len,
673 self_address, 673 self_address,
674 peer_address); 674 peer_address);
675 } 675 }
676 676
677 } // namespace test 677 } // namespace test
678 } // namespace net 678 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698