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 "chrome/browser/chromeos/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 TEST_F(FileCacheTest, ScanCacheFile) { | 853 TEST_F(FileCacheTest, ScanCacheFile) { |
854 // Set up files in the cache directory. | 854 // Set up files in the cache directory. |
855 const base::FilePath file_directory = | 855 const base::FilePath file_directory = |
856 temp_dir_.path().Append(util::kCacheFileDirectory); | 856 temp_dir_.path().Append(util::kCacheFileDirectory); |
857 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( | 857 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( |
858 file_directory.AppendASCII("id_foo"), "foo")); | 858 file_directory.AppendASCII("id_foo"), "foo")); |
859 | 859 |
860 // Remove the existing DB. | 860 // Remove the existing DB. |
861 const base::FilePath metadata_directory = | 861 const base::FilePath metadata_directory = |
862 temp_dir_.path().Append(util::kMetadataDirectory); | 862 temp_dir_.path().Append(util::kMetadataDirectory); |
863 ASSERT_TRUE(base::Delete(metadata_directory, true /* recursive */)); | 863 ASSERT_TRUE(base::DeleteFile(metadata_directory, true /* recursive */)); |
864 | 864 |
865 // Put an empty file with the same name as old DB. | 865 // Put an empty file with the same name as old DB. |
866 // This file cannot be opened by ImportOldDB() and will be dismissed. | 866 // This file cannot be opened by ImportOldDB() and will be dismissed. |
867 ASSERT_TRUE(file_util::CreateDirectory(metadata_directory)); | 867 ASSERT_TRUE(file_util::CreateDirectory(metadata_directory)); |
868 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( | 868 ASSERT_TRUE(google_apis::test_util::WriteStringToFile( |
869 metadata_directory.Append(FileCache::kOldCacheMetadataDBName), "")); | 869 metadata_directory.Append(FileCache::kOldCacheMetadataDBName), "")); |
870 | 870 |
871 // Create a new cache and initialize it. | 871 // Create a new cache and initialize it. |
872 metadata_storage_.reset(new ResourceMetadataStorage( | 872 metadata_storage_.reset(new ResourceMetadataStorage( |
873 metadata_directory, base::MessageLoopProxy::current().get())); | 873 metadata_directory, base::MessageLoopProxy::current().get())); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 &contents)); | 998 &contents)); |
999 EXPECT_EQ("koo", contents); | 999 EXPECT_EQ("koo", contents); |
1000 contents.clear(); | 1000 contents.clear(); |
1001 EXPECT_TRUE(file_util::ReadFileToString(file_directory.AppendASCII("id_kyu"), | 1001 EXPECT_TRUE(file_util::ReadFileToString(file_directory.AppendASCII("id_kyu"), |
1002 &contents)); | 1002 &contents)); |
1003 EXPECT_EQ("kyu", contents); | 1003 EXPECT_EQ("kyu", contents); |
1004 } | 1004 } |
1005 | 1005 |
1006 } // namespace internal | 1006 } // namespace internal |
1007 } // namespace drive | 1007 } // namespace drive |
OLD | NEW |