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

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

Issue 2933613002: Add quic_test_loopback used for tests only. (Closed)
Patch Set: Created 3 years, 6 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/platform/impl/quic_test_loopback_impl.cc ('k') | net/tools/quic/quic_client_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 <stddef.h> 5 #include <stddef.h>
6 #include <sys/epoll.h> 6 #include <sys/epoll.h>
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 17 matching lines...) Expand all
28 #include "net/quic/core/quic_server_id.h" 28 #include "net/quic/core/quic_server_id.h"
29 #include "net/quic/core/quic_session.h" 29 #include "net/quic/core/quic_session.h"
30 #include "net/quic/core/quic_utils.h" 30 #include "net/quic/core/quic_utils.h"
31 #include "net/quic/platform/api/quic_flags.h" 31 #include "net/quic/platform/api/quic_flags.h"
32 #include "net/quic/platform/api/quic_logging.h" 32 #include "net/quic/platform/api/quic_logging.h"
33 #include "net/quic/platform/api/quic_ptr_util.h" 33 #include "net/quic/platform/api/quic_ptr_util.h"
34 #include "net/quic/platform/api/quic_socket_address.h" 34 #include "net/quic/platform/api/quic_socket_address.h"
35 #include "net/quic/platform/api/quic_str_cat.h" 35 #include "net/quic/platform/api/quic_str_cat.h"
36 #include "net/quic/platform/api/quic_string_piece.h" 36 #include "net/quic/platform/api/quic_string_piece.h"
37 #include "net/quic/platform/api/quic_test.h" 37 #include "net/quic/platform/api/quic_test.h"
38 #include "net/quic/platform/api/quic_test_loopback.h"
38 #include "net/quic/platform/api/quic_text_utils.h" 39 #include "net/quic/platform/api/quic_text_utils.h"
39 #include "net/quic/test_tools/crypto_test_utils.h" 40 #include "net/quic/test_tools/crypto_test_utils.h"
40 #include "net/quic/test_tools/quic_config_peer.h" 41 #include "net/quic/test_tools/quic_config_peer.h"
41 #include "net/quic/test_tools/quic_connection_peer.h" 42 #include "net/quic/test_tools/quic_connection_peer.h"
42 #include "net/quic/test_tools/quic_flow_controller_peer.h" 43 #include "net/quic/test_tools/quic_flow_controller_peer.h"
43 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 44 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
44 #include "net/quic/test_tools/quic_session_peer.h" 45 #include "net/quic/test_tools/quic_session_peer.h"
45 #include "net/quic/test_tools/quic_spdy_session_peer.h" 46 #include "net/quic/test_tools/quic_spdy_session_peer.h"
46 #include "net/quic/test_tools/quic_stream_peer.h" 47 #include "net/quic/test_tools/quic_stream_peer.h"
47 #include "net/quic/test_tools/quic_stream_sequencer_peer.h" 48 #include "net/quic/test_tools/quic_stream_sequencer_peer.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 293 }
293 294
294 private: 295 private:
295 QuicClient* client_; 296 QuicClient* client_;
296 }; 297 };
297 298
298 class EndToEndTest : public QuicTestWithParam<TestParams> { 299 class EndToEndTest : public QuicTestWithParam<TestParams> {
299 protected: 300 protected:
300 EndToEndTest() 301 EndToEndTest()
301 : initialized_(false), 302 : initialized_(false),
302 server_address_(QuicSocketAddress(QuicIpAddress::Loopback4(), 0)), 303 server_address_(QuicSocketAddress(TestLoopback(), 0)),
303 server_hostname_("test.example.com"), 304 server_hostname_("test.example.com"),
304 client_writer_(nullptr), 305 client_writer_(nullptr),
305 server_writer_(nullptr), 306 server_writer_(nullptr),
306 server_started_(false), 307 server_started_(false),
307 chlo_multiplier_(0), 308 chlo_multiplier_(0),
308 stream_factory_(nullptr), 309 stream_factory_(nullptr),
309 support_server_push_(false) { 310 support_server_push_(false) {
310 client_supported_versions_ = GetParam().client_supported_versions; 311 client_supported_versions_ = GetParam().client_supported_versions;
311 server_supported_versions_ = GetParam().server_supported_versions; 312 server_supported_versions_ = GetParam().server_supported_versions;
312 negotiated_version_ = GetParam().negotiated_version; 313 negotiated_version_ = GetParam().negotiated_version;
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 peer_address, options); 1594 peer_address, options);
1594 } 1595 }
1595 1596
1596 bool IsWriteBlockedDataBuffered() const override { return false; } 1597 bool IsWriteBlockedDataBuffered() const override { return false; }
1597 1598
1598 QuicIpAddress self_address_; 1599 QuicIpAddress self_address_;
1599 }; 1600 };
1600 1601
1601 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { 1602 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) {
1602 ASSERT_TRUE(Initialize()); 1603 ASSERT_TRUE(Initialize());
1603
1604 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1604 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1605 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 1605 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
1606 1606
1607 // Store the client IP address which was used to send the first request. 1607 // Store the client IP address which was used to send the first request.
1608 QuicIpAddress old_host = client_->client()->GetLatestClientAddress().host(); 1608 QuicIpAddress old_host = client_->client()->GetLatestClientAddress().host();
1609 1609
1610 // Migrate socket to the new IP address. 1610 // Migrate socket to the new IP address.
1611 QuicIpAddress new_host; 1611 QuicIpAddress new_host = TestLoopback(2);
1612 new_host.FromString("127.0.0.2");
1613 EXPECT_NE(old_host, new_host); 1612 EXPECT_NE(old_host, new_host);
1614 ASSERT_TRUE(client_->client()->MigrateSocket(new_host)); 1613 ASSERT_TRUE(client_->client()->MigrateSocket(new_host));
1615 1614
1616 // Send a request using the new socket. 1615 // Send a request using the new socket.
1617 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); 1616 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar"));
1618 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 1617 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
1619 } 1618 }
1620 1619
1621 TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { 1620 TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) {
1622 // Tests that the client's port can change during an established QUIC 1621 // Tests that the client's port can change during an established QUIC
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 client_->WaitForResponse(); 3114 client_->WaitForResponse();
3116 EXPECT_EQ(kBarResponseBody, client_->response_body()); 3115 EXPECT_EQ(kBarResponseBody, client_->response_body());
3117 QuicConnectionStats client_stats = 3116 QuicConnectionStats client_stats =
3118 client_->client()->session()->connection()->GetStats(); 3117 client_->client()->session()->connection()->GetStats();
3119 EXPECT_EQ(0u, client_stats.packets_lost); 3118 EXPECT_EQ(0u, client_stats.packets_lost);
3120 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 3119 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
3121 } 3120 }
3122 } // namespace 3121 } // namespace
3123 } // namespace test 3122 } // namespace test
3124 } // namespace net 3123 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/platform/impl/quic_test_loopback_impl.cc ('k') | net/tools/quic/quic_client_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698