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

Unified Diff: net/tools/quic/quic_in_memory_cache_test.cc

Issue 999353005: Land Recent QUIC Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wrap Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | net/tools/quic/quic_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_in_memory_cache_test.cc
diff --git a/net/tools/quic/quic_in_memory_cache_test.cc b/net/tools/quic/quic_in_memory_cache_test.cc
index e8e603eff38d93843e528803612e49858052033e..d93a344f64339acec268d7e56d5bbec4d9d66457 100644
--- a/net/tools/quic/quic_in_memory_cache_test.cc
+++ b/net/tools/quic/quic_in_memory_cache_test.cc
@@ -7,6 +7,7 @@
#include "base/files/file_path.h"
#include "base/memory/singleton.h"
#include "base/path_service.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "net/tools/balsa/balsa_headers.h"
@@ -25,27 +26,33 @@ namespace test {
class QuicInMemoryCacheTest : public ::testing::Test {
protected:
QuicInMemoryCacheTest() {
- base::FilePath path;
- PathService::Get(base::DIR_SOURCE_ROOT, &path);
- path = path.AppendASCII("net").AppendASCII("data")
- .AppendASCII("quic_in_memory_cache_data");
- // The file path is known to be an ascii string.
- FLAGS_quic_in_memory_cache_dir = path.MaybeAsASCII();
+ QuicInMemoryCachePeer::ResetForTests();
}
~QuicInMemoryCacheTest() override { QuicInMemoryCachePeer::ResetForTests(); }
- void CreateRequest(StringPiece host,
- StringPiece path,
- BalsaHeaders* headers) {
+ void CreateRequest(string host, string path, BalsaHeaders* headers) {
headers->SetRequestFirstlineFromStringPieces("GET", path, "HTTP/1.1");
headers->ReplaceOrAppendHeader("host", host);
}
- void SetUp() override { QuicInMemoryCachePeer::ResetForTests(); }
-
+ string CacheDirectory() {
+ base::FilePath path;
+ PathService::Get(base::DIR_SOURCE_ROOT, &path);
+ path = path.AppendASCII("net").AppendASCII("data")
+ .AppendASCII("quic_in_memory_cache_data");
+ // The file path is known to be an ascii string.
+ return path.MaybeAsASCII();
+ }
};
+TEST_F(QuicInMemoryCacheTest, GetResponseNoMatch) {
+ const QuicInMemoryCache::Response* response =
+ QuicInMemoryCache::GetInstance()->GetResponse("mail.google.com",
+ "/index.html");
+ ASSERT_FALSE(response);
+}
+
TEST_F(QuicInMemoryCacheTest, AddSimpleResponseGetResponse) {
string response_body("hello response");
QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
@@ -56,40 +63,37 @@ TEST_F(QuicInMemoryCacheTest, AddSimpleResponseGetResponse) {
const QuicInMemoryCache::Response* response =
cache->GetResponse("www.google.com", "/");
ASSERT_TRUE(response);
- EXPECT_EQ("200", response->headers().response_code());
+ ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
+ EXPECT_EQ("200 OK", response->headers().find(":status")->second);
EXPECT_EQ(response_body.size(), response->body().length());
}
TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) {
+ QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory());
const QuicInMemoryCache::Response* response =
QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url",
"/index.html");
ASSERT_TRUE(response);
- string value;
- response->headers().GetAllOfHeaderAsString("Connection", &value);
- EXPECT_EQ("200", response->headers().response_code());
- EXPECT_EQ("Keep-Alive", value);
+ ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
+ EXPECT_EQ("200 OK", response->headers().find(":status")->second);
+ ASSERT_TRUE(ContainsKey(response->headers(), "connection"));
+ EXPECT_EQ("close", response->headers().find("connection")->second);
EXPECT_LT(0U, response->body().length());
}
TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) {
+ QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory());
const QuicInMemoryCache::Response* response =
QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url",
"/index.html");
ASSERT_TRUE(response);
- EXPECT_EQ("200", response->headers().response_code());
- string value;
- response->headers().GetAllOfHeaderAsString("Connection", &value);
+ ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
+ EXPECT_EQ("200 OK", response->headers().find(":status")->second);
+ ASSERT_TRUE(ContainsKey(response->headers(), "connection"));
+ EXPECT_EQ("close", response->headers().find("connection")->second);
EXPECT_LT(0U, response->body().length());
}
-TEST_F(QuicInMemoryCacheTest, GetResponseNoMatch) {
- const QuicInMemoryCache::Response* response =
- QuicInMemoryCache::GetInstance()->GetResponse("mail.google.com",
- "/index.html");
- ASSERT_FALSE(response);
-}
-
} // namespace test
} // namespace tools
} // namespace net
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | net/tools/quic/quic_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698