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/disk_cache/flash/flash_cache_test_base.h" | 5 #include "net/disk_cache/flash/flash_cache_test_base.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "net/disk_cache/flash/format.h" | 10 #include "net/disk_cache/flash/format.h" |
11 #include "net/disk_cache/flash/log_store.h" | 11 #include "net/disk_cache/flash/log_store.h" |
12 #include "net/disk_cache/flash/storage.h" | 12 #include "net/disk_cache/flash/storage.h" |
13 | 13 |
14 namespace { | 14 FlashCacheTest::FlashCacheTest() { |
15 | |
16 const int32 kSegmentCount = 10; | |
17 const base::FilePath::StringType kCachePath = FILE_PATH_LITERAL("cache"); | |
18 | |
19 } // namespace | |
20 | |
21 FlashCacheTest::FlashCacheTest() : num_segments_in_storage_(kSegmentCount) { | |
22 int seed = static_cast<int>(base::Time::Now().ToInternalValue()); | 15 int seed = static_cast<int>(base::Time::Now().ToInternalValue()); |
23 srand(seed); | 16 srand(seed); |
24 } | 17 } |
25 | 18 |
26 FlashCacheTest::~FlashCacheTest() { | 19 FlashCacheTest::~FlashCacheTest() { |
27 } | 20 } |
28 | 21 |
29 void FlashCacheTest::SetUp() { | 22 void FlashCacheTest::SetUp() { |
| 23 const base::FilePath::StringType kCachePath = FILE_PATH_LITERAL("cache"); |
30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 24 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
31 const base::FilePath path(temp_dir_.path().Append(kCachePath)); | 25 path_ = temp_dir_.path().Append(kCachePath); |
32 | |
33 int32 storage_size = num_segments_in_storage_ * disk_cache::kFlashSegmentSize; | |
34 storage_.reset(new disk_cache::Storage(path, storage_size)); | |
35 ASSERT_TRUE(storage_->Init()); | |
36 | |
37 log_store_.reset(new disk_cache::LogStore(storage_.get())); | |
38 ASSERT_TRUE(log_store_->Init()); | |
39 } | 26 } |
40 | 27 |
41 void FlashCacheTest::TearDown() { | 28 void FlashCacheTest::TearDown() { |
42 ASSERT_TRUE(log_store_->Close()); | |
43 log_store_.reset(); | |
44 storage_.reset(); | |
45 } | 29 } |
OLD | NEW |