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

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

Issue 10824336: Run the disk cache tests in scoped temporary directories instead of a fixed directory so that they … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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 | « no previous file | net/disk_cache/disk_cache_test_base.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) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 DisableFirstCleanup(); 2349 DisableFirstCleanup();
2350 SetMaxSize(20 * 1024 * 1024); 2350 SetMaxSize(20 * 1024 * 1024);
2351 SetNewEviction(); 2351 SetNewEviction();
2352 InitCache(); 2352 InitCache();
2353 BackendDoomAll2(); 2353 BackendDoomAll2();
2354 } 2354 }
2355 2355
2356 // We should be able to create the same entry on multiple simultaneous instances 2356 // We should be able to create the same entry on multiple simultaneous instances
2357 // of the cache. 2357 // of the cache.
2358 TEST_F(DiskCacheTest, MultipleInstances) { 2358 TEST_F(DiskCacheTest, MultipleInstances) {
2359 ScopedTestCache store1(cache_path_); 2359 ScopedTempDir store1, store2;
2360 ScopedTestCache store2("cache_test2"); 2360 ASSERT_TRUE(store1.CreateUniqueTempDir());
2361 ScopedTestCache store3("cache_test3"); 2361 ASSERT_TRUE(store2.CreateUniqueTempDir());
2362
2362 base::Thread cache_thread("CacheThread"); 2363 base::Thread cache_thread("CacheThread");
2363 ASSERT_TRUE(cache_thread.StartWithOptions( 2364 ASSERT_TRUE(cache_thread.StartWithOptions(
2364 base::Thread::Options(MessageLoop::TYPE_IO, 0))); 2365 base::Thread::Options(MessageLoop::TYPE_IO, 0)));
2365 net::TestCompletionCallback cb; 2366 net::TestCompletionCallback cb;
2366 2367
2367 const int kNumberOfCaches = 2; 2368 const int kNumberOfCaches = 2;
2368 disk_cache::Backend* cache[kNumberOfCaches]; 2369 disk_cache::Backend* cache[kNumberOfCaches];
2369 2370
2370 int rv = disk_cache::BackendImpl::CreateBackend( 2371 int rv = disk_cache::BackendImpl::CreateBackend(
2371 store1.path(), false, 0, net::DISK_CACHE, disk_cache::kNone, 2372 store1.path(), false, 0, net::DISK_CACHE, disk_cache::kNone,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 // Ping the oldest entry. 2568 // Ping the oldest entry.
2568 cache_->OnExternalCacheHit("key0"); 2569 cache_->OnExternalCacheHit("key0");
2569 2570
2570 TrimForTest(false); 2571 TrimForTest(false);
2571 2572
2572 // Make sure the older key remains. 2573 // Make sure the older key remains.
2573 EXPECT_EQ(1, cache_->GetEntryCount()); 2574 EXPECT_EQ(1, cache_->GetEntryCount());
2574 ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); 2575 ASSERT_EQ(net::OK, OpenEntry("key0", &entry));
2575 entry->Close(); 2576 entry->Close();
2576 } 2577 }
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698