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

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

Issue 24596008: Cleanup of QuicInMemoryCache to sync with internal version. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup Created 7 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 | Annotate | Revision Log
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 <string> 6 #include <string>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "net/base/ip_endpoint.h" 12 #include "net/base/ip_endpoint.h"
13 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 13 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
14 #include "net/quic/crypto/null_encrypter.h" 14 #include "net/quic/crypto/null_encrypter.h"
15 #include "net/quic/quic_framer.h" 15 #include "net/quic/quic_framer.h"
16 #include "net/quic/quic_packet_creator.h" 16 #include "net/quic/quic_packet_creator.h"
17 #include "net/quic/quic_protocol.h" 17 #include "net/quic/quic_protocol.h"
18 #include "net/quic/test_tools/quic_connection_peer.h" 18 #include "net/quic/test_tools/quic_connection_peer.h"
19 #include "net/quic/test_tools/quic_session_peer.h" 19 #include "net/quic/test_tools/quic_session_peer.h"
20 #include "net/quic/test_tools/reliable_quic_stream_peer.h" 20 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
21 #include "net/tools/quic/quic_epoll_connection_helper.h" 21 #include "net/tools/quic/quic_epoll_connection_helper.h"
22 #include "net/tools/quic/quic_in_memory_cache.h" 22 #include "net/tools/quic/quic_in_memory_cache.h"
23 #include "net/tools/quic/quic_server.h" 23 #include "net/tools/quic/quic_server.h"
24 #include "net/tools/quic/quic_socket_utils.h" 24 #include "net/tools/quic/quic_socket_utils.h"
25 #include "net/tools/quic/test_tools/http_message_test_utils.h" 25 #include "net/tools/quic/test_tools/http_message_test_utils.h"
26 #include "net/tools/quic/test_tools/quic_client_peer.h" 26 #include "net/tools/quic/test_tools/quic_client_peer.h"
27 #include "net/tools/quic/test_tools/quic_epoll_connection_helper_peer.h" 27 #include "net/tools/quic/test_tools/quic_epoll_connection_helper_peer.h"
28 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
28 #include "net/tools/quic/test_tools/quic_test_client.h" 29 #include "net/tools/quic/test_tools/quic_test_client.h"
29 #include "net/tools/quic/test_tools/server_thread.h" 30 #include "net/tools/quic/test_tools/server_thread.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 using base::StringPiece; 33 using base::StringPiece;
33 using base::WaitableEvent; 34 using base::WaitableEvent;
34 using net::test::QuicConnectionPeer; 35 using net::test::QuicConnectionPeer;
35 using net::test::QuicSessionPeer; 36 using net::test::QuicSessionPeer;
36 using net::test::ReliableQuicStreamPeer; 37 using net::test::ReliableQuicStreamPeer;
37 using std::string; 38 using std::string;
(...skipping 15 matching lines...) Expand all
53 body->clear(); 54 body->clear();
54 body->reserve(length); 55 body->reserve(length);
55 for (int i = 0; i < length; ++i) { 56 for (int i = 0; i < length; ++i) {
56 body->append(1, static_cast<char>(32 + i % (126 - 32))); 57 body->append(1, static_cast<char>(32 + i % (126 - 32)));
57 } 58 }
58 } 59 }
59 60
60 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> { 61 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> {
61 public: 62 public:
62 static void SetUpTestCase() { 63 static void SetUpTestCase() {
63 QuicInMemoryCache::GetInstance()->ResetForTests(); 64 QuicInMemoryCachePeer::ResetForTests();
64 } 65 }
65 66
66 protected: 67 protected:
67 EndToEndTest() 68 EndToEndTest()
68 : server_hostname_("example.com"), 69 : server_hostname_("example.com"),
69 server_started_(false), 70 server_started_(false),
70 strike_register_no_startup_period_(false) { 71 strike_register_no_startup_period_(false) {
71 net::IPAddressNumber ip; 72 net::IPAddressNumber ip;
72 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); 73 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip));
73 server_address_ = IPEndPoint(ip, 0); 74 server_address_ = IPEndPoint(ip, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 server_thread_->Join(); 125 server_thread_->Join();
125 } 126 }
126 } 127 }
127 128
128 void AddToCache(StringPiece method, 129 void AddToCache(StringPiece method,
129 StringPiece path, 130 StringPiece path,
130 StringPiece version, 131 StringPiece version,
131 StringPiece response_code, 132 StringPiece response_code,
132 StringPiece response_detail, 133 StringPiece response_detail,
133 StringPiece body) { 134 StringPiece body) {
134 QuicInMemoryCache::GetInstance()->AddOrVerifyResponse( 135 QuicInMemoryCache::GetInstance()->AddSimpleResponse(
135 method, path, version, response_code, response_detail, body); 136 method, path, version, response_code, response_detail, body);
136 } 137 }
137 138
138 IPEndPoint server_address_; 139 IPEndPoint server_address_;
139 string server_hostname_; 140 string server_hostname_;
140 scoped_ptr<ServerThread> server_thread_; 141 scoped_ptr<ServerThread> server_thread_;
141 scoped_ptr<QuicTestClient> client_; 142 scoped_ptr<QuicTestClient> client_;
142 bool server_started_; 143 bool server_started_;
143 QuicConfig client_config_; 144 QuicConfig client_config_;
144 QuicConfig server_config_; 145 QuicConfig server_config_;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); 659 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL);
659 660
660 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 661 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
661 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); 662 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error());
662 } 663 }
663 664
664 } // namespace 665 } // namespace
665 } // namespace test 666 } // namespace test
666 } // namespace tools 667 } // namespace tools
667 } // namespace net 668 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698