OLD | NEW |
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 "net/url_request/view_cache_helper.h" | 5 #include "net/url_request/view_cache_helper.h" |
6 | 6 |
7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
10 #include "net/disk_cache/disk_cache.h" | 10 #include "net/disk_cache/disk_cache.h" |
11 #include "net/http/http_cache.h" | 11 #include "net/http/http_cache.h" |
| 12 #include "net/http/http_transaction_test_util.h" |
12 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 class TestURLRequestContext : public URLRequestContext { | 20 class TestURLRequestContext : public URLRequestContext { |
20 public: | 21 public: |
21 TestURLRequestContext(); | 22 TestURLRequestContext(); |
22 virtual ~TestURLRequestContext() {} | 23 virtual ~TestURLRequestContext() {} |
23 | 24 |
24 // Gets a pointer to the cache backend. | 25 // Gets a pointer to the cache backend. |
25 disk_cache::Backend* GetBackend(); | 26 disk_cache::Backend* GetBackend(); |
26 | 27 |
27 private: | 28 private: |
28 HttpCache cache_; | 29 HttpCache cache_; |
29 }; | 30 }; |
30 | 31 |
31 TestURLRequestContext::TestURLRequestContext() | 32 TestURLRequestContext::TestURLRequestContext() |
32 : cache_(reinterpret_cast<HttpTransactionFactory*>(NULL), NULL, | 33 : cache_(new MockNetworkLayer(), NULL, |
33 HttpCache::DefaultBackend::InMemory(0)) { | 34 HttpCache::DefaultBackend::InMemory(0)) { |
34 set_http_transaction_factory(&cache_); | 35 set_http_transaction_factory(&cache_); |
35 } | 36 } |
36 | 37 |
37 void WriteHeaders(disk_cache::Entry* entry, int flags, | 38 void WriteHeaders(disk_cache::Entry* entry, int flags, |
38 const std::string& data) { | 39 const std::string& data) { |
39 if (data.empty()) | 40 if (data.empty()) |
40 return; | 41 return; |
41 | 42 |
42 Pickle pickle; | 43 Pickle pickle; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 203 |
203 std::string data; | 204 std::string data; |
204 TestCompletionCallback cb1; | 205 TestCompletionCallback cb1; |
205 rv = helper.GetEntryInfoHTML(key, &context, &data, cb1.callback()); | 206 rv = helper.GetEntryInfoHTML(key, &context, &data, cb1.callback()); |
206 EXPECT_EQ(OK, cb1.GetResult(rv)); | 207 EXPECT_EQ(OK, cb1.GetResult(rv)); |
207 | 208 |
208 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); | 209 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); |
209 } | 210 } |
210 | 211 |
211 } // namespace net | 212 } // namespace net |
OLD | NEW |