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

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

Issue 1499673003: Adds response trailers to the QuicInMemoryCache's Responses. Currently unused, this is preparation … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@108726817
Patch Set: 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/tools/quic/quic_in_memory_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 BalsaHeaders request_headers; 69 BalsaHeaders request_headers;
70 CreateRequest("www.google.com", "/", &request_headers); 70 CreateRequest("www.google.com", "/", &request_headers);
71 const QuicInMemoryCache::Response* response = 71 const QuicInMemoryCache::Response* response =
72 cache->GetResponse("www.google.com", "/"); 72 cache->GetResponse("www.google.com", "/");
73 ASSERT_TRUE(response); 73 ASSERT_TRUE(response);
74 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); 74 ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
75 EXPECT_EQ("200", response->headers().find(":status")->second); 75 EXPECT_EQ("200", response->headers().find(":status")->second);
76 EXPECT_EQ(response_body.size(), response->body().length()); 76 EXPECT_EQ(response_body.size(), response->body().length());
77 } 77 }
78 78
79 TEST_F(QuicInMemoryCacheTest, AddResponse) {
80 const string kRequestHost = "www.foo.com";
81 const string kRequestPath = "/";
82 const string kResponseBody("hello response");
83
84 SpdyHeaderBlock response_headers;
85 response_headers[":version"] = "HTTP/1.1";
86 response_headers[":status"] = "200";
87 response_headers["content-length"] = IntToString(kResponseBody.size());
88
89 SpdyHeaderBlock response_trailers;
90 response_trailers["key-1"] = "value-1";
91 response_trailers["key-2"] = "value-2";
92 response_trailers["key-3"] = "value-3";
93
94 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
95 cache->AddResponse(kRequestHost, "/", response_headers, kResponseBody,
96 response_trailers);
97
98 const QuicInMemoryCache::Response* response =
99 cache->GetResponse(kRequestHost, kRequestPath);
100 EXPECT_EQ(response->headers(), response_headers);
101 EXPECT_EQ(response->body(), kResponseBody);
102 EXPECT_EQ(response->trailers(), response_trailers);
103 }
104
79 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) { 105 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) {
80 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); 106 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory());
81 const QuicInMemoryCache::Response* response = 107 const QuicInMemoryCache::Response* response =
82 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", 108 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url",
83 "/index.html"); 109 "/index.html");
84 ASSERT_TRUE(response); 110 ASSERT_TRUE(response);
85 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); 111 ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
86 EXPECT_EQ("200 OK", response->headers().find(":status")->second); 112 EXPECT_EQ("200 OK", response->headers().find(":status")->second);
87 ASSERT_TRUE(ContainsKey(response->headers(), "connection")); 113 ASSERT_TRUE(ContainsKey(response->headers(), "connection"));
88 EXPECT_EQ("close", response->headers().find("connection")->second); 114 EXPECT_EQ("close", response->headers().find("connection")->second);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_EQ(push_response_status[i++], 239 EXPECT_EQ(push_response_status[i++],
214 response->headers().find(":status")->second); 240 response->headers().find(":status")->second);
215 EXPECT_EQ(push_resource.body, response->body()); 241 EXPECT_EQ(push_resource.body, response->body());
216 resources.pop_front(); 242 resources.pop_front();
217 } 243 }
218 } 244 }
219 245
220 } // namespace test 246 } // namespace test
221 } // namespace tools 247 } // namespace tools
222 } // namespace net 248 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698