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

Side by Side Diff: net/disk_cache/backend_unittest.cc

Issue 501099: Http cache: Add a test to make sure that the cache... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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/base/test_completion_callback.h ('k') | net/disk_cache/disk_cache_test_util.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/test_completion_callback.h"
12 #include "net/disk_cache/backend_impl.h" 13 #include "net/disk_cache/backend_impl.h"
13 #include "net/disk_cache/disk_cache_test_base.h" 14 #include "net/disk_cache/disk_cache_test_base.h"
14 #include "net/disk_cache/disk_cache_test_util.h" 15 #include "net/disk_cache/disk_cache_test_util.h"
15 #include "net/disk_cache/mapped_file.h" 16 #include "net/disk_cache/mapped_file.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using base::Time; 19 using base::Time;
19 20
20 namespace { 21 namespace {
21 22
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_EQ(0, entry->WriteData(0, 20000, buffer1, 0, NULL, false)); 202 ASSERT_EQ(0, entry->WriteData(0, 20000, buffer1, 0, NULL, false));
202 entry->Close(); 203 entry->Close();
203 204
204 // And verify that the first file is still there. 205 // And verify that the first file is still there.
205 scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kSize); 206 scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kSize);
206 ASSERT_EQ(kSize, file_util::ReadFile(filename, buffer2->data(), kSize)); 207 ASSERT_EQ(kSize, file_util::ReadFile(filename, buffer2->data(), kSize));
207 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize)); 208 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize));
208 } 209 }
209 210
210 TEST_F(DiskCacheTest, ShutdownWithPendingIO) { 211 TEST_F(DiskCacheTest, ShutdownWithPendingIO) {
211 SimpleCallbackTest callback; 212 TestCompletionCallback callback;
212 213
213 { 214 {
214 FilePath path = GetCacheFilePath(); 215 FilePath path = GetCacheFilePath();
215 ASSERT_TRUE(DeleteCache(path)); 216 ASSERT_TRUE(DeleteCache(path));
216 217
217 disk_cache::Backend* cache = 218 disk_cache::Backend* cache =
218 disk_cache::CreateCacheBackend(path, false, 0, net::DISK_CACHE); 219 disk_cache::CreateCacheBackend(path, false, 0, net::DISK_CACHE);
219 220
220 disk_cache::Entry* entry; 221 disk_cache::Entry* entry;
221 ASSERT_TRUE(cache->CreateEntry("some key", &entry)); 222 ASSERT_TRUE(cache->CreateEntry("some key", &entry));
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 EXPECT_EQ(kDefaultSize * 5 / 2, 1572 EXPECT_EQ(kDefaultSize * 5 / 2,
1572 disk_cache::PreferedCacheSize(large_size * 100 / 2)); 1573 disk_cache::PreferedCacheSize(large_size * 100 / 2));
1573 EXPECT_EQ(kDefaultSize * 5 / 2, 1574 EXPECT_EQ(kDefaultSize * 5 / 2,
1574 disk_cache::PreferedCacheSize(large_size * 500 / 2)); 1575 disk_cache::PreferedCacheSize(large_size * 500 / 2));
1575 1576
1576 EXPECT_EQ(kDefaultSize * 6 / 2, 1577 EXPECT_EQ(kDefaultSize * 6 / 2,
1577 disk_cache::PreferedCacheSize(large_size * 600 / 2)); 1578 disk_cache::PreferedCacheSize(large_size * 600 / 2));
1578 EXPECT_EQ(kDefaultSize * 7 / 2, 1579 EXPECT_EQ(kDefaultSize * 7 / 2,
1579 disk_cache::PreferedCacheSize(large_size * 700 / 2)); 1580 disk_cache::PreferedCacheSize(large_size * 700 / 2));
1580 } 1581 }
OLDNEW
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/disk_cache/disk_cache_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698