summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/block_files_unittest.cc
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 20:22:37 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 20:22:37 +0000
commitebcb20c7ead50898319724aa42efb0e31acf1877 (patch)
treefc1b9f066fc9ac3aa2faa32ae56e765f9133423a /net/disk_cache/block_files_unittest.cc
parent55a75d99c6609ed4f6dc7052fcf3d907efaf7137 (diff)
downloadchromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.zip
chromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.tar.gz
chromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.tar.bz2
Convert BlockFiles to use FilePath instead of wstring.
BUG=24444 Review URL: http://codereview.chromium.org/274012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/block_files_unittest.cc')
-rw-r--r--net/disk_cache/block_files_unittest.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/net/disk_cache/block_files_unittest.cc b/net/disk_cache/block_files_unittest.cc
index 2ea930e..322c10c 100644
--- a/net/disk_cache/block_files_unittest.cc
+++ b/net/disk_cache/block_files_unittest.cc
@@ -14,9 +14,8 @@ using base::Time;
namespace {
// Returns the number of files in this folder.
-int NumberOfFiles(const std::wstring& path) {
- file_util::FileEnumerator iter(FilePath::FromWStringHack(path), false,
- file_util::FileEnumerator::FILES);
+int NumberOfFiles(const FilePath& path) {
+ file_util::FileEnumerator iter(path, false, file_util::FileEnumerator::FILES);
int count = 0;
for (FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) {
count++;
@@ -29,8 +28,8 @@ int NumberOfFiles(const std::wstring& path) {
namespace disk_cache {
TEST_F(DiskCacheTest, BlockFiles_Grow) {
- std::wstring path = GetCachePath();
- ASSERT_TRUE(DeleteCache(path.c_str()));
+ FilePath path = FilePath::FromWStringHack(GetCachePath());
+ ASSERT_TRUE(DeleteCache(path));
ASSERT_TRUE(file_util::CreateDirectory(path));
BlockFiles files(path);
@@ -56,8 +55,8 @@ TEST_F(DiskCacheTest, BlockFiles_Grow) {
// We should be able to delete empty block files.
TEST_F(DiskCacheTest, BlockFiles_Shrink) {
- std::wstring path = GetCachePath();
- ASSERT_TRUE(DeleteCache(path.c_str()));
+ FilePath path = FilePath::FromWStringHack(GetCachePath());
+ ASSERT_TRUE(DeleteCache(path));
ASSERT_TRUE(file_util::CreateDirectory(path));
BlockFiles files(path);
@@ -80,8 +79,8 @@ TEST_F(DiskCacheTest, BlockFiles_Shrink) {
// Handling of block files not properly closed.
TEST_F(DiskCacheTest, BlockFiles_Recover) {
- std::wstring path = GetCachePath();
- ASSERT_TRUE(DeleteCache(path.c_str()));
+ FilePath path = FilePath::FromWStringHack(GetCachePath());
+ ASSERT_TRUE(DeleteCache(path));
ASSERT_TRUE(file_util::CreateDirectory(path));
BlockFiles files(path);
@@ -158,19 +157,19 @@ TEST_F(DiskCacheTest, BlockFiles_Recover) {
// Handling of truncated files.
TEST_F(DiskCacheTest, BlockFiles_ZeroSizeFile) {
- std::wstring path = GetCachePath();
- ASSERT_TRUE(DeleteCache(path.c_str()));
+ FilePath path = FilePath::FromWStringHack(GetCachePath());
+ ASSERT_TRUE(DeleteCache(path));
ASSERT_TRUE(file_util::CreateDirectory(path));
BlockFiles files(path);
ASSERT_TRUE(files.Init(true));
- std::wstring filename = files.Name(0);
+ FilePath filename = files.Name(0);
files.CloseFiles();
// Truncate one of the files.
{
scoped_refptr<File> file(new File);
- ASSERT_TRUE(file->Init(FilePath::FromWStringHack(filename)));
+ ASSERT_TRUE(file->Init(filename));
EXPECT_TRUE(file->SetLength(0));
}
@@ -180,8 +179,8 @@ TEST_F(DiskCacheTest, BlockFiles_ZeroSizeFile) {
// An invalid file can be detected after init.
TEST_F(DiskCacheTest, BlockFiles_InvalidFile) {
- std::wstring path = GetCachePath();
- ASSERT_TRUE(DeleteCache(path.c_str()));
+ FilePath path = FilePath::FromWStringHack(GetCachePath());
+ ASSERT_TRUE(DeleteCache(path));
ASSERT_TRUE(file_util::CreateDirectory(path));
BlockFiles files(path);
@@ -192,7 +191,7 @@ TEST_F(DiskCacheTest, BlockFiles_InvalidFile) {
EXPECT_TRUE(NULL == files.GetFile(addr));
// Let's create an invalid file.
- FilePath filename(FilePath::FromWStringHack(files.Name(5)));
+ FilePath filename(files.Name(5));
char header[kBlockHeaderSize];
memset(header, 'a', kBlockHeaderSize);
EXPECT_EQ(kBlockHeaderSize,