| 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/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 cache->Init(path); | 173 cache->Init(path); |
| 174 EXPECT_EQ(2, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 174 EXPECT_EQ(2, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
| 175 EXPECT_EQ(net::OK, cb.GetResult(cache->DeleteData(cb.callback()))); | 175 EXPECT_EQ(net::OK, cb.GetResult(cache->DeleteData(cb.callback()))); |
| 176 EXPECT_EQ(0, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 176 EXPECT_EQ(0, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
| 177 EXPECT_FALSE(file_util::PathExists(path)); | 177 EXPECT_FALSE(file_util::PathExists(path)); |
| 178 | 178 |
| 179 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); | 179 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); |
| 180 } | 180 } |
| 181 | 181 |
| 182 TEST(InfiniteCache, DeleteBetween) { | 182 TEST(InfiniteCache, DeleteBetween) { |
| 183 #if !defined(OS_ANDROID) |
| 183 ScopedTempDir dir; | 184 ScopedTempDir dir; |
| 184 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 185 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 185 FilePath path = dir.path().Append(FILE_PATH_LITERAL("infinite")); | 186 FilePath path = dir.path().Append(FILE_PATH_LITERAL("infinite")); |
| 186 | 187 |
| 187 scoped_ptr<InfiniteCache> cache(new InfiniteCache); | 188 scoped_ptr<InfiniteCache> cache(new InfiniteCache); |
| 188 cache->Init(path); | 189 cache->Init(path); |
| 189 net::TestCompletionCallback cb; | 190 net::TestCompletionCallback cb; |
| 190 | 191 |
| 191 Time::Exploded baseline = {}; | 192 Time::Exploded baseline = {}; |
| 192 baseline.year = 2012; | 193 baseline.year = 2012; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 225 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
| 225 | 226 |
| 226 // Make sure the data is deleted from disk. | 227 // Make sure the data is deleted from disk. |
| 227 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); | 228 EXPECT_EQ(net::OK, cb.GetResult(cache->FlushDataForTest(cb.callback()))); |
| 228 cache.reset(new InfiniteCache); | 229 cache.reset(new InfiniteCache); |
| 229 cache->Init(path); | 230 cache->Init(path); |
| 230 | 231 |
| 231 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 232 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
| 232 ProcessRequest(kTypicalGET_Transaction, cache.get()); | 233 ProcessRequest(kTypicalGET_Transaction, cache.get()); |
| 233 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); | 234 EXPECT_EQ(1, cb.GetResult(cache->QueryItemsForTest(cb.callback()))); |
| 235 #endif // OS_ANDROID |
| 234 } | 236 } |
| OLD | NEW |