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

Side by Side Diff: net/tools/quic/end_to_end_test.cc

Issue 1901723002: Cleanup: Remove references to and unneeded includes of "base/scoped_ptr.h". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119917706
Patch Set: Created 4 years, 8 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_client_promised_info_test.cc ('k') | net/tools/quic/quic_client.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 <stddef.h> 5 #include <stddef.h>
6 #include <sys/epoll.h> 6 #include <sys/epoll.h>
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
14 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
15 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
17 #include "base/time/time.h" 16 #include "base/time/time.h"
18 #include "net/base/ip_address.h" 17 #include "net/base/ip_address.h"
19 #include "net/base/ip_endpoint.h" 18 #include "net/base/ip_endpoint.h"
20 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
21 #include "net/quic/crypto/null_encrypter.h" 20 #include "net/quic/crypto/null_encrypter.h"
22 #include "net/quic/quic_client_session_base.h" 21 #include "net/quic/quic_client_session_base.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 } 499 }
501 500
502 // Must be called before Initialize to have effect. 501 // Must be called before Initialize to have effect.
503 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) { 502 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) {
504 stream_factory_ = factory; 503 stream_factory_ = factory;
505 } 504 }
506 505
507 bool initialized_; 506 bool initialized_;
508 IPEndPoint server_address_; 507 IPEndPoint server_address_;
509 string server_hostname_; 508 string server_hostname_;
510 scoped_ptr<ServerThread> server_thread_; 509 std::unique_ptr<ServerThread> server_thread_;
511 scoped_ptr<QuicTestClient> client_; 510 std::unique_ptr<QuicTestClient> client_;
512 PacketDroppingTestWriter* client_writer_; 511 PacketDroppingTestWriter* client_writer_;
513 PacketDroppingTestWriter* server_writer_; 512 PacketDroppingTestWriter* server_writer_;
514 bool server_started_; 513 bool server_started_;
515 QuicConfig client_config_; 514 QuicConfig client_config_;
516 QuicConfig server_config_; 515 QuicConfig server_config_;
517 QuicVersionVector client_supported_versions_; 516 QuicVersionVector client_supported_versions_;
518 QuicVersionVector server_supported_versions_; 517 QuicVersionVector server_supported_versions_;
519 QuicVersion negotiated_version_; 518 QuicVersion negotiated_version_;
520 bool strike_register_no_startup_period_; 519 bool strike_register_no_startup_period_;
521 size_t chlo_multiplier_; 520 size_t chlo_multiplier_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 ASSERT_TRUE(Initialize()); 580 ASSERT_TRUE(Initialize());
582 581
583 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 582 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
584 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 583 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
585 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); 584 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar"));
586 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 585 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
587 } 586 }
588 587
589 TEST_P(EndToEndTest, MultipleClients) { 588 TEST_P(EndToEndTest, MultipleClients) {
590 ASSERT_TRUE(Initialize()); 589 ASSERT_TRUE(Initialize());
591 scoped_ptr<QuicTestClient> client2(CreateQuicClient(nullptr)); 590 std::unique_ptr<QuicTestClient> client2(CreateQuicClient(nullptr));
592 591
593 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); 592 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
594 request.AddHeader("content-length", "3"); 593 request.AddHeader("content-length", "3");
595 request.set_has_complete_message(false); 594 request.set_has_complete_message(false);
596 595
597 client_->SendMessage(request); 596 client_->SendMessage(request);
598 client2->SendMessage(request); 597 client2->SendMessage(request);
599 598
600 client_->SendData("bar", true); 599 client_->SendData("bar", true);
601 client_->WaitForResponse(); 600 client_->WaitForResponse();
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 // Send the public reset. 1730 // Send the public reset.
1732 QuicConnectionId incorrect_connection_id = 1731 QuicConnectionId incorrect_connection_id =
1733 client_->client()->session()->connection()->connection_id() + 1; 1732 client_->client()->session()->connection()->connection_id() + 1;
1734 QuicPublicResetPacket header; 1733 QuicPublicResetPacket header;
1735 header.public_header.connection_id = incorrect_connection_id; 1734 header.public_header.connection_id = incorrect_connection_id;
1736 header.public_header.reset_flag = true; 1735 header.public_header.reset_flag = true;
1737 header.public_header.version_flag = false; 1736 header.public_header.version_flag = false;
1738 header.rejected_packet_number = 10101; 1737 header.rejected_packet_number = 10101;
1739 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 1738 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
1740 Perspective::IS_SERVER); 1739 Perspective::IS_SERVER);
1741 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); 1740 std::unique_ptr<QuicEncryptedPacket> packet(
1741 framer.BuildPublicResetPacket(header));
1742 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; 1742 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
1743 client_->client()->session()->connection()->set_debug_visitor(&visitor); 1743 client_->client()->session()->connection()->set_debug_visitor(&visitor);
1744 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) 1744 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
1745 .Times(1); 1745 .Times(1);
1746 // We must pause the server's thread in order to call WritePacket without 1746 // We must pause the server's thread in order to call WritePacket without
1747 // race conditions. 1747 // race conditions.
1748 server_thread_->Pause(); 1748 server_thread_->Pause();
1749 server_writer_->WritePacket( 1749 server_writer_->WritePacket(
1750 packet->data(), packet->length(), server_address_.address(), 1750 packet->data(), packet->length(), server_address_.address(),
1751 client_->client()->GetLatestClientAddress(), nullptr); 1751 client_->client()->GetLatestClientAddress(), nullptr);
(...skipping 14 matching lines...) Expand all
1766 // Send the public reset. 1766 // Send the public reset.
1767 QuicConnectionId incorrect_connection_id = 1767 QuicConnectionId incorrect_connection_id =
1768 client_->client()->session()->connection()->connection_id() + 1; 1768 client_->client()->session()->connection()->connection_id() + 1;
1769 QuicPublicResetPacket header; 1769 QuicPublicResetPacket header;
1770 header.public_header.connection_id = incorrect_connection_id; 1770 header.public_header.connection_id = incorrect_connection_id;
1771 header.public_header.reset_flag = true; 1771 header.public_header.reset_flag = true;
1772 header.public_header.version_flag = false; 1772 header.public_header.version_flag = false;
1773 header.rejected_packet_number = 10101; 1773 header.rejected_packet_number = 10101;
1774 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 1774 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
1775 Perspective::IS_CLIENT); 1775 Perspective::IS_CLIENT);
1776 scoped_ptr<QuicEncryptedPacket> packet(framer.BuildPublicResetPacket(header)); 1776 std::unique_ptr<QuicEncryptedPacket> packet(
1777 framer.BuildPublicResetPacket(header));
1777 client_writer_->WritePacket( 1778 client_writer_->WritePacket(
1778 packet->data(), packet->length(), 1779 packet->data(), packet->length(),
1779 client_->client()->GetLatestClientAddress().address(), server_address_, 1780 client_->client()->GetLatestClientAddress().address(), server_address_,
1780 nullptr); 1781 nullptr);
1781 1782
1782 // The connection should be unaffected. 1783 // The connection should be unaffected.
1783 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1784 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1784 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1785 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1785 } 1786 }
1786 1787
1787 // Send a version negotiation packet from the server for a different 1788 // Send a version negotiation packet from the server for a different
1788 // connection ID. It should be ignored. 1789 // connection ID. It should be ignored.
1789 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { 1790 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) {
1790 ASSERT_TRUE(Initialize()); 1791 ASSERT_TRUE(Initialize());
1791 1792
1792 // Send the version negotiation packet. 1793 // Send the version negotiation packet.
1793 QuicConnectionId incorrect_connection_id = 1794 QuicConnectionId incorrect_connection_id =
1794 client_->client()->session()->connection()->connection_id() + 1; 1795 client_->client()->session()->connection()->connection_id() + 1;
1795 scoped_ptr<QuicEncryptedPacket> packet( 1796 std::unique_ptr<QuicEncryptedPacket> packet(
1796 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, 1797 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id,
1797 server_supported_versions_)); 1798 server_supported_versions_));
1798 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; 1799 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
1799 client_->client()->session()->connection()->set_debug_visitor(&visitor); 1800 client_->client()->session()->connection()->set_debug_visitor(&visitor);
1800 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) 1801 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
1801 .Times(1); 1802 .Times(1);
1802 // We must pause the server's thread in order to call WritePacket without 1803 // We must pause the server's thread in order to call WritePacket without
1803 // race conditions. 1804 // race conditions.
1804 server_thread_->Pause(); 1805 server_thread_->Pause();
1805 server_writer_->WritePacket( 1806 server_writer_->WritePacket(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 1889
1889 // Send a packet from the client with bad encrypted data. The server should not 1890 // Send a packet from the client with bad encrypted data. The server should not
1890 // tear down the connection. 1891 // tear down the connection.
1891 TEST_P(EndToEndTest, BadEncryptedData) { 1892 TEST_P(EndToEndTest, BadEncryptedData) {
1892 ASSERT_TRUE(Initialize()); 1893 ASSERT_TRUE(Initialize());
1893 1894
1894 // Start the connection. 1895 // Start the connection.
1895 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1896 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1896 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1897 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1897 1898
1898 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( 1899 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
1899 client_->client()->session()->connection()->connection_id(), false, false, 1900 client_->client()->session()->connection()->connection_id(), false, false,
1900 false, kDefaultPathId, 1, "At least 20 characters.", 1901 false, kDefaultPathId, 1, "At least 20 characters.",
1901 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER)); 1902 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER));
1902 // Damage the encrypted data. 1903 // Damage the encrypted data.
1903 string damaged_packet(packet->data(), packet->length()); 1904 string damaged_packet(packet->data(), packet->length());
1904 damaged_packet[30] ^= 0x01; 1905 damaged_packet[30] ^= 0x01;
1905 DVLOG(1) << "Sending bad packet."; 1906 DVLOG(1) << "Sending bad packet.";
1906 client_writer_->WritePacket( 1907 client_writer_->WritePacket(
1907 damaged_packet.data(), damaged_packet.length(), 1908 damaged_packet.data(), damaged_packet.length(),
1908 client_->client()->GetLatestClientAddress().address(), server_address_, 1909 client_->client()->GetLatestClientAddress().address(), server_address_,
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 client_->client()->WaitForCryptoHandshakeConfirmed(); 2609 client_->client()->WaitForCryptoHandshakeConfirmed();
2609 SetPacketLossPercentage(1); 2610 SetPacketLossPercentage(1);
2610 client_->SendRequest("/huge_response"); 2611 client_->SendRequest("/huge_response");
2611 client_->WaitForResponse(); 2612 client_->WaitForResponse();
2612 VerifyCleanConnection(false); 2613 VerifyCleanConnection(false);
2613 } 2614 }
2614 2615
2615 } // namespace 2616 } // namespace
2616 } // namespace test 2617 } // namespace test
2617 } // namespace net 2618 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_client_promised_info_test.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698