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

Side by Side Diff: net/url_request/view_cache_helper_unittest.cc

Issue 8832006: Reverts a commit that caused ASAN failures, and 2 dependent commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/view_cache_helper.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/completion_callback.h"
9 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
10 #include "net/base/test_completion_callback.h" 9 #include "net/base/test_completion_callback.h"
11 #include "net/disk_cache/disk_cache.h" 10 #include "net/disk_cache/disk_cache.h"
12 #include "net/http/http_cache.h" 11 #include "net/http/http_cache.h"
13 #include "net/url_request/url_request_context.h" 12 #include "net/url_request/url_request_context.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 14
16 namespace net { 15 namespace net {
17 16
18 namespace { 17 namespace {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 78 }
80 79
81 WriteHeaders(entry, 0, data0); 80 WriteHeaders(entry, 0, data0);
82 WriteData(entry, 1, data1); 81 WriteData(entry, 1, data1);
83 WriteData(entry, 2, data2); 82 WriteData(entry, 2, data2);
84 83
85 entry->Close(); 84 entry->Close();
86 } 85 }
87 86
88 void FillCache(URLRequestContext* context) { 87 void FillCache(URLRequestContext* context) {
89 TestCompletionCallback cb; 88 TestOldCompletionCallback cb;
90 disk_cache::Backend* cache; 89 disk_cache::Backend* cache;
91 int rv = context->http_transaction_factory()->GetCache()->GetBackend( 90 int rv =
92 &cache, cb.callback()); 91 context->http_transaction_factory()->GetCache()->GetBackend(&cache, &cb);
93 ASSERT_EQ(OK, cb.GetResult(rv)); 92 ASSERT_EQ(OK, cb.GetResult(rv));
94 93
95 std::string empty; 94 std::string empty;
96 WriteToEntry(cache, "first", "some", empty, empty); 95 WriteToEntry(cache, "first", "some", empty, empty);
97 WriteToEntry(cache, "second", "only hex_dumped", "same", "kind"); 96 WriteToEntry(cache, "second", "only hex_dumped", "same", "kind");
98 WriteToEntry(cache, "third", empty, "another", "thing"); 97 WriteToEntry(cache, "third", empty, "another", "thing");
99 } 98 }
100 99
101 } // namespace. 100 } // namespace.
102 101
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_NE(std::string::npos, data.find("</html>")); 173 EXPECT_NE(std::string::npos, data.find("</html>"));
175 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:first\">")); 174 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:first\">"));
176 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:second\">")); 175 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:second\">"));
177 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:third\">")); 176 EXPECT_NE(std::string::npos, data.find("<a href=\"prefix:third\">"));
178 } 177 }
179 178
180 TEST(ViewCacheHelper, TruncatedFlag) { 179 TEST(ViewCacheHelper, TruncatedFlag) {
181 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext()); 180 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
182 ViewCacheHelper helper; 181 ViewCacheHelper helper;
183 182
184 TestCompletionCallback cb; 183 TestOldCompletionCallback cb;
185 disk_cache::Backend* cache; 184 disk_cache::Backend* cache;
186 int rv = context->http_transaction_factory()->GetCache()->GetBackend( 185 int rv =
187 &cache, cb.callback()); 186 context->http_transaction_factory()->GetCache()->GetBackend(&cache, &cb);
188 ASSERT_EQ(OK, cb.GetResult(rv)); 187 ASSERT_EQ(OK, cb.GetResult(rv));
189 188
190 std::string key("the key"); 189 std::string key("the key");
191 disk_cache::Entry* entry; 190 disk_cache::Entry* entry;
192 TestOldCompletionCallback cb2; 191 rv = cache->CreateEntry(key, &entry, &cb);
193 rv = cache->CreateEntry(key, &entry, &cb2);
194 ASSERT_EQ(OK, cb.GetResult(rv)); 192 ASSERT_EQ(OK, cb.GetResult(rv));
195 193
196 // RESPONSE_INFO_TRUNCATED defined on response_info.cc 194 // RESPONSE_INFO_TRUNCATED defined on response_info.cc
197 int flags = 1 << 12; 195 int flags = 1 << 12;
198 WriteHeaders(entry, flags, "something"); 196 WriteHeaders(entry, flags, "something");
199 entry->Close(); 197 entry->Close();
200 198
201 std::string data; 199 std::string data;
202 TestCompletionCallback cb1; 200 TestCompletionCallback cb1;
203 rv = helper.GetEntryInfoHTML(key, context, &data, cb1.callback()); 201 rv = helper.GetEntryInfoHTML(key, context, &data, cb1.callback());
204 EXPECT_EQ(OK, cb1.GetResult(rv)); 202 EXPECT_EQ(OK, cb1.GetResult(rv));
205 203
206 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED")); 204 EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED"));
207 } 205 }
208 206
209 } // namespace net 207 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/view_cache_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698