OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", | 105 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", |
106 "/index.html"); | 106 "/index.html"); |
107 ASSERT_TRUE(response); | 107 ASSERT_TRUE(response); |
108 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 108 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |
109 EXPECT_EQ("200", response->headers().find(":status")->second); | 109 EXPECT_EQ("200", response->headers().find(":status")->second); |
110 ASSERT_TRUE(ContainsKey(response->headers(), "connection")); | 110 ASSERT_TRUE(ContainsKey(response->headers(), "connection")); |
111 EXPECT_EQ("close", response->headers().find("connection")->second); | 111 EXPECT_EQ("close", response->headers().find("connection")->second); |
112 EXPECT_LT(0U, response->body().length()); | 112 EXPECT_LT(0U, response->body().length()); |
113 } | 113 } |
114 | 114 |
| 115 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResource) { |
| 116 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + |
| 117 "_with_push"); |
| 118 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |
| 119 std::list<ServerPushInfo> resources = |
| 120 cache->GetServerPushResources("quic.test.url/"); |
| 121 ASSERT_EQ(1UL, resources.size()); |
| 122 } |
| 123 |
| 124 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResources) { |
| 125 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + |
| 126 "_with_push"); |
| 127 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |
| 128 std::list<ServerPushInfo> resources = |
| 129 cache->GetServerPushResources("quic.test.url/index2.html"); |
| 130 ASSERT_EQ(2UL, resources.size()); |
| 131 } |
| 132 |
115 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) { | 133 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) { |
116 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); | 134 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); |
117 const QuicInMemoryCache::Response* response = | 135 const QuicInMemoryCache::Response* response = |
118 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", | 136 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", |
119 "/index.html"); | 137 "/index.html"); |
120 ASSERT_TRUE(response); | 138 ASSERT_TRUE(response); |
121 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 139 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |
122 EXPECT_EQ("200", response->headers().find(":status")->second); | 140 EXPECT_EQ("200", response->headers().find(":status")->second); |
123 ASSERT_TRUE(ContainsKey(response->headers(), "connection")); | 141 ASSERT_TRUE(ContainsKey(response->headers(), "connection")); |
124 EXPECT_EQ("close", response->headers().find("connection")->second); | 142 EXPECT_EQ("close", response->headers().find("connection")->second); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); | 253 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); |
236 EXPECT_EQ(push_response_status[i++], | 254 EXPECT_EQ(push_response_status[i++], |
237 response->headers().find(":status")->second); | 255 response->headers().find(":status")->second); |
238 EXPECT_EQ(push_resource.body, response->body()); | 256 EXPECT_EQ(push_resource.body, response->body()); |
239 resources.pop_front(); | 257 resources.pop_front(); |
240 } | 258 } |
241 } | 259 } |
242 | 260 |
243 } // namespace test | 261 } // namespace test |
244 } // namespace net | 262 } // namespace net |
OLD | NEW |