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/http/infinite_cache.h" | 5 #include "net/http/infinite_cache.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/stringprintf.h" | |
9 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
10 #include "base/time.h" | 11 #include "base/time.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
13 #include "net/http/http_transaction_unittest.h" | 14 #include "net/http/http_transaction_unittest.h" |
14 #include "net/http/http_util.h" | 15 #include "net/http/http_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 using base::Time; | 18 using base::Time; |
18 using base::TimeDelta; | 19 using base::TimeDelta; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 // Make sure the data is deleted from disk. | 239 // Make sure the data is deleted from disk. |
239 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); | 240 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); |
240 cache.reset(new InfiniteCache); | 241 cache.reset(new InfiniteCache); |
241 cache->Init(path); | 242 cache->Init(path); |
242 | 243 |
243 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 244 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
244 ProcessRequest(kTypicalGET_Transaction, cache.get()); | 245 ProcessRequest(kTypicalGET_Transaction, cache.get()); |
245 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 246 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
246 #endif // OS_ANDROID | 247 #endif // OS_ANDROID |
247 } | 248 } |
249 | |
250 #if 0 | |
tburkard
2012/11/30 19:00:54
How about not using #if 0, but making it Disabled,
rvargas (doing something else)
2012/11/30 19:12:23
I don't care that much either way, but we have reg
| |
251 // This test is too slow for the bots. | |
252 TEST(InfiniteCache, FillUp) { | |
253 base::ScopedTempDir dir; | |
254 ASSERT_TRUE(dir.CreateUniqueTempDir()); | |
255 FilePath path = dir.path().Append(FILE_PATH_LITERAL("infinite")); | |
256 | |
257 scoped_ptr<InfiniteCache> cache(new InfiniteCache); | |
258 cache->Init(path); | |
259 net::TestCompletionCallback cb; | |
260 | |
261 const int kNumEntries = 25000; | |
262 for (int i = 0; i < kNumEntries; i++) { | |
263 std::string url = StringPrintf("http://foo.com/%d/foo.html", i); | |
264 MockTransaction transaction = kTypicalGET_Transaction; | |
265 transaction.url = url.c_str(); | |
266 ProcessRequest(transaction, cache.get()); | |
267 } | |
268 | |
269 EXPECT_EQ(kNumEntries, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | |
270 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); | |
271 | |
272 cache.reset(new InfiniteCache); | |
273 cache->Init(path); | |
274 EXPECT_EQ(kNumEntries, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | |
275 } | |
276 #endif | |
OLD | NEW |